Starting from:
$35

$29

Homework #5 Solution

Hand in: A student with number 20180000001 should hand in a file named 20180000001.c for this homework.










The Word Hunter Game




The word hunter game typically consists of scrambled letters in a grid in which player seeks for hidden meaningful words. Hidden words are placed vertically, horizontally or diagonally. They may overlap but cannot be in zigzag form or wrap around. Your task is to create a word hunter puzzle and let the player play the game.







This is a 6x6 puzzle. There are 4 words hidden in this puzzle. That are:

• “hello” [4,0] & [4,4]




• “world” [1,0] & [5,4]




• “great” [0,0] & [0,4]




• “random” [5,5] & [0,5]




Puzzle Map: Puzzle map is a 15x15 grid where each cell contains a character.




To build a puzzle map, you must do the followings:




 
Fill the whole map with randomly assigned characters. To do so, use a function that simply returns a random character without taking any input.




 
Words and their locations are stored in a file called




“word_hunter.dat”. The given piece of code reads the file and stores the words in a pointer array called “dict”. Coordinates of each word is also stored in an array called “coordinates”. Size of coordinates is 15x4 which are starting [x1, y1] and ending positions [x2, y2] of a word. You must place the words in dictionary on puzzle based on coordinates.




Gameplay: At the beginning of the game, puzzle is printed on the screen. All characters are lowercase. Then, program asks for a word and a coordinate (r=row, c=column). The coordinate can be either the beginning or the end of a word. Thus, program must search for all 8 directions (e.g., north, north-east, east, south-east etc.) as soon as player enters a guess (word). If guess of player is true, corresponding word on map must be converted to uppercase. Otherwise, there is no change on the map.




Termination Conditions:




 
Player finds all the words in the puzzle.




 
Player types “exit game”.










Page 1 of 2







Cumulative Grading Points:




 
[10pts] Filling the whole map with only random characters and printing on the screen.




 
[25pts] Placing the words on map based on given coordinates and printing on the screen.




 
[30pts] Exiting game when user types “exit game”.




 
[90pts] Searching for 8 directions. Each direction is 7,5pts.




 
[95pts] Making the word uppercase, if user finds the word.




 
[100pts] Finishing the game when all words are found.




If you only do choice 1, you get 10pts. If you do choice 1 & 2, you get 25. You cannot do choice 2 by itself. And so on…




General Rules:




 
Obey and don’t broke the function prototypes that are shown on each part, if any, otherwise, you will get zero from the related part.




 
You are not allowed to use string.h library. However, you can write your own string functions. You can also use the functions that I wrote.




 
Note that if any part of your program is not working as expected, then you can get zero from the related part, even it’s working in some way.




 
Upload your .c file on to Moodle to deliver your homework.




 
You can ask any question about the homework via Moodle Forum.




Corresponding TA: M. Rasih ÇELENLİOĞLU (mcelenlioglu@gtu.edu.tr)







































































































Page 2 of 2

More products