dice_war
Class AITemplate

java.lang.Object
  extended by dice_war.AITemplate
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
GoAhead, Greedy

public abstract class AITemplate
extends java.lang.Object
implements java.lang.Runnable

The template of AI, 2 necessary methods must be overridden: main() and arrangeNewDices(int nNewDice). You can extend this class and put the class in package dice_war.AI (so it's in the directory dice_war/AI/ ), then the client(UserInterface) will load it automatically. Read the example codes in dice_war.AI, you'll know how to write AI faster.


Field Summary
 boolean[][] edge
          edge set of the graph, represented by adjacency matrix
 int[][] edgeList
          edge set of the graph, represented by edge list
 int MAX_DICE
          the max number of dices a node(vertex) can have
 int myCountry
          the id of me, "nodes[i].country == myCountry" means node i is yours.
 Node[] nodes
          vertex set of the graph, there are some nodes with "country = 0" which means they are holes, don't care them
 double[][] probabilityTable
          probabitlity table, probabilityTable[i][j] means the winning probability about attack(i, j)
 
Constructor Summary
AITemplate()
           
 
Method Summary
 void appendNewDice(Node n)
          append a dice to the node n
protected abstract  void arrangeNewDices(int nNewDice)
          the core of game play, when it's your turn, UserInterface will call this method.
 void attack(int from, int to)
          attack the node 'to' by the node 'from'
 boolean isAttackable(int from, int to)
          see if the node 'from' can attack the node 'to'
protected abstract  void main()
          the core of game play, when it's your turn, UserInterface will call this method.
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_DICE

public int MAX_DICE
the max number of dices a node(vertex) can have


myCountry

public int myCountry
the id of me, "nodes[i].country == myCountry" means node i is yours.


nodes

public Node[] nodes
vertex set of the graph, there are some nodes with "country = 0" which means they are holes, don't care them


edgeList

public int[][] edgeList
edge set of the graph, represented by edge list


edge

public boolean[][] edge
edge set of the graph, represented by adjacency matrix


probabilityTable

public double[][] probabilityTable
probabitlity table, probabilityTable[i][j] means the winning probability about attack(i, j)

Constructor Detail

AITemplate

public AITemplate()
Method Detail

attack

public void attack(int from,
                   int to)
attack the node 'to' by the node 'from'


appendNewDice

public void appendNewDice(Node n)
append a dice to the node n


isAttackable

public boolean isAttackable(int from,
                            int to)
see if the node 'from' can attack the node 'to'


main

protected abstract void main()
the core of game play, when it's your turn, UserInterface will call this method. Override this to do the strategy of attack.


arrangeNewDices

protected abstract void arrangeNewDices(int nNewDice)
the core of game play, when it's your turn, UserInterface will call this method. Override this to do the strategy of attack.


run

public final void run()
Specified by:
run in interface java.lang.Runnable