1 package ru.alphatech.icfpc.policy;
3 import java.util.ArrayList;
5 import ru.alphatech.icfpc.cards.Dbl;
6 import ru.alphatech.icfpc.cards.ICard;
7 import ru.alphatech.icfpc.cards.Put;
8 import ru.alphatech.icfpc.cards.Zero;
9 import ru.alphatech.icfpc.game.Batch;
10 import ru.alphatech.icfpc.game.IValue;
11 import ru.alphatech.icfpc.game.Player;
12 import ru.alphatech.icfpc.game.Slot;
13 import ru.alphatech.icfpc.game.Value;
14 import ru.alphatech.icfpc.game.Batch.OperationType;
16 public abstract class AbstractPolicy {
18 protected Player player = null;
20 protected ArrayList<Batch> batches = new ArrayList<Batch>();
22 public AbstractPolicy(Player player){
26 public void setRegister0( int num ){
30 public void setRegister1( int num ){
34 public void setRegister2( int num ){
38 protected ArrayList<Batch> numberIntoSlotField(int slot, int number)
40 ArrayList<Batch> retArray = new ArrayList<Batch>();
42 Slot targetSlot = player.getSlot(slot);
43 IValue targetValue = targetSlot.getValue();
45 if(targetValue instanceof ICard){
46 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), targetSlot));
49 Value numTargetValue = (Value) targetValue;
50 if( numTargetValue.getValue() == number ){
53 if( numTargetValue.getValue() < number ){
54 int buffValue = numTargetValue.getValue();
55 while( buffValue*2 < number){
56 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Dbl(), targetSlot));
58 while( buffValue != number){
59 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Dbl(), targetSlot));
62 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), targetSlot));
63 retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), targetSlot));
64 int buffValue = numTargetValue.getValue();
65 while( buffValue*2 < number){
66 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Dbl(), targetSlot));
68 while( buffValue != number){
69 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Dbl(), targetSlot));