[debutant] jeu avec creation de processus et partage memoire
Bonjour,
je suis etudiant en informatique et j'effectue ma 3eme annee de licence en irlande.Je dois faire ce jeux en 1 semaines et je n'ai malheureusement jamais programme en C++.
Un peu d'aide serait la bienvenue...
Voici l'enonce en anglais bien entendu :s
You are asked to build the infrastructure for a simple two player game system using shared memory and message queues for the communications under UNIX. The system will comprise of a GameController and two player processes. They will communicate using a combination of command line arguments (for setup), shared memory (for the current state of play), and message queues (to request that a player makes a move and to confirm that the player has made a move).
You are being given 1 week to implement this assignment. This is an indication that there is a fair amount of work involved so you need to get started immediately. I will run a tutorial session after a week to discuss issues - but it will only be of use to those who have started work on the assignment.
I would recommend that you develop the GameController first, as what it must do should be reasonably apparent from studying this assignment specification.
A more formal specification:
You are asked to build a system for supporting two player games as follows:
* You must build your system by extending the code provided.
* This assignment must be implemented under UNIX on the College computers (If you do it on your own machine make sure that it works on the machines in College before submitting it).
* The game must be run using 3 processes: one for the GameController and one for each of the two players.
* The GameController must take two command line arguments specifying the player programs (i.e. executable files)
* The board must be stored as an area of shared memory which the GameController must create and then pass its ID to each of the player processes (as a command line argument) when it creates them.
* Requests for players to take a move and confirmation that a player has taken a move must be sent as messages (on a message queue). The type of the message must be the player number (for requests) and CONFIRM_MOVE_MESSAGE_TYPE for confirmations.
* The GameController must create the message queue and must pass its ID to each of the player processes (as a command line argument) when it creates them.
* Each player should be asked for a move in turn but if no move is received within the allowed time (See CNoughtsAndCrosses::TimeAllowedForAMove()) then the game must be awarded to the other player.
* If a player makes an invalid move the game must be awarded to his/her opponent.
* The player processes must be killed, the shared memory deleted and the message queue deleted when the game is over.
* If a player program cannot be started correctly the system must handle this gracefully (and not proceed with the game).
Supplied:
* PlayerUtilities.C & PlayerUtilities.h These files provide methods which allow player process to select and make a move.
* Game.C & Game.h These files define a class on which any specific two person game can be built.
* NoughtsAndCrosses.C & NoughtsAndCrosses.h These files implement the game of Noughts and Crosses.
* NoughtsAndCrossesBoard.h This file defines a basic structure for the Noughts and Crosses board.
* General.C & General.h These files just provide the syserr() facility.
* Utilities.h This file defines some general purpose utilities for shared memory and message queues.
* Makefile
Partly supplied:
* Controller.h (public methods only shown - add private methods/data as required)
* Player.h (public methods only shown - add private methods/data as required)
To be written:
* Utilities.C Implement the methods defined in Utilities.h
* Player.C Implement the Player class defined in Player.h
* Controller.C Implement the Controller class defined in Controller.h
* ContollerMain.C Create a mainline for the Game controller
* PoorPlayer.C and/or PerfectPlayer.C (these should be virtually identical) These mainlines should each create a player process
Voila maintenant plus de 5 heures que j'essaye de comprendre le C++ et le code mais je n'ai pas beaucoup avance.
Si quelqu'un se sent de me sauver la vie ... lol et de me donner un coup de main je pourrai vous transmettre le code ....
Merci ;D