multiagent systems self xo self +[sel]for sel in self availablereturn self allchildren def isleaf(self)""" leaf has no numbers available or is win for one of the players we only need to check for win for if it is currently ' turnand only check for win for if it is ' turn (otherwise it would have been win earlier""return (self available =[or (sum_to_ (self last_move,self oif self xmove else sum_to_ (self last_move,self )) def evaluate(self)if self xmove and sum_to_ (self last_move,self )return - elif not self xmove and sum_to_ (self last_move,self )return elsereturn def sum_to_ (last,selected)"""is true if lasttoegether with two other elements of selected sum to ""return any(last+ + = for in selected if !last for in selected if !last and !aminimax and - pruning this is naive depth-first minimax algorithmmasminimax py -minimax search with alpha-beta pruning def minimax(node,depth)"""returns the value of nodeand best path for the agents ""if node isleaf()return node evaluate(),none elif node ismaxmax_score float("-inf"max_path none for in node children()score,path minimax( ,depth+ if score max_scoremax_score score max_path name,path version june