Exemplo n.º 1
0
def game_random(game_id):
    # Play the v4 of the game only with random agent
    game_type = game_id.title() + '-v4'
    game = gm.Game(game_type)
    agent_id = 'random'
    return render_template("game.html", title=game_type, \
                           game_type=game_type, agent_id=agent_id)
Exemplo n.º 2
0
def game_view(game_id):
    games = gm.Games()
    list_of_game_types = games.get_games_from_key(game_id)
    description_dict = dict()
    for game_type in list_of_game_types:
        game = gm.Game(game_type)
        description = game.get_description()
        description = '\n'.join(map(str, description))
        description_dict[game_type] = description

    json_object = list_of_game_types
    return render_template("game_menu.html", title=game_id.title(),\
                           game_id=game_id, games=json_object,\
                           description_dict=description_dict)
Exemplo n.º 3
0
def delete_game_db_entry():
    games = gm.Games()
    pack = games.dict_names()

    print('BEGIN')
    for key in pack:
        game_type = games.get_games_from_key(key)[0]

        game = gm.Game(game_type)
        flag, encodedImage = game.get_static_image()
        encodedImage = encodedImage.reshape(-1).tolist()
        mongo.db.games.delete_one(
            {"game_id": key})
    print('END')
    return 'Done updating game entries'
Exemplo n.º 4
0
def save_game_posters_local():
    games = gm.Games()
    pack = games.dict_names()
    print('BEGIN')
    for key in pack:
        game_type = games.get_games_from_key(key)[0]
        game = gm.Game(game_type)
        frame = game.show_frame()

        filename = str(key)+".jpg"

        cv2.imwrite(\
            'C:/Users/user/Desktop/GitHub/Gym-Web-App/static/images/'+filename,\
            frame)
    print('END')
    return 'Done saving images'
Exemplo n.º 5
0
def create_game_db_entry():
    games = gm.Games()
    pack = games.dict_names()
    collection = mongo.db.games
    print('BEGIN')
    for key in pack:
        game_type = games.get_games_from_key(key)[0]

        game = gm.Game(game_type)
        flag, encodedImage = game.get_static_image()
        encodedImage = encodedImage.reshape(-1).tolist()
        collection.insert({
            "game_id": key,
            "name": pack[key].title(),
            "timestamp": datetime.datetime.now(),
            "image": encodedImage,
        })
    print('END')
    return 'Done creating game entries'
Exemplo n.º 6
0
def update_game_db_entry():
    games = gm.Games()
    pack = games.dict_names()

    print('BEGIN')
    for key in pack:
        game_type = games.get_games_from_key(key)[0]

        game = gm.Game(game_type)
        flag, encodedImage = game.get_static_image()
        encodedImage = encodedImage.reshape(-1).tolist()
        mongo.db.games.update_one(
            {"game_id": key},
            {'$set':{
                "name": pack[key].title(),
                "timestamp": datetime.datetime.now(),
                "image": encodedImage,
            }
        })
    print('END')
    return 'Done updating game entries'
Exemplo n.º 7
0
def game_feed(game_type, agent_id):
    # return the response generated along with the specific media
    # type (mime type)
    game = gm.Game(game_type, agent_id)
    return Response(game.play(),\
                    mimetype="multipart/x-mixed-replace; boundary=frame")
Exemplo n.º 8
0
def game_description(game_type):
    game = gm.Game(game_type)
    description_list = game.get_description()
    description_json = dumps(enumerate(description_list))
    return Response(description_json)