Code is at: https://github.com/jackdoe/programming-for-kids
If you want to play locally, click here
Or send your friend this link to play:
Code is at: https://github.com/jackdoe/programming-for-kids
Rules:
* join your forces to increase the number on one position
* bigger number wins, but takes up to smaller number damage
* create new numbers:
the patterns
n n
n
and
n
n n
spawns a number in the empty space, randint(1,3), but there
is 1 in 10 chance it is a zombie and it will be from
the oposite team, beware!
* things are sorted left to right, and top to bottom
* you can move +-2 in x and y direction
examples (red):
def evolve(red, blue, grid):
print(red)
for r in red:
r["x"] += 1
r["y"] += 2
return red
def evolve(red, blue, grid):
if grid[0][5] != None:
grid[0][5]["y"] += 1
return red
def evolve(red, blue, grid):
for row in grid:
for v in row:
if v != None and "red" in v:
v["x"] += 1
v["y"] += 2
return red
def evolve(red, blue, grid):
for (i,r) in enumerate(red):
if i % 2 != 0:
r["y"] += 1
else:
r["y"] += 2
return red
def evolve(red, blue, grid):
for r in red:
if r["x"] % 2 != 0:
r["y"] += 1
else:
r["y"] += 2
return red
def evolve(red, blue, grid):
# you can print and use console.log to debug
print(blue)
return blue
or a javascript example:
function evolve({red,blue,grid}) {
for (let r of red) {
r.x ++
r.y += 2
}
return red
}
* cheating
there is some cheating allowed by modifying the grid state in
the location.hash, this is great opportunity to teach about
validating user input in practice.
the format is [x,y,value,x,y,value...] so [2,1,-5] will
spawn 5 on x=2 and y=1
* license: