Question: Problem 2 . ( 2 0 points ) For problem 2 , you will put answers in your writeup for a . Also make alterations
Problem points
For problem you will put answers in your writeup for aAlso make alterations to the given python module.
aFind the definition for Gomoku inarowin the aima code. Build an evaluation function for gomoku. In your writeup, briefly explain what your evaluation function is doing.
bIn the function problem brun games of a random agent versus an alphabetacutoff agent using your evaluation function, with each agent playing times as X and times as OChoose a depth cutoff that will allow each game to complete in under seconds Have the function return a tuple nxnowhere nx is the number of games that your agent wins as Xand no is the number of games that your agent wins as OSo if your agent wins every single game, it will return Note: As mentioned above, it may help to write a version of your eval function to evaluate as Xand another version of your eval function to evaluate as OThis is fine.
pspy
syspath.appendaimapython'
from games import
import math
def csillyevalstate:
Example of a silly evaluation function:
Each X piece is worth points based on its column number through
Each O piece is worth points based in its column number
ev
for col in range:
for row in range:
if state.board.getrowcolX:
ev col
elif state.board.getrowcol:
ev col
return ev
def cgoodevalstate:
Write your answer to c in this function!
return
def abcutoffplayergamestate:
return alphabetacutoffsearchstategame devalfncsillyeval
class PS:
def initself:
pass
def problemaself:
tt TicTacToe
ttplaygamealphabetaplayer,queryplayer
def problembself:
cConnectFour
cplaygameabcutoffplayer, queryplayer
def problemcself:
write your code for problem c here
return
def problemdself:
write your code for problem d here
return
def problembself:
write your code for problem d here
return
def main:
psPS
An example for you to follow to get you started on Games
printExample Problem, playing Tic Tac Toe:
print
psproblema
printExample Problem, playing Connect against my silly eval:
print
uncomment to get it to run problem
#psproblemb
if name main:
main
amiapythongamespy
class GomokuTicTacToe:
Also known as Five in a row."""
def initselfhvk:
TicTacToe.initselfhvk
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
