1 package ru.alphatech.icfpc.game;
3 import java.util.ArrayList;
5 import ru.alphatech.icfpc.cards.Attack;
6 import ru.alphatech.icfpc.cards.Dbl;
7 import ru.alphatech.icfpc.cards.Get;
8 import ru.alphatech.icfpc.cards.Help;
9 import ru.alphatech.icfpc.cards.ICard;
10 import ru.alphatech.icfpc.cards.K;
11 import ru.alphatech.icfpc.cards.Put;
12 import ru.alphatech.icfpc.cards.S;
13 import ru.alphatech.icfpc.cards.Succ;
14 import ru.alphatech.icfpc.cards.Zero;
15 import ru.alphatech.icfpc.game.Batch.OperationType;
24 public abstract class AbstractPolicy {
26 protected ArrayList<Batch> batches = new ArrayList<Batch>();
28 public AbstractPolicy(){
31 public void setRegister(int registerIndex, int num ){
32 if( registerIndex < 4) {
33 Slot registerSlot = Run.getRegisterByIndex(registerIndex);
34 batches.addAll( numberIntoSlotField( registerSlot, num ) );
38 protected ArrayList<Batch> numberIntoSlotField(Slot targetSlot, int number)
40 ArrayList<Batch> retArray = new ArrayList<Batch>();
42 IValue targetValue = targetSlot.getValue();
44 if(targetValue instanceof ICard){
45 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), targetSlot));
48 Value numTargetValue = (Value) targetValue;
49 if( numTargetValue.getValue() == number ){
52 if( numTargetValue.getValue() > number ){
53 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), targetSlot));
54 retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), targetSlot));
55 stupidAlg(0, number, targetSlot);
57 stupidAlg(numTargetValue.getValue(), number, targetSlot);
64 protected ArrayList<Batch> stupidAlg(int begin, int end, Slot targetSlot){
65 ArrayList<Batch> retArray = new ArrayList<Batch>();
66 while( begin*2 < end){
67 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Dbl(), targetSlot));
71 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Succ(), targetSlot));
77 protected ArrayList<Batch> smartAlg(int begin, int end, Slot targetSlot){
78 ArrayList<Batch> retArray = new ArrayList<Batch>();
79 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), targetSlot));
80 retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), targetSlot));
84 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Dbl() , targetSlot));
86 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Dbl() , targetSlot));
87 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Succ(), targetSlot));
94 public abstract ArrayList<Batch> getBatches();