Ejemplo n.º 1
0
def get_max_counter(maze_id):
    world = db.get_world(maze_id)
    ret = {
        "max": world.farm.counter
    }

    return json.dumps(ret)
Ejemplo n.º 2
0
def get_maze(maze_id):
    world = db.get_world(maze_id)

    ret = {
        'maze' : world.farm.a_svg_maze
    }

    return json.dumps(ret)
Ejemplo n.º 3
0
def get_action(maze_id, action_id):
    world = db.get_world(maze_id)

    if action_id > world.client_counter:
        world.client_counter = action_id
        db.save_world(maze_id, world)

    info = db.get_info(maze_id, action_id)
    print "GETTING", maze_id, action_id
    return info
Ejemplo n.º 4
0
def get_action(maze_id,action_id):
    world = db.get_world(maze_id)

    if action_id > world.client_counter:
        world.client_counter = action_id
        db.save_world(maze_id, world)


    info = db.get_info(maze_id, action_id)
    print "GETTING", maze_id, action_id
    return info
Ejemplo n.º 5
0
def increment_world():
    for key in db.list_worlds():
        world = db.get_world(key)
        # only do work on the server 10 moves ahead of client
        if world.farm.counter <= 50 + world.client_counter:
            world.farm.run_farm()

            db.save_info(world.farm.make_json(), key, world.farm.counter)

            world.farm.counter += 1

            print 'ANT FARM COUNTER: ', world.farm.counter
            db.save_world(key, world)
Ejemplo n.º 6
0
def increment_world():
    for key in db.list_worlds():
        world = db.get_world(key)  
        # only do work on the server 10 moves ahead of client
        if world.farm.counter <= 50 + world.client_counter:
            world.farm.run_farm()

            db.save_info(world.farm.make_json(), key, world.farm.counter)

            world.farm.counter += 1

            print 'ANT FARM COUNTER: ', world.farm.counter
            db.save_world(key, world)
Ejemplo n.º 7
0
def get_maze(maze_id):
    world = db.get_world(maze_id)

    ret = {'maze': world.farm.a_svg_maze}

    return json.dumps(ret)
Ejemplo n.º 8
0
def get_max_counter(maze_id):
    world = db.get_world(maze_id)
    ret = {"max": world.farm.counter}

    return json.dumps(ret)
Ejemplo n.º 9
0
def ant_maze(maze_id=0):
    world = db.get_world(maze_id)

    return render_template('maze.html', maze_id=maze_id)
Ejemplo n.º 10
0
def ant_maze(maze_id=0):
    world = db.get_world(maze_id)

    return render_template('maze.html', maze_id=maze_id)