Hey That’s My Fish Game in C Language

Project Profile
The goal of this project is to implement the game Hey, thats my Fish! using the C programming language. The game will be interactive and played between a human user and an AI (artificial intelligence). The focus of this project is primarily on exercising an introductory understanding of the C programming language including basic data types, looping and conditional constructs, arrays, iteration, basic I/O, formatted output, and functions.  This semester, all projects are individual work (not done in groups), unlike the challenges and labs!
Hey, thats my Fish
Traditionally, Hey that my Fish! game is a 2-4 player game in which the players first choose a color of penguins and then take turns moving one of his/her penguins in a straight line as far as he/she wishes, as long as there is a continuous line of vacant hexagons between the penguin’s starting and destination hexagons. The hexagons has 1-3 points and will be collected when players penguin move out from it. The objective of the game is to collect the most points in the game to win. Please see the Wikipedia entry for more details. In your implementation you will use P (for Player) and A (for AI) characters in place of the colors. In this project, you only need to implement this game for two players and each only has 1 penguin to play in this game. Please use P as players penguin and A to represent the AIs penguin. Also, we change hexagons to octagon.

Game Board
The game board is a 6-column by 6-row suspended grid. The rows are labeled 1 – 6 and the columns are labeled 1 – 6. This is the initial game board:

  1 2 3 4 5 6
1  1 1 1 1 1 1
2  1 2 2 2 2 1
3  1 2 3 3 2 1
4  1 2 3 3 2 1
5  1 2 2 2 2 1
6  1 1 1 1 1 1

The rows are labeled from top to bottom starting with 1, and the columns are labeled from left to right starting with 1. The number in the table(i, j) means the point of octagon at row i and column j. If the octagon was taken, please use . to represent it. Here is an example state of the game:
  1 2 3 4 5 6
1  . P 1 1 1 .
2  . . 2 2 2 1
3  1 2 . . 2 1
4  1 2 A . 2 1
5  1 2 2 2 2 1
6  1 1 1 1 1 1

Game Play
Your implementation will prompt the user before game play to determine where (which octagon) players penguin is. Both players can only select an octagon with 1 point as a starting point. In your implementation, have the human player take the first move. When it is the humans turn the game will prompt the player for which (row, column) she would like to move in the game board. For example, using the above game state, if the human player chooses (2,3) the resulting game state would be:
  1 2 3 4 5 6
1  . . 1 1 1 .
2  . . P 2 2 1
3  1 2 . . 2 1
4  1 2 A . 2 1
5  1 2 2 2 2 1
6  1 1 1 1 1 1

Notice that the player cannot choose (3, 2) since the octagon(2, 2) was taken and theres no path from octagon(1,2) to it. You need to tell the player if she chooses an invalid move, like (3, 2) in this situation, and ask the player to choose another move. The next move would be decided by the AI player, followed by prompting the human player again. Game play would then proceed in that fashion. Here is an example of the game playing out to completion:

  1 2 3 4 5 6
1  . 1 1 1 1 .
2  . . P 2 2 1
3  1 2 . . 2 1
4  1 A . . 2 1
5  1 2 2 2 2 1
6  1 1 1 1 1 1
  1 2 3 4 5 6
1  . 1 1 1 1 .
2  . . . P 2 1
3  1 2 . . 2 1
4  1 A . . 2 1
5  1 2 2 2 2 1
6  1 1 1 1 1 1
  1 2 3 4 5 6
1  . 1 1 1 1 .
2  . . . P 2 1
3  1 2 . . 2 1
4  1 . . . 2 1
5  1 A 2 2 2 1
6  1 1 1 1 1 1
  1 2 3 4 5 6
1  . 1 1 1 1 .
2  . . . . P 1
3  1 2 . . 2 1
4  1 . . . 2 1
5  1 A 2 2 2 1
6  1 1 1 1 1 1

A valid path: the path your penguin moves through contains no empty spot (see . in the map) or another penguin.
Both Player and AI can move as many squares as they want, so long as it’s in a straight line and theres still a path. See the exam below, the player/AI can move from (1, 2) to (1, 5) and from (1, 5) to (6, 5), but cannot move from (6, 5) to (3, 2).
  1 2 3 4 5 6
1  . . 1 1 P .
2  . . 2 2 2 1
3  1 2 . . 2 1
4  1 2 . . 2 1
5  1 2 2 2 2 1
6  1 1 1 1 1 1
  1 2 3 4 5 6
1  . . 1 1 . .
2  . . 2 2 2 1
3  1 2 . . 2 1
4  1 2 . . 2 1
5  1 2 2 2 2 1
6  1 1 1 1 P 1
  1 2 3 4 5 6
1  . . 1 1 . .
2  . . 2 2 2 1
3  1 2 . . 2 1
4  1 2 . . 2 1
5  1 2 2 2 2 1
6  1 1 1 1 P 1

If one of the players dont have any achievable octagon left, print a message saying so and skip that players turn until both players dont have any achievable octagon left and the game is over. See the example below, after the players last term, the AI move twice and end the game.
 
  1 2 3 4 5 6
1  . . . . . .
2  . . P 2 . 1
3  1 2 . . . 1
4  . A . . 2 1
5  . 2 . . . .
6  . . . . . .
  1 2 3 4 5 6
1  . . . . . .
2  . . . P . 1
3  1 2 . . . 1
4  . A . . 2 1
5  . 2 . . . .
6  . . . . . .
1 2 3 4 5 6
1  . . . . . .
2  . . . P . 1
3  1 A . . . 1
4  . . . . 2 1
5  . 2 . . . .
6  . . . . . .
1 2 3 4 5 6
1  . . . . . .
2  . . . P . 1
3  A . . . . 1
4  . . . . 2 1
5  . 2 . . . .
6  . . . . . .

When both players cannot move, output the points acquired by each player in order and announce the winner. For example (though a real game would probably have a longer record):
Players points:    1+3+1+1+2+3 = 11
AIs points:    1+2+2+1+3+1 = 10
Player wins!
Requirements
Your primary objective is to use the C programming language to design and implement Hey that my Fish! game that operates according to the game play described in the previous section. You are required to design and implement the appropriate data structures and corresponding algorithms that will enable a human player to play against an AI player.

The AI design is entirely up to you, however, it should be at least as smart as a 5 year old playing the game. That is, the AI should make some obvious choices such as chasing the achievable octagon with maximal point. If you have taken a course in Artificial Intelligence you are welcome to make your AI more sophisticated (e.g., Minimax), however, this is not required. Furthermore, you are constrained to using only the C constructs that we have covered up through the first week of class. In particular:

Allowable C Language Constructs
printf
basic C data types and variables (int, float, double, char, _Byte/byte)
storage sizes and ranges
type specifiers
arithmetic expressions
for, while, do loop, if statement, switch, conditional operator
aligning output
scanf

1D array and initialization
const
multi-dim arrays
variable length arrays
array length bounds, iteration, length
functions, arguments, locals, returns
prototype declaration
functions and arrays, mutability
global variables
automatic/static variables

In addition, your implementation must meet the following specific requirements:

An array must be used to represent the game board as described above.
Must be able to take row column as user input (i.e. 2 4 to play the tile in the second row and fourth column).
One or more functions must be used as part of the implementation.
Arrays must be passed to functions as arguments.
Iteration must be used to traverse the game board.
Your implementation must be able to determine end state of game: win, lose, or draw with both players total points.
An AI must exist in your game as described above.
You should minimize the use of global variables – no global variables is the best.
Your implementation must show the state of the game, modeled after our examples above, after each move (both human and AI) and display the final game state, who won or who drew, along with the recorded points in the form mentioned in the previous section. All output should be properly formatted and aligned.

The post Hey That’s My Fish Game in C Language appeared first on Savvy Essay Writers.

Disclaimer: It is illegal to use the research material ordered on this website for other than research purposes. You must quote the sources appropriately. The company bears no responsibility for the use of research work, not intended for education use, the work is sold as-is with the highest quality and service available and written by freelancers.