How to use the magent.utility.check_model function in magent

To help you get started, we’ve selected a few magent examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github geek-ai / MAgent / examples / show_arrange.py View on Github external
"""


import os
import sys

import magent
from magent.renderer import PyGameRenderer
from magent.renderer.server import ArrangeServer as Server

if __name__ == "__main__":
    if len(sys.argv) < 2:
        print("Usage: python show_arrange.py messages...")
        exit()

    magent.utility.check_model('arrange')
    PyGameRenderer().start(Server(messages=sys.argv[1:]), grid_size=3.5)
github geek-ai / MAgent / examples / show_battle_game.py View on Github external
"""
Interactive game, Pygame are required.
Act like a general and dispatch your solders.
"""

import os

import magent
from magent.renderer import PyGameRenderer
from magent.renderer.server import BattleServer as Server


if __name__ == "__main__":
    magent.utility.check_model('battle-game')
    PyGameRenderer().start(Server())
github geek-ai / MAgent / examples / train_against.py View on Github external
parser.add_argument("--render_every", type=int, default=10)
    parser.add_argument("--n_round", type=int, default=600)
    parser.add_argument("--n_step", type=int, default=550)
    parser.add_argument("--render", action="store_true")
    parser.add_argument("--load_from", type=int)
    parser.add_argument("--train", action="store_true")
    parser.add_argument("--map_size", type=int, default=125)
    parser.add_argument("--greedy", action="store_true")
    parser.add_argument("--name", type=str, default="against")
    parser.add_argument("--eval", action="store_true")
    parser.add_argument("--opponent", type=int, default=0)
    parser.add_argument('--alg', default='dqn', choices=['dqn', 'drqn', 'a2c'])
    args = parser.parse_args()

    # download opponent model
    magent.utility.check_model('against')

    # set logger
    magent.utility.init_logger(args.name)

    # init the game
    env = magent.GridWorld("battle", map_size=args.map_size)
    env.set_render_dir("build/render")

    # two groups of agents
    handles = env.get_handles()

    # sample eval observation set
    if args.eval:
        print("sample eval set...")
        env.reset()
        generate_map(env, args.map_size, handles)