1.1 --- a/src/main/java/ru/alphatech/icfpc/policy/DecIncPolicy.java Sun Jun 19 17:12:05 2011 +0400
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,74 +0,0 @@
1.4 -package ru.alphatech.icfpc.policy;
1.5 -
1.6 -import java.util.ArrayList;
1.7 -
1.8 -import ru.alphatech.icfpc.cards.Dec;
1.9 -import ru.alphatech.icfpc.cards.Get;
1.10 -import ru.alphatech.icfpc.cards.ICard;
1.11 -import ru.alphatech.icfpc.cards.Inc;
1.12 -import ru.alphatech.icfpc.cards.K;
1.13 -import ru.alphatech.icfpc.cards.Put;
1.14 -import ru.alphatech.icfpc.cards.S;
1.15 -import ru.alphatech.icfpc.cards.Zero;
1.16 -import ru.alphatech.icfpc.game.AbstractPolicy;
1.17 -import ru.alphatech.icfpc.game.Batch;
1.18 -import ru.alphatech.icfpc.game.IValue;
1.19 -import ru.alphatech.icfpc.game.Run;
1.20 -import ru.alphatech.icfpc.game.Slot;
1.21 -import ru.alphatech.icfpc.game.Value;
1.22 -import ru.alphatech.icfpc.game.Batch.OperationType;
1.23 -
1.24 -public class DecIncPolicy extends AbstractPolicy{
1.25 -
1.26 - public enum TYPE {
1.27 - DEC,
1.28 - INC
1.29 - }
1.30 -
1.31 - private TYPE type;
1.32 - private int processingSlotIndex = -1;
1.33 - private int targetSlotIndex = -1;
1.34 -
1.35 -
1.36 - public DecIncPolicy(TYPE type, int processingSlot, int target) {
1.37 - this.type = type;
1.38 - this.processingSlotIndex = processingSlot;
1.39 - this.targetSlotIndex = target;
1.40 - }
1.41 -
1.42 - public ICard getCard(){
1.43 - return type == TYPE.DEC ? new Dec() : new Inc();
1.44 - }
1.45 -
1.46 - @Override
1.47 - public ArrayList<Batch> getBatches() {
1.48 - ArrayList<Batch> retArray = new ArrayList<Batch>();
1.49 -
1.50 - retArray.addAll(numberIntoSlotField(Run.getRegisterByIndex(0), targetSlotIndex));
1.51 -
1.52 - Slot processingSlot = Run.getProponent().getSlot(processingSlotIndex);
1.53 - IValue slotValue = processingSlot.getValue();
1.54 -
1.55 - if(slotValue instanceof Value){
1.56 - retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), processingSlot));
1.57 - retArray.add(new Batch(OperationType.SLOT_TO_CARD, getCard(), processingSlot));
1.58 - }else{
1.59 - ICard currentCard = (ICard) slotValue;
1.60 - if(!(currentCard instanceof Dec && type == TYPE.DEC) ||
1.61 - !(currentCard instanceof Inc && type == TYPE.INC))
1.62 - {
1.63 - retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), processingSlot));
1.64 - retArray.add(new Batch(OperationType.SLOT_TO_CARD, getCard(), processingSlot));
1.65 - }
1.66 - }
1.67 -
1.68 - retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
1.69 - retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
1.70 -
1.71 - retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
1.72 - retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
1.73 -
1.74 - return retArray;
1.75 - }
1.76 -
1.77 -}