football
football copied to clipboard
Play without human, watch two AIs or Bots play against each other (with rendering)
Just trying to make to get any combination of players work without human type of player (keyboard):
python -m gfootball.play_game --action_set=full --players "lazy:left_players=1;bot:right_players=1"
python -m gfootball.play_game --action_set=full --players "bot:left_players=1;bot:right_players=1"
python -m gfootball.play_game --action_set=full --players "lazy:left_players=1;lazy:right_players=1"
python -m gfootball.play_game --players "lazy:left_players=1;lazy:right_players=1"
The game just hangs and never renders a single frame (Mac). Any suggestions? Thanks!
@asyschikov The proposed commands don't work on my Mac too. I'll try to look into it.
add few lines code into gfootball/env/players/agent.py as below will solve this problem. I am not sure this is the best solution.
"""Agent player controlled by the training policy and using step/reset API."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import copy
from gfootball.env import player_base
import pygame
class Player(player_base.PlayerBase):
def __init__(self, player_config, env_config):
player_base.PlayerBase.__init__(self, player_config)
assert player_config['player_agent'] == 0, 'Only one \'agent\' player allowed'
self._action = None
self._init_done = False
pygame.init()
def set_action(self, action):
self._action = action
def take_action(self, observations):
if not self._init_done:
self._init_done = True
pygame.display.set_mode((1, 1), pygame.NOFRAME)
pygame.event.get()
return copy.deepcopy(self._action)