예제 #1
0
def end():
    data = bottle.request.json
    """
    TODO: If your snake AI was stateful,
        clean up any stateful objects here.
    """
    return end_response()
예제 #2
0
파일: main.py 프로젝트: kanatade/dariasnake
def end():
    data = bottle.request.json

    print("end part")
    print("================")
    # print(json.dumps(data))

    return end_response()
예제 #3
0
def end():
    data = bottle.request.json
    """
    TODO: If your snake AI was stateful,
        clean up any stateful objects here.
    """
    print(json.dumps(data, indent=4))

    return end_response()
예제 #4
0
def end():
    data = bottle.request.json

    print(json.dumps(data, indent=4))
    print('\n============GAMEOVER==============\n')

    #concat the state info to a json file

    return end_response()
예제 #5
0
def end():
    """This is called every time the game ends"""
    data = bottle.request.json
    #This gets rid of the object that is corisponding to this game
    del GAMES[findCurGameIndex(GAMES, data)]

    # print(json.dumps(data))

    return end_response()
예제 #6
0
def end():
    data = bottle.request.json
    """
    TODO: If your snake AI was stateful,
        clean up any stateful objects here.
    """
    # print("---------- ---------- END OF GAME ---------- ----------")
    # print(json.dumps(data))

    return end_response()
예제 #7
0
def end():
    data = bottle.request.json

    """
    TODO: If your snake AI was stateful,
        clean up any stateful objects here.
    """
    # dangerous(json.dumps(data))

    return end_response()
예제 #8
0
def end():
    data = bottle.request.json
    """
    TODO: If your snake AI was stateful,
        clean up any stateful objects here.
    """
    with open(f'snake_{sys.argv[1]}.txt', 'w') as f:
        print(f"WRITING {score}")
        f.write(f'{score}')
    return end_response()
예제 #9
0
def end():
    print 'end received'
    data = bottle.request.json
    """
    TODO: If your snake AI was stateful,
        clean up any stateful objects here.
    """
    # print(json.dumps(data))

    return end_response()
예제 #10
0
def end():
    data = bottle.request.json
    """
    TODO: If your snake AI was stateful,
        clean up any stateful objects here.
    """
    print('\n*------END------*')
    print(json.dumps(data))
    games.pop(data['game']['id'])

    return end_response()
예제 #11
0
def end():
    data = bottle.request.json
    """
    TODO: If your snake AI was stateful,
        clean up any stateful objects here.
    """
    print("end part")
    print("================")
    # print(json.dumps(data))

    return end_response()
예제 #12
0
def end():
    data = bottle.request.json
    """
    TODO: If your snake AI was stateful,
        clean up any stateful objects here.
    """
    # print("### end()")
    # print(json.dumps(data))

    print("##### GAME OVER #####")

    return end_response()
예제 #13
0
def end():
    global state
    data = bottle.request.json
    """
    TODO: If your snake AI was stateful,
        clean up any stateful objects here.
    """
    # print(json.dumps(data))

    state = {}

    return end_response()
예제 #14
0
def end():
    data = bottle.request.json
    wonGameFlag = False
    snakeNames = []
    for snake in data["board"]["snakes"]:
        snakeNames.append(snake["name"])
    # Check if we are in the list of snakes at the termination of the game, if so
    # we have won!
    if len(data["board"]["snakes"]) == 1 and data["you"]["name"] in snakeNames:
        wonGameFlag = True
    envi.endEnvi(wonGameFlag)
    return end_response()
예제 #15
0
def end():
    global floodGrid
    data = bottle.request.json
    # end_grid_file = open("Death_grid.txt", "w")
    # end_grid_file.write(floodGrid.to_string())
    # end_grid_file.close()
    """
    TODO: If your snake AI was stateful,
        clean up any stateful objects here.
    """
    # print(json.dumps(data))

    return end_response()
def end():
    data = bottle.request.json
    won = False
    if data != None:
        if data["game"]["id"] == envi.getCurrentGame() \
        and data["you"]["id"] == envi.getCurrentSnake():
            envi.setCurrentGameParams("", "")
            snakeNames = []
            for snake in data["board"]["snakes"]:
                snakeNames.append(snake["name"])
            if len(data["board"]["snakes"]) <= 1 and (data["you"]["name"]
                                                      in snakeNames):
                won = True
            envi.endEnvi(won)
    return end_response()
예제 #17
0
def end():
    global gamecount
    global movecount
    #queue needed to pass value back to parent
    #print(movecount)
    queue.put(movecount)
    gamecount = gamecount + 1
    movecount = 0
    #application.close()
    #sys.stderr.close()
    #server.stop()
    try:
        return end_response()
    finally:
        if (gamecount == 3):
            server.stop()
예제 #18
0
def end():
    data = bottle.request.json

    """
    TODO: If your snake AI was stateful,
        clean up any stateful objects here.
    """
    
    # x=data['turn']
    

# print(x)
    
    ##print(json.dumps(data))

    return end_response()
예제 #19
0
def end():
    data = bottle.request.json
    """
    TODO: If your snake AI was stateful,
        clean up any stateful objects here.
    """
    you = data['you']
    you_id = you['id']
    globalList_index = len(globalList) - 1
    while globalList_index >= 0:
        globalList_token = globalList[globalList_index]
        if globalList_token[0] == you_id:
            del globalList[globalList_index]
            break
        else:
            globalList_index = -1

    # print(json.dumps(data))

    return end_response()
예제 #20
0
def move():
    data = bottle.request.json
    """
    TODO: Using the data from the endpoint request object, your
            snake AI must choose a direction to move in.
    """

    print(json.dumps(data, indent=2))

    global last_move
    #ay yo vide check

    board_max_y = data['board']['width']
    board_max_x = data['board']['height']
    head_x = data['you']['body'][0]['x']
    print('Your head is: ', head_x)
    head_y = data['you']['body'][0]['y']
    print('Your head_y is: ', head_y)
    apple_x = data['board']['food'][0]['x']
    print('The apple_x is:', apple_x)
    apple_y = data['board']['food'][0]['y']
    print('The apple_y is :', apple_y)
    HP = data['you']['health']
    print('Health is: ', HP)
    size = len(data['you']['body'])
    print('size is: ', size)
    loop_size = size - 3
    print('loop size is, ', loop_size)
    apple_right = apple_x > head_x
    apple_left = apple_x < head_x
    apple_down = apple_y > head_y
    apple_up = apple_y < head_y
    tail_x = data['you']['body'][-1]['x']
    print('Tail x is :', tail_x)
    tail_y = data['you']['body'][-1]['y']
    print('Tail y is :', tail_y)
    directions = ['up', 'down', 'left', 'right']
    direction = 'none'
    #snake1 = len['board']['snakes'][0]['body']
    #snake2= len['board']['snakes'][1]['body']
    #snake3 = len['board']['snakes'][2]['body']
    #snake4 = len['board']['snakes'][3]['body']
    #snake1_x = data['board']['snakes'][0]['body'][0]['x']
    #print ('Snake 1 x is :',snake_1)
    #snake2_x= data['board']['snakes'][1]['body'][0]['x']
    #snake3_x = data['board']['snakes'][2]['body'][0]['x']
    #snake4_x = data['board']['snakes'][3]['body'][0]['x']
    #snake1_y = data['board']['snakes'][0]['body'][0]['y']
    #snake2_y= data['board']['snakes'][1]['body'][0]['y']
    #snake3_y = data['board']['snakes'][2]['body'][0]['y']
    #snake4_y = data['board']['snakes'][3]['body'][0]['y']

    othersize = []
    for s in data['board']['snakes']:
        for b in s['body']:
            len(b)
    print('othersize:', othersize)
    snakes = []
    for s in data['board']['snakes']:
        for b in s['body']:
            c = h.Coord(b)
            snakes.append(c)

    #caculate food

    #cant hit walls
    if head_y == 0:
        direction = 'right'
    if head_x == board_max_x - 1:
        direction = 'down'
    if head_y == board_max_y - 1:
        direction = 'left'
    if head_y == 0:
        direction = 'up'

    #apple eater
    print('direction is: ', direction)
    if size >= 3:
        target = h.Coord({'x': apple_x, 'y': apple_y})
        start = h.Coord({'x': head_x, 'y': head_y})
        direction = h.floodForTarget(start, [target], snakes)

    return move_response(direction)

    @bottle.post('/end')
    def end():
        data = bottle.request.json

    #"""
    #TODO: If your snake AI was stateful,
    #    clean up any stateful objects here.
    #"""
    print(json.dumps(data))

    return end_response()
예제 #21
0
def end():
    game_state = bottle.request.json
    return end_response()
예제 #22
0
def end():
    data = request.get_json()
    logging.debug(f"/end request: {json.dumps(data)}")
    return end_response()
예제 #23
0
def end():
    # """
    # TODO: If your snake AI was stateful,
    #     clean up any stateful objects here.
    # """
    return end_response()
예제 #24
0
def end():
	print("***END***")
	return end_response()
예제 #25
0
def end():
    data = request.get_json()
    print(json.dumps(data))

    return end_response()
예제 #26
0
def end():
    return end_response()
예제 #27
0
def end():
    data = bottle.request.json

    return end_response()
예제 #28
0
def end():
    data = bottle.request.json

    print(json.dumps(data))

    return end_response()