Question: Problem 2 . ( 2 0 points ) For problem 2 , you will put answers in your writeup for a . Also make alterations

Problem 2.(20points)
For problem 2,you will put answers in your writeup for a.Also make alterations to the given python module.
a.Find the definition for Gomoku (5-in-a-row)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 2b,run 8games of a random agent versus an alpha-beta-cutoff agent using your evaluation function, with each agent playing 4times as X and 4times as O.Choose a depth cutoff that will allow each game to complete in under 20seconds. 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 (4,4).(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 O.This is fine.)
ps3.py
sys.path.append('aima-python')
from games import *
import math
def c4_silly_eval(state):
'''Example of a silly evaluation function:
Each X piece is worth points based on its column number (1through 6)
Each O piece is worth points based in its -column number
'''
ev =0
for col in range(1,7):
for row in range(1,8):
if state.board.get((row,col))=='X':
ev +=(col *0.01)
elif state.board.get((row,col))=='0':
ev -=(col *0.01)
return ev
def c4_good_eval(state):
'''Write your answer to 1c in this function!
'''
return 0
def ab_cutoff_player(game,state):
return alpha_beta_cutoff_search(state,game, d=2,eval_fn=c4_silly_eval)
class PS3:
def init(self):
pass
def problem_1a(self):
tt =TicTacToe()
tt.play_game(alpha_beta_player,query_player)
def problem_1b(self):
c4=ConnectFour()
c4.play_game(ab_cutoff_player, query_player)
def problem_1c(self):
write your code for problem 1c here
return 0,0
def problem_1d(self):
write your code for problem 1d here
return 0,0
def problem_2b(self):
write your code for problem 2d here
return 0,0
def main():
ps3=PS3()
An example for you to follow to get you started on Games
print('Example Problem, playing Tic Tac Toe:')
print('=====================================')
ps3.problem_1a()
print('Example Problem, playing Connect 4against my silly eval:')
print('========================================================')
uncomment to get it to run problem2
#ps3.problem_1b()
if name =='main':
main()
amia-python/games.py
class Gomoku(TicTacToe):
"""Also known as Five in a row."""
def init(self,h=15,v=16,k=5):
TicTacToe.init(self,h,v,k)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!