Question: complete the coding portions for 1 c , 1 d , 2 a , and 2 b . you may need to download or lookup
complete the coding portions for cda and b you may need to download or lookup the games.py or agents.py in amiapython code.
Problem points
For problem you will put answers in your writeup for a c Also make alterations to the given python module.
a Run the pspy code. You will be prompted to play tictactoe against a minimax agent. Common wisdom suggests that the best first move is the center square. The agent doesnt begin by playing in the center square. Why do you think the agent plays where it does instead of the center? Give an explanation sentences in your writeup.
b Alter the pspy codes main function so that it calls problem b instead of problem a You will be prompted to play connect against an alphabeta with cutoff agent that is using a silly evaluation function. See if you can defeat the agent in a few games. Describe sentences what your plan to defeat it every time. Explain briefly sentences why your plan works.
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
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
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
