Solved–Lab 5– Solution

$30.00 $19.00

The exercises below will have you explore and improve Python programs of a simple 3×3 tic-tac-toe game. Start by obtain a copies of a tic-tac-toe game program in Python, tictactoe_basic.py Exercise 1: Load module tictactoe_basic.py and run the program as follows: mygame = T3() mygame.play() Play a few rounds. How do you fair? You should…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

5/5 – (2 votes)

The exercises below will have you explore and improve Python programs of a simple 3×3 tic-tac-toe game. Start by obtain a copies of a tic-tac-toe game program in Python, tictactoe_basic.py

Exercise 1: Load module tictactoe_basic.py and run the program as follows:

  • mygame = T3()

  • mygame.play()

Play a few rounds. How do you fair? You should be winning …. You should find that the program presents

little challenge and that your chances at winning games are excellent. Study the code so that you understand what make this game so easy to beat.

Exercise 2: Make a copy of tictactoe_basic.py and call it tictactoe_lab5.py. In this second file, you will make changes and additions that will render the game a bit more challenging. You can make the game more challenging without going as far as implementing the minimax game strategy. Based on your understanding of the game, and your experience with playing the basic game, think of any way in which you can give more smarts to the game program.

Exercise 3: If time permits …

  • continue by making a copy of tictactoe_lab5.py and call tictactoe_minimax.py. In the new file, make changes and additions that will have the game program apply minimax to beat you. Note: If the human player starts, then the human player is the “mini-maxer” and the game program is actually applying “maximin” which is the equivalent reverse strategy.

Here is what the program will do before making any next move: (1) determine all possible moves that the program can make at this time; (2) for each move in (1) determine all possible responses by the human player; (3) label all possible human moves with the computed evaluation function value (all possible rows, cols, diags for human X – all possible rows, cols, diags for game O); (4) for each game move, compute the maximum evaluation for all human moves under this game move; label each game move with the computed maximum value; (5) the best next move for the program will be the move with the smallest label.

To receive credit:

Nothing to be handed in. During the lab, keep smiling (and working). Make sure you sign your name on the signup sheet. Get mentally prepared for a related next homework assignment.