For this lab you will write a pthreads program that will simulate 5 epochs in an online game world. The world consists of four continents (numbered 0 - 3). There are three types of players. The first two are user generated players - type A and type H. The second type of player is a machine generated dragon. The following rules apply:
1. When players log on they are not given a choice which continent they will play in. Main should create four threads (one per continent). Main handles reading in player data and storing it in a global queue. The continents get players from the queue as needed, but at the beginning of the game main will choose 5 consecutive players with the first 5 going to continent 0, the second 5 to continent 1, etc.
2. There can be no more than 5 players per continent...well, 5 players and a dragon.
3. At the end of an epoch, the first two living players on each continent will be magically transported to the next continent. This is a circular shift, so players on continent 3 will go to continent 0. (I recommend keeping a queue of players for each continent)
4. New players can be allowed into the game only at the end of an epoch. So at the end of an epoch after the removal of dead bodies and transportation of other players, if a continent doesn't have 5 players, then it will get the next however many needed players from the global queue.
5. A player will fight players of a different type. The rules of engagement are as follows:
a. Players always fight in groups
b. Players are involved in at most one fight each epoch
c. Players can be killed by opposing players. It requires two team members to kill one opponent. Examples:
Num A's before Num H's before Num A's after Num H's after
5 0 5 0
4 1 4 0
3 2 3 1
2 3 1 3
1 4 0 4
0 5 0 5
6. There is always a dragon roaming around the world somewhere. Dragons roam counter to players...i.e., a dragon will move from 3 to 2 to 1 to 0 to 3.
7. Players cannot kill the dragon.
The homework descriptions is in lab 2 .