CS 109_Fall2016-HW4

# CS 109_Fall2016-HW4 - CS 109 Introduction to Computer...

• Homework Help
• 11
• 62% (13) 8 out of 13 people found this document helpful

This preview shows pages 1–4. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

Question 1: Minimax and game trees [10 points] One way to program a computer to play a game against an opponent is to use the Minimax algorithm. In this question, we will first work through a helpful example using the algorithm, and then ask you to apply it to the game of Tic-Tac-Toe. Each state of the board in a game is given a score, with high score states assumed to be ‘good’ for the computer, and low score states ‘good’ for the opponent. When it is the computer’s turn to play, it picks the move that leads to a board state with the highest score. When it is the opponent’s turn to play, we assume that the opponent picks its best move (i.e. that leads to a board state with the lowest score). Assume the leaves of the following tree represent outcomes of the game. Assume it is the computer’s turn to make a move in board state a . Let’s use Minimax to determine the score of the current position and choose whether to make a move leading to state b or c. Working backwards, we first compute the scores for the game-ending board states d , e , f , and g . Since it is the computer’s turn in state a , states b and c are the opponent’s turn, and it will be the computer’s turn in d , e , f , and g . In each case, the computer has two choices. For example, in state d , the computer can choose a move that leads to a state with score 20 (good for the computer) or a move that leads to a state with score -10 (bad for the computer). According to the Minimax algorithm, the computer should choose the move that leads to a “max” score state, i.e. score 20. This is shown below.
Similarly, the computer would choose the move that maximizes the score in states e, f, g. These three are shown filled in below.

This preview has intentionally blurred sections. Sign up to view the full version.

This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern