This module is designed for game rules and interface, which is scheduled to be completed in 2005.3.9. It is currently progressing smoothly and is expected to be completed in advance.
This module is divided into two parts: 1) interface design. Prepare the needs of the image file, etc .; design graphical interface; this part design has been completed, time consuming for two days. Main Class: Mainframe: Game window, initially set to the game itself, will have three logical members: UI: Game interface, only responsible for display; (completed) GameMaster: Game managers, responsible for game order, monitor players and modify game status . StateObserver: Game status observers, observe the status status and display on the UI. (carry out)
2) Design of the game rules. Design game rules and ChesSplayer interactions between games. Major class: GameMaster: Game managers, responsible for game order, monitor players and modify game status. When the player is human, monitor several ChessGrid and three auxiliary jbutton; when players
When the computer AI is monitored, the AI gets the fall position. According to the position and rules of the fall, make corresponding behavior. Finally modify the game status Gamestate, including the logging game and switching the user, by
GameState stimulates its observer StateObserver modified status display. It has the domain: chessgrid [] [] []: Chess array jButton []: Auxiliary button GameState: Game status, two players, or human or AI;
Gamemaster partial algorithm:
MouseClicked () {// Handle Mouse Event / / If the fall position is legal, close the chessgrid monitoring status = checkstep (current); // If auxiliary input is required, open the secondplay monitoring; return; NextPlayer ();} ... actionperformed ) {Handle (decision); NextPlayer ();} ... NextPlayer () {// ready for next player gamestate.addstep (current, defision); GameState.NextPlayer (); while (! Gamestate.ishumanturn ()) { Decision = GameState.getNextStep (CURRENT); STATUS = checkstep; // If auxiliary input is required, because AI must consider how to enter Handle (Decision); Gamestate.Addstep (Current, Decision); Gamestate .nextplayer ();} // Open CHESSGRID monitoring, ready to accept human input}
GameState: is an observer. With two ChessPlayer, NEXTPLAYER (), first notifyobserver () modifies the status, and then point to the next CHESSPLAYER. in
GetNextStep () Call the getNextStep () method provided by ChessPlayer to get the AI calculation results.
StateObserver: is an observer. Observe the status of GameState and make the corresponding modification. At present, the remaining tasks are: 1) The GameMaster needs to be judged to end. The game end conditions will be selected in the following conditions: a) Unable to continue the decision and b) one party full dismantlement C) One party time exceeds the period to determine the loss D) One Slim Sub-bead Judgment 2) GameMaster add time limit. 3) Control the game through the menu in the mainframe.