cz.nipax.hippo.pexeso
Class AI

java.lang.Object
  extended by cz.nipax.hippo.pexeso.AI
Direct Known Subclasses:
AI_human, AI_random

public class AI
extends java.lang.Object

The basic class for all other AI classes. Defines basic interface for AI. See Playground for description of calls between AI and rest of the game. Object of this class shouldn't be created od used since this class doesn't implement any inteligence. It is recommended to check m_killed and m_pg.isEnd() for end of AI's living.


Field Summary
(package private) static boolean DEBUG
          Determines weather println(java.lang.String) will write anything to output.
protected  boolean m_killed
          Determines state of AI.
protected  Playground m_pg
          Playground where this AI is used.
protected static int MOVESLEEP
          Sleeptime between moves.
 
Constructor Summary
AI(Playground pg)
          Simple constructior that only sets m_pg.
 
Method Summary
 java.lang.String getname()
          Gets name of AI.
 void ivalidate(int x, int y)
          Notify AI, that position is now invalid.
 void kill()
          Notify AI, that it should end now and no longer disturb anyone.
 void onturn()
          Notification from Playground that it is our turn.
 void println(java.lang.String s)
          Inteligent printing message.
 void revealed(int x, int y, int ID)
          Notification from Playground that it card in playground was revealed.
static void setSleep(int time)
          Set sleep time.
 void userinput(int x, int y)
          If user clicks on any card, this event is generated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MOVESLEEP

protected static int MOVESLEEP
Sleeptime between moves. For better feeling for human.


m_pg

protected Playground m_pg
Playground where this AI is used. It is important for calls back to Playground using Playground.wantturn(cz.nipax.hippo.pexeso.AI, int, int)


m_killed

protected boolean m_killed
Determines state of AI. If m_killed == true the AI should stop all computation and don't call any funcions from m_pg.

See Also:
kill()

DEBUG

static final boolean DEBUG
Determines weather println(java.lang.String) will write anything to output.

See Also:
Constant Field Values
Constructor Detail

AI

public AI(Playground pg)
Simple constructior that only sets m_pg.

Parameters:
pg - the Playground thi AI is playing on
Method Detail

setSleep

public static void setSleep(int time)
Set sleep time.

Parameters:
time - in miliseconds

println

public void println(java.lang.String s)
Inteligent printing message. It is possible to disable all messages in one place at once.

Parameters:
s - the message to print

getname

public java.lang.String getname()
Gets name of AI. Should be overriden in child classes.

Returns:
string with name

userinput

public void userinput(int x,
                      int y)
If user clicks on any card, this event is generated. Every time this AI is on turn all user's clicks are passed here.

Parameters:
x - x coordinate of click
y - y coortinate of click

onturn

public void onturn()
Notification from Playground that it is our turn. Now the AI has two turns. It is possible to make two moves directly from this function or wait for second turn to function revealed(int, int, int). If the AI is successfull and guess two same positions, this method is called again.


revealed

public void revealed(int x,
                     int y,
                     int ID)
Notification from Playground that it card in playground was revealed. AI may want to remember revealed cards somewere. This method is called everytime any card is revealed.

Parameters:
x - coordinate of card
y - coordinate of card
ID - ID of card

ivalidate

public void ivalidate(int x,
                      int y)
Notify AI, that position is now invalid. Notification for one position may occure multipletimes. AI shouldn't do any strong computaion here.

Parameters:
x - coordinate of now invalid position
y - coordinate of now invalid position

kill

public void kill()
Notify AI, that it should end now and no longer disturb anyone. Playground should take no more input Playground.wantturn(cz.nipax.hippo.pexeso.AI, int, int) from killed AI. This sets m_killed to true