Question: complete the coding aspects of these questions from 1 c , 1 d , 2 a , and 2 b . do not do 1
complete the coding aspects of these questions from cda and b do not do a or b or worry about the short answer parts. Just input the right code for the pspy file
Problem points
For problem you will put answers in your writeup for a c Also make alterations to the given python module.
c In the function c good eval, write a new evaluation function. Using this function, write code in problem c that will play an alphabeta agent with depth cutoff using your evaluation function against a random agent. Play once as X and once as ONote: For this problem and also d and also b it may help to write a version of your eval function to evaluate as X and another version of your eval function to evaluate as O This is fine. Have the function return a tuple nx no where nx is the number of games that your agent wins as X and no is the number of games that your agent wins as O So if you win both games, you return
Describe sentences your evaluation function in your writeup and explain sentences why you think it should do well. If your agent doesnt usually win against a random agent, then you probably did something wrong.
d In the function problem d run games of an alphabetacutoff agent using my evaluation function versus an alphabetacutoff agent using your evaluation function, with each agent playing times as X and times as O Run four of games at depth limit for both agents, then four games at depth limit for both agents. Return a tuple nx no where nx is the number of games that your agent wins as X and no is the number of games that your agent wins as O So if you win all games, you return
Problem points
For problem you will put answers in your writeup for a Also make alterations to the given python module.
a Find the definition for Gomoku inarow in the aima code. Build an evaluation function for gomoku. In your writeup, briefly explain what your evaluation function is doing.
b In the function problem b run games of a random agent versus an alphabetacutoff agent using your evaluation function, with each agent playing times as X and times as O Choose a depth cutoff that will allow each game to complete in under seconds. Have the function return a tuple nx no where nx is the number of games that your agent wins as X and no is the number of games that your agent wins as O So 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 X and another version of your eval function to evaluate as O This 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.getrow col:
ev col
return ev
def cgoodevalstate:
Write your answer to c in this function!
return
def abcutoffplayergame state:
return alphabetacutoffsearchstate game, d evalfncsillyeval
class PS:
def initself:
pass
def problemaself:
tt TicTacToe
ttplaygamealphabetaplayer,queryplayer
def problembself:
c ConnectFour
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:
ps PS
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 initself h v k:
TicTacToe.initself h v k
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
