Hey-thats-my-Fish / readme1.txt
readme1.txt
Raw
README
The program is the simulation of the board game "Hey, that's my Fish," where the player and AI take a turn going around the board collecting points as possible before running out of space. The program creates a game board using the user-defined type "grid" which stores the current spots data and other connecting pieces. Then we have two pointers representing the AI and players' position on the gameboard, and they are randomly placed on the outskirts of the board. Once that is done, the game is ready to be played. The function validPlayerRequest takes in user input and checks if it is valid. And if it is valid then another function illegal move checks if there is a path to the desired spot. However, if there isn't the player must enter a new input. Once it finds a legal path to the desired spot, the pointer changes to point to the new spot, and the score is added to the linked list. Then the AI goes. The AI tries to head to the spot that has the most point value. To implement this, a pointer goes into a direction such as "left" and keeps going left until it hits a null pointer or an illegal character (P, A, .). While iterating, it keeps on comparing its value to the highest value found in 8 directions. If the current grid piece has a higher point value than the global highest value, it sets a different pointer representing the grid piece of highest value to it. Once it is down iterating through all the directions, the new AI spot is going to be the pointer with the highest value found. Once AI is turn is over and the score has been added to the linked list, it goes back to the player's turn. The game continues until both players don't have any turns remain. Then the scores are printed and calculated, showing who won.


The game board uses the user-defined type "grid" which represents a spot on the board. Type grid can hold the spots value and pointers to other grid pieces (representing the 8 possible directions). Using the malloc function, 36 blocks of memory were allocated for the grid pieces to represent the spots on the grid. And then, a for-loop was used to construct the game board. The for-loop iterates 36 times and connects other grid pieces to other grid pieces depending on their location on memory. For example, the very first grid piece (the zeroth spot) can link to the 6th piece in memory, which would represent the piece below the first one. Using properties such that the left piece is the previous spot in memory, the right piece is the next spot in the memory, down is the 6th spot in memory to the right, up is the 6th memory to the left, upright is the 5th memory to the left, upleft is the 7th memory, downright is 7th memory to right, and down left is 5th memory allows us to traverse any piece on the board from anywhere. However, if a grid piece doesn't have a certain direction is set to Null, representing the borders. Once the board is linked, the points are added. Depending on if the piece is located on memory, different points are added. For instance, if the location in the memory array is less than 6 or greater than 30 or %6==0 or %6==1, it will be given the point values of one since they represent the borders.