Computer Science 245: Data Structures and Algorithms

Network (Due 5/13/2015)

For your fourth and final project, you will create a program that allows users to play the game Network, and build a simple AI that allows users to play against each other. We will pit each of your AIs against each other to find out who can design the championship Network player.

The Game of Network

Network is a game created by Sid Sackson, in his book "A Gamut of Games". It is played on an 8x8 checkerboard, with two players. The top and bottom rows of the checkerboard are the goal regions for player 1, and the left and right regions are the goal regions for player 2. Each player has ten pieces, and tries to make a "network" across the board
Starting Chessboard

Playing the Game

Players take turns placing pices on the board, with the following restrictions: In the board below, assuming it is red's move, the spaces that are legal to play in are marked in blue
Legal Moves for Red

Winning Networks

Players are trying to create a network -- a series of 6 or more pieces that connect their goal areas. Two pieces can be connected if they are adjacent, or if they are separated only by empty spaces along a horziontal, vertical, or diagonal line. The following is a win for red:
Winning network for red
Winning networks have the following properties: Some more example winning networks: Win for red
Winning network for red
Win for black
Winning network for black
Win for red
Winning network for black

After all Pieces are Played

If all 10 pieces are played by both players without forming a winning network, then players take turns moving pieces. On each turn after all 10 pieces have been placed, a player moves one of her pieces to another location on the board, with the following restrictions:

Required Input/Output

In order to make our grading scripts work correctly on your projects, your program will need to conform to some standards. Failure to follow these standards will require extra time grading your project, and will lose you points! Gameplay proceeds as follows:

Required Archtecture

You are mostly allowed to build this program as you see fit, with two exceptions:

Computer Player

You will need to implement a computer player, which should use a min/max algorithm as described in class (preferably using alpha-beta pruning, though that is not required) and an evaluation function of your own design. You have a fair amount of leeway on what evaluation function to use -- though some ideas are: You will likely need to be able to make and unmake moves on your board to get this search to work correctly. Your are strongly encouraged to see me to get ideas, and to check if your ideas for the computer player are reasonable.

Network Tournament

We will be running a tournament running your programs against each other.

To make our lives easier, please rename your computer player as yourUsernameComputerPlayer (so mine would be gallesComputerPlayer), and rename all of the classes needed by your computer player (a board class, for instance) by prepending your username (so I would name my board class gallesBoard, for instance)

Note that the "correct" way to do this is with java packages, but this is the eaisest last-minute stopgap solution, since we are so close to the due date.

Program Requirements

Supporting Files

Sample Output

Enter the number of human players (0, 1 or 2): 2
  1 2 3 4 5 6 7 8 
A:. . . . . . . . 
B:. . . . . . . . 
C:. . . . . . . . 
D:. . . . . . . . 
E:. . . . . . . . 
F:. . . . . . . . 
G:. . . . . . . . 
H:. . . . . . . . 
Player 1: Enter row and colum position to place piece:A 4
  1 2 3 4 5 6 7 8 
A:. . . 1 . . . . 
B:. . . . . . . . 
C:. . . . . . . . 
D:. . . . . . . . 
E:. . . . . . . . 
F:. . . . . . . . 
G:. . . . . . . . 
H:. . . . . . . . 
Player 2: Enter row and colum position to place piece:D 3
  1 2 3 4 5 6 7 8 
A:. . . 1 . . . . 
B:. . . . . . . . 
C:. . . . . . . . 
D:. . 2 . . . . . 
E:. . . . . . . . 
F:. . . . . . . . 
G:. . . . . . . . 
H:. . . . . . . . 
Player 1: Enter row and colum position to place piece:B 5
  1 2 3 4 5 6 7 8 
A:. . . 1 . . . . 
B:. . . . 1 . . . 
C:. . . . . . . . 
D:. . 2 . . . . . 
E:. . . . . . . . 
F:. . . . . . . . 
G:. . . . . . . . 
H:. . . . . . . . 
Player 2: Enter row and colum position to place piece:D 1
  1 2 3 4 5 6 7 8 
A:. . . 1 . . . . 
B:. . . . 1 . . . 
C:. . . . . . . . 
D:2 . 2 . . . . . 
E:. . . . . . . . 
F:. . . . . . . . 
G:. . . . . . . . 
H:. . . . . . . . 
Player 1: Enter row and colum position to place piece:A 6
Player 1: Bad move!  
Position would form clump
Player 1: Enter row and column to place piece:B 7
  1 2 3 4 5 6 7 8 
A:. . . 1 . . . . 
B:. . . . 1 . 1 . 
C:. . . . . . . . 
D:2 . 2 . . . . . 
E:. . . . . . . . 
F:. . . . . . . . 
G:. . . . . . . . 
H:. . . . . . . . 
Player 2: Enter row and colum position to place piece:B 1
  1 2 3 4 5 6 7 8 
A:. . . 1 . . . . 
B:2 . . . 1 . 1 . 
C:. . . . . . . . 
D:2 . 2 . . . . . 
E:. . . . . . . . 
F:. . . . . . . . 
G:. . . . . . . . 
H:. . . . . . . . 
Player 1: Enter row and colum position to place piece:G 2
  1 2 3 4 5 6 7 8 
A:. . . 1 . . . . 
B:2 . . . 1 . 1 . 
C:. . . . . . . . 
D:2 . 2 . . . . . 
E:. . . . . . . . 
F:. . . . . . . . 
G:. 1 . . . . . . 
H:. . . . . . . . 
Player 2: Enter row and colum position to place piece:A 3
Player 2: Bad move!  
Position in opponent goal
Player 2: Enter row and column to place piece:B 4
  1 2 3 4 5 6 7 8 
A:. . . 1 . . . . 
B:2 . . 2 1 . 1 . 
C:. . . . . . . . 
D:2 . 2 . . . . . 
E:. . . . . . . . 
F:. . . . . . . . 
G:. 1 . . . . . . 
H:. . . . . . . . 
Player 1: Enter row and colum position to place piece:D 2
  1 2 3 4 5 6 7 8 
A:. . . 1 . . . . 
B:2 . . 2 1 . 1 . 
C:. . . . . . . . 
D:2 1 2 . . . . . 
E:. . . . . . . . 
F:. . . . . . . . 
G:. 1 . . . . . . 
H:. . . . . . . . 
Player 2: Enter row and colum position to place piece:E 8
  1 2 3 4 5 6 7 8 
A:. . . 1 . . . . 
B:2 . . 2 1 . 1 . 
C:. . . . . . . . 
D:2 1 2 . . . . . 
E:. . . . . . . 2 
F:. . . . . . . . 
G:. 1 . . . . . . 
H:. . . . . . . . 
Player 1: Enter row and colum position to place piece:H 6
  1 2 3 4 5 6 7 8 
A:. . . 1 . . . . 
B:2 . . 2 1 . 1 . 
C:. . . . . . . . 
D:2 1 2 . . . . . 
E:. . . . . . . 2 
F:. . . . . . . . 
G:. 1 . . . . . . 
H:. . . . . 1 . . 
Player 1 wins! A4 B5 B7 G2 D2 H6