1.1 --- a/src/main/java/ru/alphatech/icfpc/game/AbstractPolicy.java Sun Jun 19 21:18:00 2011 +0400
1.2 +++ b/src/main/java/ru/alphatech/icfpc/game/AbstractPolicy.java Sun Jun 19 22:41:13 2011 +0400
1.3 @@ -6,7 +6,9 @@
1.4
1.5 import ru.alphatech.icfpc.cards.Dbl;
1.6 import ru.alphatech.icfpc.cards.ICard;
1.7 +import ru.alphatech.icfpc.cards.K;
1.8 import ru.alphatech.icfpc.cards.Put;
1.9 +import ru.alphatech.icfpc.cards.S;
1.10 import ru.alphatech.icfpc.cards.Succ;
1.11 import ru.alphatech.icfpc.cards.Zero;
1.12 import ru.alphatech.icfpc.game.Batch.OperationType;
1.13 @@ -118,6 +120,26 @@
1.14 return list;
1.15 }
1.16
1.17 + /**
1.18 + * Корректировка позиций регистров
1.19 + * В самом лучшем случаи регистры это слоты 0 1 2 3
1.20 + * Но могут быть изменены, этот метод корректирует ссылки на регистры в полтиках
1.21 + * @param registerIndex - индекс регитсра (не слота!)
1.22 + * @param processingSlot - слот где происходит рассчёт
1.23 + * @return
1.24 + */
1.25 + protected ArrayList<Batch> correctRegister(int registerIndex, Slot processingSlot){
1.26 + ArrayList<Batch> retArray = new ArrayList<Batch>();
1.27 + for(int i=0; i<Run.getRegisterSlotNum(0); ++i)
1.28 + {
1.29 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
1.30 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
1.31 +
1.32 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Succ(), processingSlot));
1.33 + }
1.34 + return retArray;
1.35 + }
1.36 +
1.37 public abstract ArrayList<Batch> getBatches();
1.38
1.39 public static void main(String[] args)
2.1 --- a/src/main/java/ru/alphatech/icfpc/policy/AttackHelpPolicy.java Sun Jun 19 21:18:00 2011 +0400
2.2 +++ b/src/main/java/ru/alphatech/icfpc/policy/AttackHelpPolicy.java Sun Jun 19 22:41:13 2011 +0400
2.3 @@ -61,7 +61,8 @@
2.4 retArray.addAll(numberIntoSlotField(Run.getRegisterByIndex(1), targetSlotIndex));
2.5 retArray.addAll(numberIntoSlotField(Run.getRegisterByIndex(2), pointsSlotIndex));
2.6
2.7 - retArray.addAll(BcombineForFunctWith3ParamsInRegister(getCard(), processingSlot));
2.8 +// retArray.addAll(BcombineForFunctWith3ParamsInRegister(getCard(), processingSlot));
2.9 + retArray.addAll(BcombineForFunctWith3ParamsInRegister2(getCard(), processingSlot));
2.10
2.11 return retArray;
2.12 }
2.13 @@ -70,6 +71,62 @@
2.14 return type == TYPE.ATTACK ? new Attack() : new Help();
2.15 }
2.16
2.17 +
2.18 +
2.19 + /**
2.20 + * С корректировкой регистров
2.21 + * @param function
2.22 + * @param processingSlot
2.23 + * @return
2.24 + */
2.25 + protected ArrayList<Batch> BcombineForFunctWith3ParamsInRegister2(ICard function, Slot processingSlot)
2.26 + {
2.27 + ArrayList<Batch> retArray = new ArrayList<Batch>();
2.28 +
2.29 + if(!(function instanceof Attack || function instanceof Help)){
2.30 + throw new ICFPCException();
2.31 + }
2.32 +
2.33 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), processingSlot));
2.34 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, function, processingSlot));
2.35 +
2.36 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
2.37 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
2.38 +
2.39 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
2.40 +
2.41 + retArray.addAll(correctRegister(0, processingSlot));
2.42 +
2.43 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
2.44 +
2.45 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
2.46 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
2.47 +
2.48 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
2.49 +
2.50 + retArray.addAll(correctRegister(1, processingSlot));
2.51 +
2.52 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
2.53 +
2.54 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
2.55 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
2.56 +
2.57 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
2.58 +
2.59 + retArray.addAll(correctRegister(2, processingSlot));
2.60 +
2.61 + if(execute)
2.62 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
2.63 +
2.64 + return retArray;
2.65 + }
2.66 +
2.67 + /***
2.68 + * @deprecated
2.69 + * @param function
2.70 + * @param processingSlot
2.71 + * @return
2.72 + */
2.73 protected ArrayList<Batch> BcombineForFunctWith3ParamsInRegister(ICard function, Slot processingSlot)
2.74 {
2.75 ArrayList<Batch> retArray = new ArrayList<Batch>();
2.76 @@ -78,8 +135,6 @@
2.77 throw new ICFPCException();
2.78 }
2.79
2.80 - //TODO Абстрагироваться от регистров
2.81 -
2.82 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), processingSlot));
2.83 retArray.add(new Batch(OperationType.SLOT_TO_CARD, function, processingSlot));
2.84
2.85 @@ -122,6 +177,4 @@
2.86
2.87 return retArray;
2.88 }
2.89 -
2.90 -
2.91 }