Solution
David answered on
Dec 26 2021
Our proposal is define minimax search with alpha-beta pruning and once the computer is ahead,
it can generally gain at least slight improvements to score with the extra moves occu
ing after
the obvious benefit In our opinion, the best way to gain a feel for the power (and drawbacks) of
alhpa-beta pruning and minimax search is to experience the effects of playing against it! We
allow the user to choose whether or not the computer searches to a specific depth or for a given
time limit. The depth or time can also be specified. Giving the computer more time (or a higher
depth) clearly leads to better moves and a more challenging game!
Screenshot One: Describe what is happening in this screenshot.
In this screen white win shown even before given chance to black press the button start when
we press reassign then shown white win there is need to give code when we press start then
information game is not finished start again not shown message win
Each computer turn best method is alpha-beta search. The first is to search down to a specified
depth. We consider depths of 4 or 5 to be beginner level, depths of 6 to 8 to be intermediate, and
depths of 9 or 10 to be advanced. The depth or time can also be specified.
Proposed Code for
For computer turn best move
We proposed AI algorithm that is alphabeta purning search
def alphaBetaSearch(state, alpha, beta, depth):
def maxValue(state, alpha, beta, depth):
val = -MaxUtility
for successor in state.getSuccessors():
val = max(val, alphaBetaSearch(successor, alpha, beta, depth))
if val >= beta: return val
alpha = max(alpha, val)
return val
def minValue(state, alpha, beta, depth):
val = MaxUtility
for successor in state.getSuccessors():
val = min(val, alphaBetaSearch(successor, alpha, beta, depth - 1))
if val <= alpha: return val
beta = min(beta, val)
return val
if state.isTerminalState(): return state.getTerminalUtility()
if depth <= 0 or time() - startTime > MaxAllowedTimeInSeconds: return
evaluationFunc(state)
return maxValue(state, alpha, beta, depth) if state.blackToMove == IsPlayerBlack else
minValue(state, alpha, beta, depth)
estMove = None
for depth in xrange(1, MaxDepth):
if time() - startTime > MaxAllowedTimeInSeconds:
eak
val = -MaxUtility
for successor in state.getSuccessors():
score = alphaBetaSearch(successor, -MaxUtility, MaxUtility, depth)
if score > val:
val, bestMove = score, successor.moves
return bestMove
Screenshot Two: Describe your proposed change.
In this screen when we start move then there is no check about all pieces of player have been
eliminated
Our Propose strategy we use elimination strategy. This just checks for whether or not all pieces
of a player have been eliminated. It does not check for whether a player has a move or not. In
that case, there will be no successors for that player and alpha beta search will return Min/Max
Utility.
def isTerminalState(self):
blackSeen, whiteSeen = False, False
for row in grid:
...