Tải bản đầy đủ (.pdf) (2 trang)

Slp description for simple ASCII game using multithreading

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (160.24 KB, 2 trang )

Main Idea

We decided to show you the aspects of multithreading via a simple ASCII game. You can see if you have done something right by observing that the game is getting more

playable. In the beginning, you will only see a plain game map without any content.

The games a simplified version of seaquest. Your player can move around and pick up divers. In the game the player needs to pick up all divers and rescue them, while
avoiding debris and sharks in the water.

The game consists of 5 different entities:

* Debris: Debris are a 2x2 square on the game map. They are stationary and will kill your player immediately upon contact. (represented by a 'M')
* Sharks: Sharks are a single field on the game map and are moving randomly. They will destroy the player upon contact. (represented by an‘S’)
* Player: The player (represented by a‘P’) gets moved via the WASD keys. The game shall quit when ‘q’ is pressed, when the hits an enemy or the border or the oxygen
supply is depleted. (Lifepoints get set to 0)
* Divers: To get points, the player needs to rescue divers (represented by ‘D’). First the player needs to collect all missing divers in the water, then the divers need to be
returned to the surface. After the divers are returned to the surfacea new set of divers is spawned, which need to be rescued.
* Oxygen: While below a certain depth level the player loses oxygen. When the oxygen is depleted the player loses the game. To restore the oxygen level, the players
needs to be near the surface.
Setup

You'll have to install ncurses as well as the C build tools on your system. In Debian/Ubuntu

the following line will do the job:

sudo apt-get install build-essential 1ibncurses-dev

In some circumstances, your system may require explicit ncurse versions:
sudo apt-get install Libncurses6-dev Libncursesw6-dev
If none of the packages above work on your system, you can use ncurses5. This package is deprecated and you should only use it as a last resort after asking for support on
discord!



Do NOT make any other changes to the Makefile !


Implementation details
'When you open the folder ofthis task, you will notice five files:
‘makefile : Use this file to compile and run the program or clean up the folder with it. You MUST NOT commit any changes to this file!
© main.c : This file exists to more easily mount our testcases. You MUST NOT commit any changes to this file!
* searescue.h : This file contains relevant includes, typedefs, predefined values. You can change them as you wish but be careful: you MUST NOT commit changes to
this file. Therefore, all changes are irrelevant for us.
*helpers.c : This file contains helper functions to make the game playable. You MUST NOT commit any changes to this file!
© searescue.c : Thisis the only file that will be checked and used by the test system. Please follow the TODOs and ONLY change and add code between TODO BEGIN,
and TODO END!
To summarize, you can modify all files but only are allowed to commit changes to searescue.c. This ensures that you are using the same files as the testsystem and
everything should work locally as it would on the testsystem.
‘You must not create ANY global variables, delete existing code outside of the TODOs (comments can be changed and added, of course), or rearrange existing code! Be
careful, do not delete any needed functions declared in the header file.
Furthermore, you should keep the lifetime of variables in mind and you shouldn't leak any memory that you allocate. You don’t need to test this with valgrind since
libncurses leaks memory and therefore valgrind would produce wrong results. Furthermore, valgrind is known to have bugs with this type of game and some of our TODOs.
What to do before you start?

Pull from upstream!
* Carefully look at the TODOs in the searescue.c file.
+ The TODOsare enumerated in the suggested way you should solve the assignment
‘* Look at the Manpage and what those parameters of the needed functions are for and how they are used. ( pthread create( . ) 4 pthread cancel ..
pthread join( . ) , etc [ />+ Only begin if you understand the basic concept, what a thread is, and what it does. Bruteforcing will lead to a severe amount of wasted time.
‘* Try to understand the different functions in the searescue.c file and their connections.
‘© Hint: Make sure that you reuse as many variables as possible.




×