F:\java\knim-game\sources\ru\ifmo\knim\controlled\AIObject.java

1    /** 
2     * @(#)AIObject.java 
3     *  
4     *  Copyright Anthony Yakovlev <yakovlev@rain.ifmo.ru> and Michail Lukin <michail@users.msn.com> 
5     */ 
6     
7    package ru.ifmo.knim.controlled; 
8     
9    import com.evelopers.unimod.runtime.ControlledObject; 
10   import com.evelopers.unimod.runtime.context.StateMachineContext; 
11   import ru.ifmo.knim.main.GamePlay; 
12   import ru.ifmo.knim.main.MoveResult; 
13    
14   /** 
15    * An object that controls AI logics pipeline  
16    * @author Anthony Yakovlev 
17    */ 
18   public class AIObject implements ControlledObject { 
19        
20       /** 
21       *@unimod.action.descr begin optimal move selection 
22       */ 
23       public void z1(StateMachineContext context) { 
24           GamePlay.getGamePlay().aiStartup(); 
25           return; 
26       } 
27    
28       /** 
29       *@unimod.action.descr the check sum is being calculated to be used later to compare with zero to detect move type 
30       */ 
31       public int x1(StateMachineContext context) { 
32           Object object = context.getEventContext().getParameter("XORSumm"); 
33           return ((Integer) object).intValue(); 
34       } 
35    
36       /** 
37       *@unimod.action.descr perform a move using “safe” schema 
38       */ 
39       public void z2(StateMachineContext context) { 
40           GamePlay.getGamePlay().sendSafeMove(); 
41       } 
42    
43       /** 
44       *@unimod.action.descr perform a move using “dangerous” schema    
45       */ 
46       public void z3(StateMachineContext context) { 
47           GamePlay.getGamePlay().sendUnsafeMove(); 
48       } 
49    
50       /** 
51       *@unimod.action.descr Endgame 
52       */ 
53       public void z4(StateMachineContext context) { 
54           // fake by AY 
55           MoveResult move = new MoveResult(); 
56           move.isGameOver = true; 
57            
58           GamePlay.getGamePlay().resendMove(move); 
59       } 
60   } 
61