System modules

Module nameTechnologyDescription
Application serverJava 2 SESuperior module. Controls data flow between subordinate modules connected to it.
GameJava 2 SERuns on the server. Receives players' actions. Verifies correctness of actions and controls the run of match. Sends actions between players and game state to a logger.
Player/WarriorTemplate C++ codeConnects to a game. Receives opponet's action and answers with its own.
ObserverJava 2 SE (Swing)Connects to a game. Receives game state data. Visualizes or logs the run of game.

System functionality

Module nameFunctions
Application server
  • setting connections
  • running games
  • message passing
  • closing connections
Game
  • building a game environment
  • players acceptance (according to a name)
  • sending match parameters (to players and observers)
  • players action analyzing (in a game logic context)
  • sending correct actions (to opponent and/or observer)
  • sending messages about incorrect actions
  • sending end of game message
Player/Warrior
  • connecting to a game
  • receiving parameters of a game
  • choosing a game action
  • sending chosen actions
  • receiving server messages (opponent?s actions, errors, end of game message)
Observer
  • connecting to a game
  • receiving a game action log (after connection)
  • receiving course of a game messages (in real time)
  • visualization of the game environment
    • drawing a game field
    • displaying players? actions on a field
    • displaying players? move times
    • game statistics (player names, number of moves, average move length)
    • showing error information
  • writing a match log into file
  • replaying a match from a log file

Protocol

Welcome message

Module nameSposob powitania
Game Jest uruchamiana przez administratora systemu lub automatycznie przez serwer, gdy pojawia sie zadanie przylaczenia do gry od gracza i serwer nie ma wolnych gier.
Player
<message type="hello" id="12345">
  <mod-type>player</mod-type>
  <name>Swapper</name>
</message>
Observer
<message type="hello" id="12345">
  <mod-type>observer</mod-type>
  <name>Logger</name>
</message>

Akcja

<message type="move" id="12345">
  <type>1</type>
  <type>2</type>
  <type>3</type>
</message>

Parametry planszy

<message type="params" id="12345">
  <map width="10" height="8" goal="2"/>
  <attack side="-1" begin="true"/>
</message>

Stan gry

<message type="log" id="12345">
  <name>Killer</name>
  <name>Swapper</name>

  <map width="10" height="8" goal="2"/>

  <begin>Swapper</begin>

  <move time="15:37.45">
   <type>1</type>
   <type>2</type>
   <type>3</type>
  </move>
  ...
  <error name="Wymiatacz">Niepoprawny komunikat</error>
  ...
  <move time="15:38.45">
   <type>1</type>
   <type>2</type>
   <type>3</type>
  </move>
  ...
  <winner>Swapper</winner>
</message>

Wiadomo?ci specjalne

Message typeDescription
Game over
<message type="game-over" id="12345">
  <name>Swapper</name>
</message>
Message acception/refusal Serwer potwierdza badz odrzuca kazda wiadomosc od klienta (gracza lub obserwatora). Jezeli wiadomosc zostanie odrzucona, klient powinien ja zmienic zaleznie od podanego przez serwer powodu odrzucenia i wyslac ponownie. W przypadku otrzymania trzech kolejnych niepoprawych wiadomosci, serwer zamyka polacznie z klientem, ktory je wyslac. Podobnie w sytuacji nadejscia wiadomosci w momencie gdy serwer sie jej nie spodziewa (np. koniec gry).

<message type="confirmation" id="12345">
  <accepted/>
</message>

<message type="confirmation" id="12345">
  <refused>
    Incorrect move.
  </refused>
</message>
Lista gier/Wybor gry do obserwacji
<message type="games" id="12345">
  <name>Red vs. Blue</name>
  <name>Freddy vs. Jason</name>
</message>

<message type="game" id="12345">
  <name>RotoZoomer vs. PlasmaCloud</name>
</message>

Communication and time measurement

PLAYER_1       GAME            PLAYER_2
   |-----\   H   |                |
   |      \---->>|   H    /-------|
   |  Ack /------|<<-----/        |
   |<<---/       |-------\  Ack   |
   |   P  /------|-------\\----->>|
   |<<---/       |   P    \----->>|
   |-----\  Ack  |  Ack   /-------|
   |      \---->>|<<-----/        |
   |       [T1b] |                |
   |             |                |
   |-----\   A1  |                |
   |      \---->>| [T1e]          |
   | Ack  /------|-------\   A1   |
   |<<---/       |        \----->>|
   |             |  Ack   /-------|
   |       [T2b] |<<-----/        |
   |             |                |
   |             |   A2   /-------|
   |       [T2e] |<<-----/        |
   |  A2  /------|                |
   |<<---/       |                |
   |-----\  Ack  |                |
   |      \---->>| [T1b]          |

                ...

   |-----\   An  |                |
   |      \---->>| [T1e]          |
   | Ack  /------|                |
   |<<---/       |                |
   |  GO  /------|-------\   GO   |
   |<<---/       |        \----->>|
   |             |                |
   X             X                X