![]() |
|
#1
|
|||
|
|||
[C] Battleship for NT platformsI'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 |
|
#2
|
|||
|
|||
|
I've modified the placeShip's code in this way:
Code:
I think I have a problem with the underlined parts. |
|
#3
|
||||
|
||||
|
Hello Alhazred. Logic comparisons can be difficult, try replacing this:
CPP / C++ / C Code:
with this: CPP / C++ / C Code:
__________________
The best damn Sports Blog period. |
|
#4
|
|||
|
|||
|
Thanks, now it works
|
|
#5
|
|||
|
|||
|
I have written the code to make the program work (there're just few more thing to be added in some functions).
I have this problem, are a couple of days I'm trying to think how to manage the shared memory access and be sure that the shared memor is used by the proper instance in a determinate moment. I know it must be done with semaphores, but I can't think a right way to do it. Here is the algorithm I want to follow: Between " " the name of function that do what's written on the step, I1 = first instance of the program, I2 = second instance Code:
|
Recent GIDBlog
US Elections and the ?Voter?s Responsibility? by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The