Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
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)
"""
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())
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)