1 package ru.alphatech.icfpc.policy;
3 import java.util.ArrayList;
5 import ru.alphatech.icfpc.cards.Attack;
6 import ru.alphatech.icfpc.cards.Get;
7 import ru.alphatech.icfpc.cards.Help;
8 import ru.alphatech.icfpc.cards.ICard;
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.Succ;
13 import ru.alphatech.icfpc.cards.Zero;
14 import ru.alphatech.icfpc.game.AbstractPolicy;
15 import ru.alphatech.icfpc.game.Batch;
16 import ru.alphatech.icfpc.game.ICFPCException;
17 import ru.alphatech.icfpc.game.Run;
18 import ru.alphatech.icfpc.game.Slot;
19 import ru.alphatech.icfpc.game.Batch.OperationType;
21 public class AttackHelpPolicy extends AbstractPolicy {
23 private int donorSlotIndex = -1;
24 private int targetSlotIndex = -1;
25 private int pointsSlotIndex = -1;
26 private int processingSlotIndex = -1;
38 * @param type - ATTACK or HELP
39 * @param processingSlot - в какой ячейке проводить
40 * @param donor - от кого забирать хп
41 * @param target - слот который надо атаковать
42 * @param points - количество хп отнимаемое у донора
44 public AttackHelpPolicy(TYPE type, int processingSlot, int donor, int target, int points) {
45 this.donorSlotIndex = donor;
46 this.targetSlotIndex = target;
47 this.pointsSlotIndex = points;
48 this.processingSlotIndex = processingSlot;
53 protected ArrayList<Batch> registerChangingBatches(Slot processingSlot){
54 ArrayList<Batch> retArray = new ArrayList<Batch>();
55 retArray.addAll(numberIntoSlotField(Run.getRegisterByIndex(2), pointsSlotIndex));
60 public ArrayList<Batch> getBatches() {
61 ArrayList<Batch> retArray = new ArrayList<Batch>();
63 Slot processingSlot = Run.getProponent().getSlot(processingSlotIndex);
65 retArray.addAll(numberIntoSlotField(Run.getRegisterByIndex(0), donorSlotIndex));
66 retArray.addAll(numberIntoSlotField(Run.getRegisterByIndex(1), targetSlotIndex));
68 retArray.addAll(registerChangingBatches(processingSlot));
70 // retArray.addAll(BcombineForFunctWith3ParamsInRegister(getCard(), processingSlot));
71 retArray.addAll(BcombineForFunctWith3ParamsInRegister2(getCard(), processingSlot));
76 public ICard getCard(){
77 return type == TYPE.ATTACK ? new Attack() : new Help();
80 protected int get3thRegisterIndex(){
84 protected boolean execute(){
90 * С корректировкой регистров
92 * @param processingSlot
95 protected ArrayList<Batch> BcombineForFunctWith3ParamsInRegister2(ICard function, Slot processingSlot)
97 ArrayList<Batch> retArray = new ArrayList<Batch>();
99 if(!(function instanceof Attack || function instanceof Help)){
100 throw new ICFPCException();
103 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), processingSlot));
104 retArray.add(new Batch(OperationType.SLOT_TO_CARD, function, processingSlot));
106 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
107 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
109 retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
111 retArray.addAll(correctRegister(0, processingSlot));
113 retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
115 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
116 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
118 retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
120 retArray.addAll(correctRegister(1, processingSlot));
122 retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
124 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
125 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
127 retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
129 retArray.addAll(correctRegister(get3thRegisterIndex(), processingSlot));
131 retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));