CS 111- Introduction to Computer Science
Homework #14


Due: Friday 5/5 at the beginning of class

Hex (Part 2)

1. Implement HexGame: Implement a class HexGame.java according to this specificationHexGame is just a text-based interface that makes use of our HexState.java model as much as possible to implement play.  This sample input should produce the sample transcript below (input underlined):

THE GAME OF HEX
Each turn, a player places a piece in an empty position using
algebraic notation (e.g. "b4").  The first player seeks to
connect the bottom row to the top row with a path of "*" pieces.
The second player seeks to connect the leftmost column to
the rightmost column with a path of "O" pieces.  The command
"undo" will undo the previous move.
Board size? 5

 5 - - - - -
  4 - - - - -
   3 - - - - -
    2 - - - - -
     1 - - - - -
        a b c d e
* to play.

Position? undo
Cannot undo.

 5 - - - - -
  4 - - - - -
   3 - - - - -
    2 - - - - -
     1 - - - - -
        a b c d e
* to play.

Position? bad-input
Invalid input.

 5 - - - - -
  4 - - - - -
   3 - - - - -
    2 - - - - -
     1 - - - - -
        a b c d e
* to play.

Position? c3

 5 - - - - -
  4 - - - - -
   3 - - * - -
    2 - - - - -
     1 - - - - -
        a b c d e
O to play.

Position? c3
Illegal play.

 5 - - - - -
  4 - - - - -
   3 - - * - -
    2 - - - - -
     1 - - - - -
        a b c d e
O to play.

Position? a0
Illegal play.

 5 - - - - -
  4 - - - - -
   3 - - * - -
    2 - - - - -
     1 - - - - -
        a b c d e
O to play.

Position? a42
Illegal play.

 5 - - - - -
  4 - - - - -
   3 - - * - -
    2 - - - - -
     1 - - - - -
        a b c d e
O to play.

Position? b2

 5 - - - - -
  4 - - - - -
   3 - - * - -
    2 - O - - -
     1 - - - - -
        a b c d e
* to play.

Position? c2

 5 - - - - -
  4 - - - - -
   3 - - * - -
    2 - O * - -
     1 - - - - -
        a b c d e
O to play.

Position? c4

 5 - - - - -
  4 - - O - -
   3 - - * - -
    2 - O * - -
     1 - - - - -
        a b c d e
* to play.

Position? b1

 5 - - - - -
  4 - - O - -
   3 - - * - -
    2 - O * - -
     1 - * - - -
        a b c d e
O to play.

Position? d4

 5 - - - - -
  4 - - O O -
   3 - - * - -
    2 - O * - -
     1 - * - - -
        a b c d e
* to play.

Position? a3

 5 - - - - -
  4 - - O O -
   3 * - * - -
    2 - O * - -
     1 - * - - -
        a b c d e
O to play.

Position? b5

 5 - O - - -
  4 - - O O -
   3 * - * - -
    2 - O * - -
     1 - * - - -
        a b c d e
* to play.

Position? a4

 5 - O - - -
  4 * - O O -
   3 * - * - -
    2 - O * - -
     1 - * - - -
        a b c d e
O to play.

Position? a5

 5 O O - - -
  4 * - O O -
   3 * - * - -
    2 - O * - -
     1 - * - - -
        a b c d e
* to play.

Position? b4

 5 O O - - -
  4 * * O O -
   3 * - * - -
    2 - O * - -
     1 - * - - -
        a b c d e
O to play.

Position? c5

 5 O O O - -
  4 * * O O -
   3 * - * - -
    2 - O * - -
     1 - * - - -
        a b c d e
* to play.

Position? e4

 5 O O O - -
  4 * * O O *
   3 * - * - -
    2 - O * - -
     1 - * - - -
        a b c d e
O to play.

Position? undo

 5 O O O - -
  4 * * O O -
   3 * - * - -
    2 - O * - -
     1 - * - - -
        a b c d e
* to play.

Position? undo

 5 O O - - -
  4 * * O O -
   3 * - * - -
    2 - O * - -
     1 - * - - -
        a b c d e
O to play.

Position? undo

 5 O O - - -
  4 * - O O -
   3 * - * - -
    2 - O * - -
     1 - * - - -
        a b c d e
* to play.

Position? undo

 5 - O - - -
  4 * - O O -
   3 * - * - -
    2 - O * - -
     1 - * - - -
        a b c d e
O to play.

Position? undo

 5 - O - - -
  4 - - O O -
   3 * - * - -
    2 - O * - -
     1 - * - - -
        a b c d e
* to play.

Position? undo

 5 - - - - -
  4 - - O O -
   3 * - * - -
    2 - O * - -
     1 - * - - -
        a b c d e
O to play.

Position? undo

 5 - - - - -
  4 - - O O -
   3 - - * - -
    2 - O * - -
     1 - * - - -
        a b c d e
* to play.

Position? undo

 5 - - - - -
  4 - - O - -
   3 - - * - -
    2 - O * - -
     1 - * - - -
        a b c d e
O to play.

Position? undo

 5 - - - - -
  4 - - O - -
   3 - - * - -
    2 - O * - -
     1 - - - - -
        a b c d e
* to play.

Position? d4

 5 - - - - -
  4 - - O * -
   3 - - * - -
    2 - O * - -
     1 - - - - -
        a b c d e
O to play.

Position? d5

 5 - - - O -
  4 - - O * -
   3 - - * - -
    2 - O * - -
     1 - - - - -
        a b c d e
* to play.

Position? e5

 5 - - - O *
  4 - - O * -
   3 - - * - -
    2 - O * - -
     1 - - - - -
        a b c d e
O to play.

Position? c1

 5 - - - O *
  4 - - O * -
   3 - - * - -
    2 - O * - -
     1 - - O - -
        a b c d e
* to play.

Position? b1

 5 - - - O *
  4 - - O * -
   3 - - * - -
    2 - O * - -
     1 - * O - -
        a b c d e
* wins.