Stacks, recursion, and games

Due: 26 Sep 2012 (The deadline for part 2 alone is extended to 1 Oct)

Note: This project has two parts. The first part is an individual assignment. In the second part, you may work in a group if you wish to.

Part 1 (80 %)

Educational objectives:

Statement of work: (i) Implement a generic Vector class and adapt it to create a stack class, and (ii) evaluate a recursive function given below.

Deliverables:

Requirements:

Sample executable: A sample executable is available at ~cop4530/fall12/solutions/proj2/recurse on linprog. The first person to find errors in our program will get a bonus point!

Notes:

  1. You should not use STL containers, other than the string class. Please get my written permission before using any other STL feature.
  2. You will need to pass certain components of this assignment to pass this course.

Part 2 (20 %)

Educational objectives:

Statement of work: Write a program to play tic-tac-toe. Your program should accept moves from a human, and should make good moves in its turn, in trying to win the game.

Background: Tic-tac-toe is normally played with a 3x3 array. This can be generalized to bigger arrays. All cells in the array are initially unmarked. Two players take turns marking previously unmarked cells, with the first player making an X mark and the second player making a 0 mark. The game ends if (i) either player wins, or (ii) the game is tied, because neither player wins. A player wins if he has a specified number of consecutive marks along a line. These consecutive marks can either be along a horizontal line, a vertical line, or a diagonal. A diagonal is as explained below. Let the cells be numbered so that the bottom left cell is denoted by (1,1) and the top right by (n,n) in an n x n array. A diagonal going North-East will have cell (i+1,j+1) adjacent to cell (i,j), while a cell going North-West will has cell (i-1,j+1) adjacent to cell (i,j). http://boulter.com/ttt/ has an example of a tic-tac-toe game. They permit an array that has a height different from its width. But we will require the height and the width to be equal. You should evaluate game trees with recursion to try to win the game.

Deliverables:

Notes:

  1. You can get up to 10 bonus points if your code wins a tic-tac-toe tournament that we will organize, competing against other tic-tac-toe programs.
  2. You will be graded on your user interface too.
  3. You may use any STL feature for this part of the assignment.
  4. You must use a game tree for at least a few levels of recursion, after which you may use some intelligent strategy to evaluate a position.
  5. You may form groups of up to 4 students each if you wish to. In this case, please email me the names of all group members by Sep 15, with a cc to each group member, and also include the names of the group members in the log file.
  6. The size of the problem will be at most 10 x 10.

Last modified: 14 Sep 2012