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 1c,1d,2a, and 2b. do not do 1a or 1b or worry about the short answer parts. Just input the right code for the ps3.py file
Problem 1.(30 points)
For problem 1, you will put answers in your writeup for a - c. Also make alterations to the given python module.
c. In the function c4 good eval, write a new evaluation function. Using this function, write code in problem 1c that will play an alpha-beta agent with depth cutoff 4 using your evaluation function against a random agent. Play once as X and once as O.(Note: For this problem and also 1(d) and also 2(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 (1,1).
Describe (2-3 sentences) your evaluation function in your writeup and explain (2-3 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 1d, run 8 games of an alpha-beta-cutoff agent using my evaluation function versus an alpha-beta-cutoff agent using your evaluation function, with each agent playing 4 times as X and 4 times as O. Run four of games at depth limit 2 for both agents, then four games at depth limit 3 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 8 games, you return (4,4).
Problem 2.(20 points)
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 8 games of a random agent versus an alpha-beta-cutoff agent using your evaluation function, with each agent playing 4 times as X and 4 times as O. Choose a depth cutoff that will allow each game to complete in under 20 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 (4,4).(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.)
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 (1 through 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 4 against 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!