Class IAS

java.lang.Object
  |
  +--IAS
All Implemented Interfaces:
SendCommand

class IAS
extends java.lang.Object
implements SendCommand

IAS class Main class used to run the IAS (In the Agent's Shoes) interface.


Field Summary
 java.util.Vector commands
           
 Command currentCommand
           
 SensorInput m_brain
           
 boolean m_goalie
           
 java.net.InetAddress m_host
           
 int m_port
           
 java.net.DatagramSocket m_socket
           
 java.lang.String m_team
           
static int MSG_SIZE
           
 PlayerCanvas p_canvas
           
 PlayerFrame p_frame
           
 boolean packFrame
           
 char side
           
 double stamina
           
 float time
           
 
Constructor Summary
IAS(java.net.InetAddress host, int port, java.lang.String team, boolean goalie)
          IAS Constructor Used to open a socket connection with the soccer server, and create the visual frame for interaction by a human competitor.
 
Method Summary
 void catchBall(double direction)
          catchBall method.
 void changeView(java.lang.String angle, java.lang.String quality)
          changeView method.
 void dash(double power)
          dash method.
 void finalize()
          finalize destructor method.
 void init()
          init method.
 void kick(double power, double direction)
          kick method.
static void main(java.lang.String[] a)
          main method.
protected  void mainLoop()
          mainLoop method.
 void move(double x, double y)
          move method.
 void nextCommand()
          nextCommand method.
 void parseHear(java.lang.String message)
          parseHear method.
protected  void parseInitCommand(java.lang.String message)
          parseInitCommand method.
 void parseSensorInformation(java.lang.String message)
          parseSensorInformation method.
 java.lang.String receive()
          receive method.
 void say(java.lang.String message)
          say method.
 void send(java.lang.String message)
          send method.
 void sensebody()
          sensebody method.
 void turn(double moment)
          turn method.
 void turnNeck(double angle)
          turnNeck method.
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

m_socket

public java.net.DatagramSocket m_socket

m_host

public java.net.InetAddress m_host

m_port

public int m_port

m_team

public java.lang.String m_team

m_brain

public SensorInput m_brain

m_goalie

public boolean m_goalie

packFrame

public boolean packFrame

p_frame

public PlayerFrame p_frame

p_canvas

public PlayerCanvas p_canvas

commands

public java.util.Vector commands

currentCommand

public Command currentCommand

side

public char side

stamina

public double stamina

time

public float time

MSG_SIZE

public static final int MSG_SIZE
Constructor Detail

IAS

public IAS(java.net.InetAddress host,
           int port,
           java.lang.String team,
           boolean goalie)
    throws java.net.SocketException
IAS Constructor Used to open a socket connection with the soccer server, and create the visual frame for interaction by a human competitor.
Parameters:
host - Host URL or IP Address of the soccer server
port - Port which is used by the soccer server
team - Teamname of the IAS player
goalie - Boolean flag which indicates whether this player is a goalie
Throws:
java.net.SocketException -  
Method Detail

main

public static void main(java.lang.String[] a)
                 throws java.net.SocketException,
                        java.io.IOException
main method. Used to start the IAS interface. Command line format: IAS [-parameter value] Parameters: host (default "localhost") The host name can either be a machine name, such as "java.sun.com" or a string representing its IP address, such as "206.26.48.100." port (default 6000) Port number for communication with server team (default IAS) Team name. This name can not contain spaces.
Parameters:
a - String array consisting of the parameters from the command line.
Returns:
none
Throws:
java.net.SocketException -  
java.io.IOException -  

finalize

public void finalize()
finalize destructor method. Used to close the socket connection
Overrides:
finalize in class java.lang.Object
Returns:
none

mainLoop

protected void mainLoop()
                 throws java.io.IOException
mainLoop method. Used to continuously wait and receive information from the soccer server.
Returns:
none
Throws:
java.io.IOException -  

move

public void move(double x,
                 double y)
move method. Used to send a move command to the server so a player is moved to a specific coordinate location on the field.
Specified by:
move in interface SendCommand
Parameters:
x - x-coordinate of the field
y - y-coordinate of the field
Returns:
none

turn

public void turn(double moment)
turn method. Used to send a turn command to the server so a player can turn.
Specified by:
turn in interface SendCommand
Parameters:
moment - Angle at which to turn the player
Returns:
none

turnNeck

public void turnNeck(double angle)
turnNeck method. Used to send a turn_neck command to the server so a player can turn their field of view, while maintaining their current direction.
Specified by:
turnNeck in interface SendCommand
Parameters:
angle - Angle at which to turn the player's neck
Returns:
none

dash

public void dash(double power)
dash method. Used to send a dash command to the server so a player can run.
Specified by:
dash in interface SendCommand
Parameters:
power - Power at which to run (maximum of 100)
Returns:
none

catchBall

public void catchBall(double direction)
catchBall method. Used to send a catch command to the server so a goalie can catch the ball.
Specified by:
catchBall in interface SendCommand
Parameters:
direction - Direction in which to attempt a catch of the ball
Returns:
none

kick

public void kick(double power,
                 double direction)
kick method. Used to send a kick command to the server so a player may kick the ball.
Specified by:
kick in interface SendCommand
Parameters:
power - Power with which to kick the ball (maximum 100)
direction - Direction, or angle, to kick the ball
Returns:
none

say

public void say(java.lang.String message)
say method. Used to send a say command to the server so that other players can hear what the current player communicates.
Specified by:
say in interface SendCommand
Parameters:
message - Message that the current player wishes to communicate
Returns:
none

changeView

public void changeView(java.lang.String angle,
                       java.lang.String quality)
changeView method. Used to send a change_view command to the server.
Specified by:
changeView in interface SendCommand
Parameters:
angle - Angle to change the view to
quality - Quality to change the view to
Returns:
none

sensebody

public void sensebody()
sensebody method. Used to send a sense_body command to the server in order to obatin a player's body information, such as stamina. In later versions of the soccer server, sense_body information is sent automatically by the server, whereas earlier versions required a sense_body command to be sent.
Specified by:
sensebody in interface SendCommand
Returns:
none

parseInitCommand

protected void parseInitCommand(java.lang.String message)
                         throws java.io.IOException
parseInitCommand method. Used to parse the init command received from the server, to obtain the player's number, side, and current play_mode. This method is also responsible for creating the Brain of the player.
Parameters:
message - Init command message from the server
Returns:
none
Throws:
java.io.IOException -  

init

public void init()
init method. Used to construct and send an init command to the server.
Returns:
none

parseSensorInformation

public void parseSensorInformation(java.lang.String message)
parseSensorInformation method. Used to parse the sensor information received from the server, which could be a see, hear, or sense_body response.
Parameters:
message - Server sensory message
Returns:
none

parseHear

public void parseHear(java.lang.String message)
parseHear method. Used to parse the hear command received from the server.
Parameters:
message - Hear command message from the server
Returns:
none

send

public void send(java.lang.String message)
send method. Used to construct a socket datagram packet, and send this to the server.
Parameters:
message - Message to send to the server
Returns:
none

receive

public java.lang.String receive()
receive method. Used to construct a socket datagram packet from the socket connection, thereby retrieving information from the soccer server.
Returns:
none

nextCommand

public void nextCommand()
nextCommand method. Used to get and remove the next command from the commands queue, and sends this command to the soccer server.
Specified by:
nextCommand in interface SendCommand
Returns:
none