1 package ru.alphatech.icfpc.policy;
3 import java.util.ArrayList;
5 import ru.alphatech.icfpc.cards.Dec;
6 import ru.alphatech.icfpc.cards.Get;
7 import ru.alphatech.icfpc.cards.ICard;
8 import ru.alphatech.icfpc.cards.Inc;
9 import ru.alphatech.icfpc.cards.K;
10 import ru.alphatech.icfpc.cards.Put;
11 import ru.alphatech.icfpc.cards.S;
12 import ru.alphatech.icfpc.cards.Zero;
13 import ru.alphatech.icfpc.game.AbstractPolicy;
14 import ru.alphatech.icfpc.game.Batch;
15 import ru.alphatech.icfpc.game.IValue;
16 import ru.alphatech.icfpc.game.Run;
17 import ru.alphatech.icfpc.game.Slot;
18 import ru.alphatech.icfpc.game.Value;
19 import ru.alphatech.icfpc.game.Batch.OperationType;
21 public class DecIncPolicy extends AbstractPolicy{
29 private int processingSlotIndex = -1;
30 private int targetSlotIndex = -1;
33 public DecIncPolicy(TYPE type, int processingSlot, int target) {
35 this.processingSlotIndex = processingSlot;
36 this.targetSlotIndex = target;
39 public ICard getCard(){
40 return type == TYPE.DEC ? new Dec() : new Inc();
44 public ArrayList<Batch> getBatches() {
45 ArrayList<Batch> retArray = new ArrayList<Batch>();
47 retArray.addAll(numberIntoSlotField(Run.getRegisterByIndex(0), targetSlotIndex));
49 Slot processingSlot = Run.getProponent().getSlot(processingSlotIndex);
50 IValue slotValue = processingSlot.getValue();
52 if(slotValue instanceof Value){
53 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), processingSlot));
54 retArray.add(new Batch(OperationType.SLOT_TO_CARD, getCard(), processingSlot));
56 ICard currentCard = (ICard) slotValue;
57 if(!(currentCard instanceof Dec && type == TYPE.DEC) ||
58 !(currentCard instanceof Inc && type == TYPE.INC))
60 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), processingSlot));
61 retArray.add(new Batch(OperationType.SLOT_TO_CARD, getCard(), processingSlot));
65 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
66 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
68 retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
69 retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));