Realize an electronic version of "Battleship". In this version two process cooperate between them.
First the player must decide where to place the ships, when both players have placed all ships the processes decide who start. The starting process accepts a move, transmit it to the opponent proocess, waits for the opponent's process response about its move and then waits for the opponent's move. Everytime each process receive a move or a response from the opponent, check if the opponent has hit a ship, check if someone has win and if so tell it to players. Communication channel between process must be implemented by a shared memory area.
To play the program have to be run twice on the same computer (this is an exercise, it won't be a real game to be played on two PCs).
Now I post what I have written till now, please, give me suggestions, correct me if there's a more simple way to do something I've already done, propose me whatever you want to help me to finish this exercise.
Question
Alhazred
I'm trying to solve this thing:
Realize an electronic version of "Battleship". In this version two process cooperate between them.
First the player must decide where to place the ships, when both players have placed all ships the processes decide who start. The starting process accepts a move, transmit it to the opponent proocess, waits for the opponent's process response about its move and then waits for the opponent's move. Everytime each process receive a move or a response from the opponent, check if the opponent has hit a ship, check if someone has win and if so tell it to players. Communication channel between process must be implemented by a shared memory area.
To play the program have to be run twice on the same computer (this is an exercise, it won't be a real game to be played on two PCs).
Now I post what I have written till now, please, give me suggestions, correct me if there's a more simple way to do something I've already done, propose me whatever you want to help me to finish this exercise.
Thanks :)
battleship.txt
Link to comment
Share on other sites
1 answer to this question
Recommended Posts