The Foxhunting game is played on a chess board, and only uses the black squares. There are four dogs and they start at the top of the board (on squares B8, D8, F8, and H8). There is only one fox and it starts at the bottom of the table on square E1. In each round only one dog can move diagonally (to the next black square) and the fox can move one square diagonally. The dogs can only move forward, down the table, but the fox can also move backward. The goal of the dogs is to trap the fox, but the fox tries to escape the dogs. The fox has won if it gets to row 8, but the dogs win if one of them reaches the same square as the fox.
Note again that both the dogs and the fox only travel on the black squares. The white squares are not used at all in this game. Below is a rough picture of the initial position of the game:
A B C D E F G H +--+--+--+--+--+--+--+--+ 8 | |H1| |H2| |H3| |H4| 8 +--+--+--+--+--+--+--+--+ 7 |..| |..| |..| |..| | 7 +--+--+--+--+--+--+--+--+ 6 | |..| |..| |..| |..| 6 +--+--+--+--+--+--+--+--+ 5 |..| |..| |..| |..| | 5 +--+--+--+--+--+--+--+--+ 4 | |..| |..| |..| |..| 4 +--+--+--+--+--+--+--+--+ 3 |..| |..| |..| |..| | 3 +--+--+--+--+--+--+--+--+ 2 | |..| |..| |..| |..| 2 +--+--+--+--+--+--+--+--+ 1 |..| |..| |RR| |..| | 1 +--+--+--+--+--+--+--+--+ A B C D E F G H
In this first part of the project you are to implement a program that allows two users to play the game. The program will accept moves from the users (e.g. the player with the fox might start by moving to D2, but the player with the dogs might move dog 2 to E7), then check if the moves are legal, and if so, print out the new positon. The program should also be able to determine that the game is over and announce the winner.
You can only use character-base graphics, so the picture if the board will never be very fancy, but you can the picture above as a starting point.
To maintain the playing board you are to implement the class defined below:
class VeidiBord { public: // The constructor builds the board and put the dogs and fox on initial squares VeidiBord(); ~VeidiBord(); // Prints the current position to standard output void PrentaBord(); // Makes a dog-move, returns false if it is illegal bool FaeraHund( int nrHund, reitur til ); // Makes a fox-move, returns false if it is illegal bool FaeraRef( reitur til ); // Returns the position of a particular dog reitur StadaHunds( int nrHund ); // Returns the position of the fox reitur StadaRefs(); // Returns true if game is over bool LeikLokid(); // Returns true if the dogs have won bool HundarSigra(); // Returns true if the fox has won bool RefurSigrar(); private: // // Here come the hidden variables that are needed to implement the class // };The type reitur (e. square) is a pair with the values rod and dalk, defined with
struct reitur { int rod; int dalk; reitur( int r=0, int d=0 ): rod(r), dalk(d) { }; };Please note that even though columns are indicated with letters in the input and output their inner representation is with a nunber. This is often done to simplify the programming of data structures.
You can the implement the inner part of the class VeidiBord as you want, but you have to keep the interface as described above. You also have to implement a main program that accept input from the users, enters their moves, and displays the current position.