1.1 --- a/src/main/java/ru/alphatech/icfpc/game/AbstractPolicy.java Sun Jun 19 14:29:38 2011 +0400
1.2 +++ b/src/main/java/ru/alphatech/icfpc/game/AbstractPolicy.java Sun Jun 19 14:30:33 2011 +0400
1.3 @@ -2,9 +2,14 @@
1.4
1.5 import java.util.ArrayList;
1.6
1.7 +import ru.alphatech.icfpc.cards.Attack;
1.8 import ru.alphatech.icfpc.cards.Dbl;
1.9 +import ru.alphatech.icfpc.cards.Get;
1.10 +import ru.alphatech.icfpc.cards.Help;
1.11 import ru.alphatech.icfpc.cards.ICard;
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.Succ;
1.16 import ru.alphatech.icfpc.cards.Zero;
1.17 import ru.alphatech.icfpc.game.Batch.OperationType;
1.18 @@ -86,5 +91,63 @@
1.19 return retArray;
1.20 }
1.21
1.22 + protected ArrayList<Batch> BcombineForFunctWith3ParamsInRegister(ICard function, Slot processingSlot){
1.23 + ArrayList<Batch> retArray = new ArrayList<Batch>();
1.24 +
1.25 + if(!(function instanceof Attack || function instanceof Help)){
1.26 + throw new ICFPCException();
1.27 + }
1.28 +
1.29 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), processingSlot));
1.30 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, function, processingSlot));
1.31 +
1.32 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
1.33 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
1.34 +
1.35 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
1.36 +
1.37 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
1.38 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
1.39 +
1.40 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
1.41 +
1.42 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
1.43 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
1.44 +
1.45 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
1.46 +
1.47 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
1.48 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
1.49 +
1.50 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Succ(), processingSlot));
1.51 +
1.52 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
1.53 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
1.54 +
1.55 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
1.56 +
1.57 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
1.58 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
1.59 +
1.60 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
1.61 +
1.62 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
1.63 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
1.64 +
1.65 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Succ(), processingSlot));
1.66 +
1.67 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
1.68 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
1.69 +
1.70 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Succ(), processingSlot));
1.71 +
1.72 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
1.73 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
1.74 +
1.75 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
1.76 +
1.77 + return retArray;
1.78 + }
1.79 +
1.80 public abstract ArrayList<Batch> getBatches();
1.81 }
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/src/main/java/ru/alphatech/icfpc/policy/AttackPolicy.java Sun Jun 19 14:30:33 2011 +0400
2.3 @@ -0,0 +1,42 @@
2.4 +package ru.alphatech.icfpc.policy;
2.5 +
2.6 +import java.util.ArrayList;
2.7 +
2.8 +import ru.alphatech.icfpc.cards.Attack;
2.9 +import ru.alphatech.icfpc.game.AbstractPolicy;
2.10 +import ru.alphatech.icfpc.game.Batch;
2.11 +import ru.alphatech.icfpc.game.Run;
2.12 +import ru.alphatech.icfpc.game.Slot;
2.13 +
2.14 +public class AttackPolicy extends AbstractPolicy {
2.15 +
2.16 + private int donorSlotIndex = -1;
2.17 + private int targetSlotIndex = -1;
2.18 + private int pointsSlotIndex = -1;
2.19 + private int processingSlotIndex = -1;
2.20 +
2.21 + public AttackPolicy(int processingSlot, int donor, int target, int points) {
2.22 + this.donorSlotIndex = donor;
2.23 + this.targetSlotIndex = target;
2.24 + this.pointsSlotIndex = points;
2.25 + this.processingSlotIndex = processingSlot;
2.26 + }
2.27 +
2.28 + @Override
2.29 + public ArrayList<Batch> getBatches() {
2.30 + ArrayList<Batch> retArray = new ArrayList<Batch>();
2.31 +
2.32 + Slot processingSlot = Run.getProponent().getSlot(processingSlotIndex);
2.33 +
2.34 + numberIntoSlotField(Run.getRegisterByIndex(0), donorSlotIndex);
2.35 + numberIntoSlotField(Run.getRegisterByIndex(1), targetSlotIndex);
2.36 + numberIntoSlotField(Run.getRegisterByIndex(2), pointsSlotIndex);
2.37 +
2.38 + retArray.addAll(BcombineForFunctWith3ParamsInRegister(new Attack(), processingSlot));
2.39 +
2.40 + return retArray;
2.41 + }
2.42 +
2.43 +
2.44 +
2.45 +}