uk.org.redfelineninja.risk.robot
Class Move

java.lang.Object
  |
  +--uk.org.redfelineninja.risk.robot.Move

public class Move
extends java.lang.Object

This class represents the choices that the robot wishes to make. The Move can be considered as a vector (mathematical sense not java.lang.Vector). There are as many elements to the vector as there are countries on the board. Each element is a float. The larger that value is the better it is to make a move on the associated country. After all legal moves have been discarded then the largest remaining element will be the move that is made.

Also included are single floats select, fortify and done. These are also compared to the elements, if any of these are the largest value then their actions are performed. Please read their entries for more information.

Move also provides some maths operations for basic manipulation of Moves

Author:
Daniel Thompson, Mar. 1999

Field Summary
 float[] countries
          List of desire levels to click on each country
 float done
          The desire level of the robot to finish their turn.
static int DONE
          This is the constant return be getMove() when the robot has opted to finish its turn.
 float fortify
          The desire level to move to fortify mode.
static int FORTIFY
          This is the constant return be getMove() when the robot has opted to fortify its position.
 float select
          The desire level to move to select mode.
static int SELECT
          This is the constant return be getMove() when the robot has opted to return to SELECT mode.
 
Constructor Summary
Move(int size)
          Create a new move of length size.
 
Method Summary
 Move add(float f)
           
 Move add(Move m)
           
 int getMove()
          Get the move that should be made.
 Move multiplyBy(float f)
           
 Move multiplyBy(Move m)
          Multiply this move by the supplied move.
 void reset()
          Reset this move back to entirely zeros.
 Move scatter(float f)
          Randomly scatter the country weights by the supplied factor.
 Move slideAboveZero()
          Make all weights positive.
 java.lang.String toString()
          Return this Move as a String.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SELECT

public static final int SELECT
This is the constant return be getMove() when the robot has opted to return to SELECT mode.

See Also:
Constant Field Values

FORTIFY

public static final int FORTIFY
This is the constant return be getMove() when the robot has opted to fortify its position.

See Also:
Constant Field Values

DONE

public static final int DONE
This is the constant return be getMove() when the robot has opted to finish its turn.

See Also:
Constant Field Values

countries

public float[] countries
List of desire levels to click on each country


select

public float select
The desire level to move to select mode. This is used by a robot in attack mode to indicate that it wants wants to return to select mode


fortify

public float fortify
The desire level to move to fortify mode. This is used by a robot that wants to fortify


done

public float done
The desire level of the robot to finish their turn. That is used by a robot that wants to finish its turn

Constructor Detail

Move

public Move(int size)
Create a new move of length size.

Method Detail

getMove

public int getMove()
Get the move that should be made.

Returns:
an integer between 0 and the number of countries or a negative number belonging to the set of non country moves, SELECT, FORTIFYor DONE.

reset

public void reset()
Reset this move back to entirely zeros.


multiplyBy

public Move multiplyBy(Move m)
Multiply this move by the supplied move. This can be used to provide extra weightings are to make a legal move filter (multiply by a Move consisting only of zeros and ones).


multiplyBy

public Move multiplyBy(float f)

add

public Move add(Move m)

add

public Move add(float f)

scatter

public Move scatter(float f)
Randomly scatter the country weights by the supplied factor. The non-country weights remain unaffected.

Parameters:
f - the weights will be scattered by +/- f

slideAboveZero

public Move slideAboveZero()
Make all weights positive. This should be called before applying a legal move filter.


toString

public java.lang.String toString()
Return this Move as a String. This is intended to be used mostly for debugging purposes, when the robot is behaving in an unexpected way and it is difficult to see how.

Overrides:
toString in class java.lang.Object