cz.nipax.hippo.pexeso
Class AI_forgetting

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

public class AI_forgetting
extends AI_random

Implementation of forgetting inteligence. The AI remembers which positions were revealed, when and how many times. From this it decides (with some random) weather takes the correct position. It simulates "fault" by taking neighbour position instead of correct one.


Nested Class Summary
(package private)  class AI_forgetting.Piece
          Store informations about one position in playground.
 
Field Summary
(package private)  AI_forgetting.Piece[][] m_field
          Representation of playground by field of AI_forgetting.Pieces.
(package private)  int m_lastID
          Last revealed ID.
(package private)  int m_turn
          Number of current turn.
(package private)  int m_x
          width of playgorund
(package private)  int m_y
          height of playground
(package private)  int my_turn
          For determinig who is playing now. 0 == not our turn, 1 == our first card, 2 == our second card.
 
Fields inherited from class cz.nipax.hippo.pexeso.AI
DEBUG, m_killed, m_pg, MOVESLEEP
 
Constructor Summary
AI_forgetting(Playground pg)
          Simple constructor for variables init.
 
Method Summary
protected  void first_random_move()
          Random move in first turn.
protected  void first_turn()
          Searches stored data and try to find two know pieces with same ID.
 java.lang.String getname()
          Returns name of AI.
 void ivalidate(int x, int y)
          Invaliding position.
 void onturn()
          Computes first move using first_turn().
 void revealed(int x, int y, int ID)
          Stores info about revealed card and makes second move if our turn.
protected  void second_random_move()
          Random move in second turn.
protected  void second_turn()
          Searches for buddy for just revealed pice.
protected  void thread_turn()
          Computes one turn in separate thread.
protected  boolean try_turn(int x, int y)
          Delivers turn to Playground.wantturn(cz.nipax.hippo.pexeso.AI, int, int).
 
Methods inherited from class cz.nipax.hippo.pexeso.AI_random
random_move
 
Methods inherited from class cz.nipax.hippo.pexeso.AI
kill, println, setSleep, userinput
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_x

int m_x
width of playgorund


m_y

int m_y
height of playground


m_turn

int m_turn
Number of current turn. Starts with 0 and increments with every revealed(int, int, int).


m_field

AI_forgetting.Piece[][] m_field
Representation of playground by field of AI_forgetting.Pieces.


my_turn

int my_turn
For determinig who is playing now. 0 == not our turn, 1 == our first card, 2 == our second card.


m_lastID

int m_lastID
Last revealed ID.

Constructor Detail

AI_forgetting

public AI_forgetting(Playground pg)
Simple constructor for variables init.

Parameters:
pg - associated Playground
Method Detail

getname

public java.lang.String getname()
Returns name of AI.

Overrides:
getname in class AI_random
Returns:
string with name

onturn

public void onturn()
Computes first move using first_turn().

Overrides:
onturn in class AI_random

thread_turn

protected void thread_turn()
Computes one turn in separate thread. The thread sleeps 1000ms to create some little delay - it is more comfortable for human opponent.


try_turn

protected boolean try_turn(int x,
                           int y)
Delivers turn to Playground.wantturn(cz.nipax.hippo.pexeso.AI, int, int). But before computes some random and may modify x and y. This is the method, where forgetting is simulated.

Parameters:
x - coordinate of wanted move
y - coordinate of wanted move

first_turn

protected void first_turn()
Searches stored data and try to find two know pieces with same ID. Then try to overturn one of them. If no same are known, uses random move. This is strategy for first of two turns.


first_random_move

protected void first_random_move()
Random move in first turn. Will be needed in AI_snc.


second_random_move

protected void second_random_move()
Random move in second turn. Will be needed in AI_snc.


second_turn

protected void second_turn()
Searches for buddy for just revealed pice. Then try to overturn it. If not found useses random move. This is strategy for second move.


revealed

public void revealed(int x,
                     int y,
                     int ID)
Stores info about revealed card and makes second move if our turn.

Overrides:
revealed in class AI
Parameters:
x - coordinate of revealed card
y - coordinate of revealed card
ID - ID of revealed card

ivalidate

public void ivalidate(int x,
                      int y)
Invaliding position.

Overrides:
ivalidate in class AI
Parameters:
x - coordinate of invalid card
y - coordinate of invalid card