wworld
Class GameServer

java.lang.Object
  |
  +--wworld.GameServer

public class GameServer
extends java.lang.Object

The gameserver object controls the overall simulation of the wumpus world. It conducts the simulation, performs the action, updates the environment, etc.


Field Summary
static int MAXSTEPS
          Maximum number of steps allowed for each trial
 
Constructor Summary
GameServer(Environment wumpusEnv, int trials, int currTrial, java.util.Vector vecScore, int waitTime, projectFrame pFrame)
           
 
Method Summary
 void doAction(Agent agent, Percept percept, int action)
          Performs the action specified by the agent, and sets the necessary variable in the Percept.
 int getAction(java.net.Socket iclient, java.io.ObjectInputStream in)
          Does the necessary communication with the client and gets the action specified by the clients.
 void playGame1(java.util.Vector client, java.util.Vector cin, java.util.Vector cout, projectFrame myFrame, int currentTrial, int numTrials)
          Conducts the simulation from beginning to the end of current trial.
static void printPrompt(java.lang.String prompt)
          prints the prompt
 void printStats()
          Prints all the statistics for each agent at the end of each trial, and at the end of all the trials.
static java.lang.String readLine()
          Reads a line from the standard input
static java.lang.String readLine(java.lang.String prompt)
           
 void reset(Environment wumpusEnv, int currTrial)
          Used to reset attributes at the end of a game.
 void sendIntToStream(java.net.Socket iclient, java.io.ObjectInputStream in, java.io.ObjectOutputStream out, int i)
          Sends an integer over the socket connection to the client.
 void sendToStream(java.net.Socket iclient, java.io.ObjectOutputStream out, java.lang.Object obj)
          Sends the specified obj over the socket to the specified client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXSTEPS

public static int MAXSTEPS
Maximum number of steps allowed for each trial

Constructor Detail

GameServer

public GameServer(Environment wumpusEnv,
                  int trials,
                  int currTrial,
                  java.util.Vector vecScore,
                  int waitTime,
                  projectFrame pFrame)
Method Detail

reset

public void reset(Environment wumpusEnv,
                  int currTrial)
Used to reset attributes at the end of a game.


playGame1

public void playGame1(java.util.Vector client,
                      java.util.Vector cin,
                      java.util.Vector cout,
                      projectFrame myFrame,
                      int currentTrial,
                      int numTrials)
Conducts the simulation from beginning to the end of current trial.


printStats

public void printStats()
Prints all the statistics for each agent at the end of each trial, and at the end of all the trials.


doAction

public void doAction(Agent agent,
                     Percept percept,
                     int action)
Performs the action specified by the agent, and sets the necessary variable in the Percept.


getAction

public int getAction(java.net.Socket iclient,
                     java.io.ObjectInputStream in)
Does the necessary communication with the client and gets the action specified by the clients.

Returns:
action coming from the ith client

sendToStream

public void sendToStream(java.net.Socket iclient,
                         java.io.ObjectOutputStream out,
                         java.lang.Object obj)
Sends the specified obj over the socket to the specified client.


sendIntToStream

public void sendIntToStream(java.net.Socket iclient,
                            java.io.ObjectInputStream in,
                            java.io.ObjectOutputStream out,
                            int i)
Sends an integer over the socket connection to the client.


printPrompt

public static void printPrompt(java.lang.String prompt)
prints the prompt


readLine

public static java.lang.String readLine()
Reads a line from the standard input


readLine

public static java.lang.String readLine(java.lang.String prompt)