From 2635d82c955ffdbf1c9778ce02e3ffc82a266886 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Mon, 26 Apr 2021 15:00:48 -0500 Subject: Revert "change base???" This reverts commit 6b9335b670df03d3452a9f65f03e1884d60ac88b. --- python/MCTS.py | 9 ----- python/agent.py | 55 ---------------------------- python/dotsandboxes/dotsandboxesagent.py | 5 --- python/dotsandboxes/static/dotsandboxes.html | 12 ------ python/start.sh | 7 ---- 5 files changed, 88 deletions(-) delete mode 100644 python/agent.py (limited to 'python') diff --git a/python/MCTS.py b/python/MCTS.py index ec6e6c1..6c71ba9 100644 --- a/python/MCTS.py +++ b/python/MCTS.py @@ -1,10 +1,6 @@ import math from copy import deepcopy -<<<<<<< HEAD from time import perf_counter -======= -from time import clock ->>>>>>> f6e623d... change base??? from random import choice from GameState import GameState @@ -139,13 +135,8 @@ class MCTSGameController(GameController): self.root_node = MCTSNode(state) iterations = 0 -<<<<<<< HEAD start_time = perf_counter() while perf_counter() < start_time + time_allowed: -======= - start_time = clock() - while clock() < start_time + time_allowed: ->>>>>>> f6e623d... change base??? node = self.select() if node.pending_moves != set(): 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()) - diff --git a/python/dotsandboxes/dotsandboxesagent.py b/python/dotsandboxes/dotsandboxesagent.py index e7407bf..9fe6cb8 100644 --- a/python/dotsandboxes/dotsandboxesagent.py +++ b/python/dotsandboxes/dotsandboxesagent.py @@ -15,11 +15,6 @@ import asyncio import websockets import json from collections import defaultdict -<<<<<<< HEAD -======= -import random - ->>>>>>> f6e623d... change base??? logger = logging.getLogger(__name__) games = {} diff --git a/python/dotsandboxes/static/dotsandboxes.html b/python/dotsandboxes/static/dotsandboxes.html index d250c76..4e97508 100644 --- a/python/dotsandboxes/static/dotsandboxes.html +++ b/python/dotsandboxes/static/dotsandboxes.html @@ -2,12 +2,6 @@ -<<<<<<< HEAD -======= - - - ->>>>>>> f6e623d... change base??? Dots and Boxes @@ -48,12 +42,6 @@ -<<<<<<< HEAD -======= - ->>>>>>> f6e623d... change base??? diff --git a/python/start.sh b/python/start.sh index 26a4b70..455944d 100755 --- a/python/start.sh +++ b/python/start.sh @@ -1,4 +1,3 @@ -<<<<<<< HEAD #/bin/bash (cd dotsandboxes; python3 dotsandboxesserver.py 8080) & python3 agent.py 10001 & @@ -6,12 +5,6 @@ python3 agent.py 10002 & echo "Press enter to close all programs" read TRASH; -======= -(cd dotsandboxes; python3 dotsandboxesserver.py 8080) & -python3 agent.py 10001 & -python3 agent.py 10002 & -read -p "Press enter to close all programs." ->>>>>>> f6e623d... change base??? trap "exit" INT TERM trap "kill 0" EXIT -- cgit v1.2.3