Skip to content

Instantly share code, notes, and snippets.

View mpeterv's full-sized avatar

Peter Melnichenko mpeterv

View GitHub Profile
@mpeterv
mpeterv / lchecks.lua
Created April 15, 2014 17:13
Pure Lua implementation of checks
--[[
Argument type checking API.
This library declares a `checks()` function and a `checkers` table, which
allow to check the parameters passed to a Lua function in a fast and
unobtrusive way.
`checks (type_1, ..., type_n)`, when called directly inside function
`f`, checks that `f`'s 1st argument conforms to `type_1`, that its 2nd
argument conforms to `type_2`, etc. until `type_n`. Type specifiers
@mpeterv
mpeterv / report
Created April 6, 2014 13:50
cd shine/src && luacheck *.lua */*.lua --no-unused-args --ignore setfenv getfenv newproxy
Checking main.lua Failure
main.lua:54:10: variable env was previously defined as an argument in the same scope
main.lua:111:10: variable args was previously defined as an argument in the same scope
Checking shnc.lua OK
Checking core/init.lua Failure
core/init.lua:23:7: unused variable xpcall
core/init.lua:51:4: setting non-standard global variable copy
@mpeterv
mpeterv / metalua-parser-0.7.3-3.rockspec
Created March 25, 2014 06:24
metalua-parser-0.7.3-3.rockspec
--*-lua-*--
package = "metalua-parser"
version = "0.7.3-3"
source = {
url = "http://git.eclipse.org/c/koneki/org.eclipse.koneki.metalua.git/snapshot/org.eclipse.koneki.metalua-v0.7.3.tar.gz"
}
description = {
summary = "Metalua's parser: converting Lua source strings and files into AST",
detailed = [[
This is a subset of the full Metalua compiler. It defines and generates an AST
@mpeterv
mpeterv / random_spec.lua
Created January 10, 2014 18:52
randomized test suit for serpent
local serpent = require "serpent"
local function random_var(is_key, deep)
local key = math.random(1000)
if key <= 100 then
if is_key then
return 0
else
return nil
@mpeterv
mpeterv / game.py
Created December 19, 2013 19:20
Rewritten game.py
import copy
import imp
import random
import sys
import traceback
from collections import defaultdict
from rgkit import rg
from rgkit.settings import settings, AttrDict
@mpeterv
mpeterv / template.py
Created December 16, 2013 20:02
Template for a robotgame bot
class Game:
def __init__(self, data, player_id):
self.player_id = player_id
self.update(data)
def update(self, data):
self.turn = data['turn']
self.robots = data['robots']
self.onNewTurn()