## ## *** REPLACE WITH YOUR CUSTOMIZED COMMENT BLOCK *** ## ## altNim implementation functions for Assigment #2. ## ## *** ONLY ADD REQUESTED CODE *** ## ## DO NOT: ## * MODIFY THE LONE IMPORT STATEMENT ## * ADD OTHER IMPORT STATEMENTS (THIS INCLUDES IMPORT ## STATEMENTS ADDED AUTOMATICALLY BY IDES SUCH AS PYCHARM); ## * ADD, MODIFY, OR REMOVE FUNCTION DEFINITIONS OR MODIFY GIVEN ## COMMENTS ASSOCIATED WITH THOSE FUNCTIONS; ## * ADD NEW CLASS DEFINITIONS OR GLOBAL VARIABLES (USE THE ## PROVIDED CLASSES IN FILE MYSEARCHCLASSES.PY) ## * ACCESS ANY PROVIDED CLASS ATRIBUTES DIRECTLY (USE ## PROVIDED ATTRIBUTE ACCESS FUNCTIONS IN THE FILE ## MYSEARCHCLASSES.PY) ## ## from myAltNimClasses import * ## Function returns True if state STATE is a leaf in the altNim game tree ## and False otherwise. def isLeaf(state): ## *** ADD REQUESTED CODE *** ## Function returns the value associated with state STATE in the altNim ## game tree. If state values indicate that the max player has won or ## lost, return 1000 or -1000 respectively (see hints in the assignment ## description); otherwise, return ## the nuumber of matchsticks ## remaining; def eval(state, isMax): ## *** ADD REQUESTED CODE *** ## Function returns a list of the game tree children of state STATE. ## As such, it is analogous to function Expand called by the basic # search algorithms given in course lecture #4. def getChildren(state): ## *** ADD REQUESTED CODE *** ## Function performs a recursive MiniMax search of the altNim game ## tree. As such, it implements recursive algorithm MiniMax in # course lecture #9 modified to store the action resulting in ## the best MiniMax value for the max player in the root node of ## the altNim game tree (see the final MiniMax + Alphabeta algorithm ## given in the course lecture #9 notes for this modification). def MiniMax(state, depth, isMax): ## *** ADD REQUESTED CODE ***