from othello import * class MyPlayer(othello_player): # This will be called once at the beginning of the game, after # a few random moves have been made. Boardstate is the initial # boardstate for the game, totalTime is the total amount of time # (in seconds) in the range 60-1800 that your player will get for # the game. For our tournament, I will generally set this to 300. # color is one of Black or White (which are just constants defined # in the othello.py file) saying what color the player will be # playing. def initialize(self, boardstate, totalTime, color): print("Initializing", self.name) self.mycolor = color pass; # This should return the utility of the given boardstate. # It can access (but not modify) the to_move and _board fields. def calculate_utility(self, boardstate): return self.mycount_difference(boardstate) def alphabeta_parameters(self, boardstate, remainingTime): # This should return a tuple of (cutoffDepth, cutoffTest, evalFn) # where any (or all) of the values can be None, in which case the # default values are used: # cutoffDepth default is 4 # cutoffTest default is None, which just uses cutoffDepth to # determine whether to cutoff search # evalFn default is None, which uses your boardstate_utility_fn # to evaluate the utility of board states. return (4, None, None) def mycount_difference(self,boardstate): return (boardstate._board.count(self.mycolor) - boardstate._board.count(opponent(self.mycolor))) def count_difference(boardstate): return (boardstate._board.count(boardstate.to_move) - boardstate._board.count(opponent(boardstate.to_move))) ## To start a graphical game type: ## start_graphical_othello_game(othello_player("Bob"), othello_player("Fred")) ## where othello_player can be replaced by MyPlayer or whatever you choose to ## call your class. ## To start a textual game (where you can have different AI players) type: ## play_othello() will just start a default game, ## play_othello(Othello(), 1800, MyPlayer("Name"), othello_player("Othername")) ## where MyPlayer is your class (which can have whatever name you want) ## and othello_player is just the dumb default. You can have BobPlayer play ## FredPlayer if you define those two classes, for example.