University of California, Berkeley
EECS Department - Computer Science Division

CS3 Lecture 17 : Final Project Overview and Game Theory Tutorial


Overview of today's lecture


Review

We took an exam together

Notes for 2001-10-29 lecture


Final Project : Shall we play a game?

Introduction

Overview

Solving a game

Huh? Can you give me an example?

1,2,...,4

A position

A value

Winning positions
(and winning moves)

Losing positions
(and losing moves)

Tieing positions
(and tieing moves)

A winning position is one in which there is at least one winning move, yielding a losing position (for the opponent)

 A losing position is one in which every move is a losing move, yielding a winning position for the opponent

 A tieing position is one in which there does not exist a winning move, but there does exist a tie move.

Five games to play and consider

 1,2,...,10 Tic-Tac-Toe TacTix Kayles Toads and Frogs Snake Poison

Standard pre-game setup when you're playing on paper

 Choose whether you want to end the game at 10 or at some other number.

none

Choose initial board (full 3x3 or smaller, perhaps)

Choose how many sticks you wish to use

Choose how big the board is, where (and how many) toads and frogs should go in, and who should start

Choose where to start the snake

Choose what each Chess piece each player will simulate, where they'll start and who will start.

Board to start with (ALWAYS start with this setup or is this an EXAMPLE?)

 0

ALWAYS

- - -
- - -
- - -

ALWAYS

o o o
o o o
o o o

EXAMPLE

||||||||

EXAMPLE

RR----LL

[L to move]

EXAMPLE

h . .
. . .
. . .

EXAMPLE

. . R
. . .
. L .

[L=rook,R=knight]
[L to move]

EXAMPLE

On your move, you...

 Add 1 or 2 to the pile.

Place your piece on a vacant slot. (Left plays X, Right O)

 Remove as many pieces you wish from any row or column as long as they are contiguous (no gaps between).

 Remove one or two ADJACENT sticks.

Take your piece and either move it one spot in the direction it moves into a vacant spot (L moves L, R moves R) OR jump in that direction over one opponent piece landing in a blank slot.

Choose either the head or tail of the snake (initially on the same spot) and move to a new adjacent unoccupied blank slot horizontally or vertically

 Move your piece (L or R) to a new slot according to the way it moves (like a chess piece of your choosing). The slot you just occupied gets "poisoned" and cannot be landed on again, nor can it be passed over (except by a knight, which can jump over them).

To win

 First to bring the total of the pile to 10

 First to get three-in-a-row, either horizontally, vertically or diagonally.

A tie is possible if the board is filled with nobody achieving three-in-a-row.

Make the last move.

Remove the last piece(s) from the board. I.e., the board is empty after you move.

 Make the last move.

Take the last stick(s).

Make the last move.

I.e., your opponent, on their turn, has no moves. 

 Make the last move.

Force your opponent to make the snake bite itself or run off the board.

 Make the last move.

Your opponent will have nowhere to move to.

Misere rules 

 First to 10 LOSES

Fiirst to three-in-a-row LOSES. 

Making the last move LOSES. 

 Making the last move LOSES. 

Making the last move LOSES. 

Making the last move LOSES. 

Making the last move LOSES. 

Sample board mid-game

 8

x o x
- o -
o x -

[player to move can be calculated by number of pieces. L=x always starts]

o o -
- o -
o o o

||----|-||

-RL-R--L

[R to move]

. h o
. . o
t o o

. . x
R . .
. x L

[L=rook,R=knight]

[player to move can be calculated by number of poisoned slots. L=x always starts, so when an even # have been poisoned, as above, it's L's turn]

Position representation

and

example of the "Sample board mid-game" above 

 Number

8

9-word sentence of what piece is in each slot from 1 through 9. (Whose turn is determined by the number of pieces on the board so far; even=x, odd=o)

(x o x - o - o x -)

1 2 3 | x o x
4 5 6 | - o -
7 8 9 | o x -

9-word sentence of o or - to represent what is in each slot from 1 through 9

(o o - - o - o o o) 

1 2 3 | o o -
4 5 6 | - o -
7 8 9 | o o o

Arbitrarily-long sentence of i or _ to represent where the sticks are

(i i _ _ _ _ i _ i i)

||----|-||

Arbitrarily-long sentence whose first word is left-turn or right-turn to represent whose turn it is. The rest of the sentence contains l, r or - to represent where the pieces are.

(right-turn - r l - r - - l)

-RL-R--L
[R to move]

11-word sentence. First two are the locations of the snake head and tail, respectively. The remaining slots are o or - to represent where the snake is (including the head and tail)

(2 7 - o o - - o o o o) 

1 2 3 | . h o
4 5 6 | . . o
7 8 9 | t o o

11-word sentence. First is the location of left, second is the location of right. The remaining slots are x or - to represent the poisoned slots. (Whose turn is determined by the number of poisoned slots; even=L, odd=R)

(1 8 - - x - - - - x -) 

1 2 3 | . . x
4 5 6 | R . .
7 8 9 | . x L

[L=rook,R=knight]

Move representation

and

example moves for "Sample board mid-game" above

 

 Number

1 or 2

A slot number (1-9) representing the slot to move into

(we know it's x's move since there are an even number of pieces on the board)

4, 6 or 9

A sentence of slots representing pieces to remove

(1), (2), (5), (7), (8), (9), (1 2), (2 5), (5 8), (7 8), (8 9), (2 5 8) or (7 8 9)

A sentence of sticks to remove

(1), (2), (7), (9), (10), (1 2) or (9 10)

A two-word sentence, the first is the slot to move FROM and the second is the slot to move TO

(since it's right's turn)

(2 4) or (5 6)

A two-word sentence, the first is the letter h or t (signifying the head or tail to move) and the second is the slot to move TO

(h 1), (h 5) or (t 4)

A single number representing the TO slot for the piece to move into.

(we know it's L's turn since L goes first and there are an even number of poisoned slots)

6

(L cannot move to 7 because only knights can jump over poisoned slots; the others can't)

Example primitive position for default standard (not misére) game and value primitive should return

 

10

lose

(x o x - o - - o x)

1 2 3 | x o x
4 5 6 | - o -
7 8 9 | - o x

lose

(- - - - - - - - -) 

1 2 3 | - - -
4 5 6 | - - -
7 8 9 | - - -

lose

(_ _ _ _ _ _ _ _ _ _)

----------

lose

(left-turn l - - r r l - -)

L--RRL--
[L to move]

lose

(1 5 o o o o o o o o o) 

1 2 3 | h o o
4 5 6 | o t o
7 8 9 | o o o

lose

(1 8 - - x - - - - x x) 

1 2 3 | . . x
4 5 6 | R . L
7 8 9 | . x x

[L=rook,R=knight]
(we know it's R's move)

lose

Compulsory rules

"Allow users to..."

 -

-

Enter an arbitrary initial position (which of the 3x3 are filled with pieces)

&

Remove pieces from any row or column even if they aren't contiguous

Enter an arbitrary initial position (variable size board and which pins are up)

&

Define maximum number m of adjacent sticks to remove in a row. User then is able to remove between 1 and m adjacent sticks in a row.

Enter an arbitrary initial position (variable size board and placement of Ls and Rs)

&

Choose whether the frogs and toads can jump over their own pieces also. (In standard rules they can only jump over opponents)

Enter an arbitrary initial position (location of snake head/tail slot on 3x3 board)

&

Choose whether the players control both heads or if the players only control a particular head. That is, L would always move first and only control the head; R would control the tail. You now have to know whose turn it is -- count the snake segments for that (odd=Left's turn).

Enter an arbitrary initial position (placement of L and R on 3x3 board)

&

Specify the movements of pieces based on one of five chess pieces: (Queen, King, Rook, Knight, Bishop)
You will be given these games as examples You need to choose which one of these games most interests you for your final project.

Summary

Next Time