diff options
author | Matt Strapp <strap012@umn.edu> | 2021-04-26 15:00:48 -0500 |
---|---|---|
committer | Matt Strapp <strap012@umn.edu> | 2021-04-26 15:03:24 -0500 |
commit | 2635d82c955ffdbf1c9778ce02e3ffc82a266886 (patch) | |
tree | 438c299b8b869df29e43e7c0ce3ee917e5ad0f98 /python/agent.py | |
parent | change base??? (diff) | |
download | csci4511w-2635d82c955ffdbf1c9778ce02e3ffc82a266886.tar csci4511w-2635d82c955ffdbf1c9778ce02e3ffc82a266886.tar.gz csci4511w-2635d82c955ffdbf1c9778ce02e3ffc82a266886.tar.bz2 csci4511w-2635d82c955ffdbf1c9778ce02e3ffc82a266886.tar.lz csci4511w-2635d82c955ffdbf1c9778ce02e3ffc82a266886.tar.xz csci4511w-2635d82c955ffdbf1c9778ce02e3ffc82a266886.tar.zst csci4511w-2635d82c955ffdbf1c9778ce02e3ffc82a266886.zip |
Revert "change base???"
This reverts commit 6b9335b670df03d3452a9f65f03e1884d60ac88b.
Diffstat (limited to 'python/agent.py')
-rw-r--r-- | python/agent.py | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/python/agent.py b/python/agent.py deleted file mode 100644 index 49bc1cc..0000000 --- a/python/agent.py +++ /dev/null @@ -1,55 +0,0 @@ -import dotsandboxes.dotsandboxesagent as dba - -import sys -import argparse -import logging -from GameState import GameState, DotsAndBoxesState -from MCTS import MCTSNode, MCTSGameController - - -logger = logging.getLogger(__name__) -games = {} -agentclass = None - - -class Agent(dba.DotsAndBoxesAgent): - def __init__(self, player, nb_rows, nb_cols, timelimit): - super(Agent, self).__init__(player, nb_rows, nb_cols, timelimit) - self.GameStateClass = DotsAndBoxesState - self.game_state = self.GameStateClass(nb_rows, nb_cols, player) - self.controller = MCTSGameController() - - def register_action(self, row, column, orientation, player): - super(Agent, self).register_action(row, column, orientation, player) - # adjust agent specific board representation - move = (row, column, orientation) - self.game_state.play_move(move) - - def next_action(self): - r, c, o = self.controller.get_next_move(self.game_state, time_allowed=self.timelimit) - return r, c, o - - def end_game(self): - super(Agent, self).end_game() - - -# Adapted from provided code -def main(argv=None): - global agentclass - parser = argparse.ArgumentParser(description='Start agent to play Dots and Boxes') - parser.add_argument('--verbose', '-v', action='count', default=0, help='Verbose output') - parser.add_argument('--quiet', '-q', action='count', default=0, help='Quiet output') - parser.add_argument('port', metavar='PORT', type=int, help='Port to use for server') - args = parser.parse_args(argv) - - logger.setLevel(max(logging.INFO - 10 * (args.verbose - args.quiet), logging.DEBUG)) - logger.addHandler(logging.StreamHandler(sys.stdout)) - - agentclass = Agent - dba.agentclass = Agent - dba.start_server(args.port) - - -if __name__ == "__main__": - sys.exit(main()) - |