dk.brics.bisim
Class BisimulationGame

java.lang.Object
  extended by dk.brics.bisim.BisimulationGame

public class BisimulationGame
extends java.lang.Object

The main class of the application.

Design

Parts:

  1. Model-View-Controller
  2. RMI
  3. GUI
  4. Computer players

1. Model-View-Controller

The application uses the MVC design pattern throughout choosing options, playing a game, and simulation a CCS agent. This means e.g. that the SimulatorController listens on user-events on the SimulatorView, and reflects changes in the SimulatorModel.

2. RMI

The game can be played remotely, where one player acts as a server, and one as a client. The server chooses the input LTSs, his role, and the bisimulation type. An RMI registry is then started on a fixed port (known to the client) on that host, with a security policy which grants the following permissions:

permission java.net.SocketPermission "localhost:*", "listen";

permission java.net.SocketPermission "*:*", "accept,connect,resolve";

permission java.io.FilePermission "<>", "read,execute";

permission java.util.PropertyPermission "*", "read";

Basically this is what is needed for reading arbitrary graph files, executing 'dot' on an arbitrary path, and making remote connections.

The RMI registry holds two remote objects:

The client may then join a game by specifying the name of the host running the game. Examples of host names are:

camel25.daimi.au.dk

camel25 (if both machines are on the same LAN)

130.225.16.144

Whether playing as a client or as a server, a security manager is installed to govern RMI. Once a server starts, a new RMI registry cannot be created on the same computer until the server exits the application. In particular this means that a server cannot later connect to the same computer as a client without exiting the application. Of course, a server may still change role and connect as a client to another computer.

3. GUI

In two-player remote games, a chat function is enabled. To chat, type a message in the text field and hit return, or press the 'Send' button. When the other user sends a message it is displayed below the text field.

4. Computer players

One player games are possible, in which the opponent is a computer player acting as either attacker or defender. The AI player is started in a separate thread and also uses the message passer to send status messages, but unlike remote games there is now only one game model and controller, namely the one associated with the human player. When the human player quits a game, the AI thread is asked to stop running. The AI strategies are based on configuration graphs.

When a game starts, check the game type:

  1. 2p remote, server:
    Setup a RMI registry and bind global objects (globalModel, messagePasser).
  2. 2p remote, client:
    Locate a remote registry at the specified host and retrieve the remote objects.
  3. Local game:
    The game controller still talks to the message passer, and if it's a 1p game, a computer player thread is started, which also talks to the message passer.
When a game ends:
  1. If an AI thread is running, tell it to quit.
  2. If the player is a server, unbind the remote objects.
  3. If the player is a client, nullify the registry.

Author:
Martin Mosegaard martinm@daimi.au.dk

Field Summary
private  AI ai
          Thread for a computer player.
private  int bisimulation
           
private  int clientServerRole
           
private  DotModel dotModel
           
private  GameController gameController
           
private  GameModel gameModel
           
private  GameView gameView
           
private  GlobalModel globalModel
           
private  boolean hasRegistry
           
private  MessagePasser messagePasser
           
private  OptionsModel optionsModel
           
private  java.rmi.registry.Registry reg
          Remote object registry: Used in 2p remote games .
private  int role
           
private  UserProperties userProperties
           
private  MainView view
           
 
Constructor Summary
BisimulationGame()
          Starts a bisimulation game, and shows the options view.
 
Method Summary
private  void initClient()
           
private  void initLocal()
           
private  void initServer()
           
static void main(java.lang.String[] args)
          Starts a bisimulation game with an options model and a view.
private  boolean makeLTSs()
          Construct an LTSModel for the left and right LTSs and pass this to a GameController.
 void quitGame()
          Invoked by the game controller when the (local) player wants to quit a game.
 void startGame()
          Invoked by the options controller.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reg

private java.rmi.registry.Registry reg
Remote object registry: Used in 2p remote games .


hasRegistry

private boolean hasRegistry

userProperties

private UserProperties userProperties

dotModel

private DotModel dotModel

gameModel

private GameModel gameModel

optionsModel

private OptionsModel optionsModel

globalModel

private GlobalModel globalModel

view

private MainView view

gameView

private GameView gameView

messagePasser

private MessagePasser messagePasser

gameController

private GameController gameController

ai

private AI ai
Thread for a computer player.


role

private int role

clientServerRole

private int clientServerRole

bisimulation

private int bisimulation
Constructor Detail

BisimulationGame

public BisimulationGame()
                 throws javax.swing.text.BadLocationException
Starts a bisimulation game, and shows the options view.

Throws:
javax.swing.text.BadLocationException - Should never be thrown
Method Detail

main

public static void main(java.lang.String[] args)
Starts a bisimulation game with an options model and a view.

Parameters:
args - Arguments are ignored

startGame

public void startGame()
Invoked by the options controller. Starts a new game.


quitGame

public void quitGame()
Invoked by the game controller when the (local) player wants to quit a game. Switch from game view to options view.


initLocal

private void initLocal()
                throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

initServer

private void initServer()
                 throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

initClient

private void initClient()
                 throws java.rmi.RemoteException,
                        java.rmi.NotBoundException
Throws:
java.rmi.RemoteException
java.rmi.NotBoundException

makeLTSs

private boolean makeLTSs()
                  throws java.rmi.RemoteException
Construct an LTSModel for the left and right LTSs and pass this to a GameController.

Throws:
java.rmi.RemoteException