1.1 --- a/src/main/java/ru/alphatech/icfpc/game/AbstractPolicy.java Sun Jun 19 18:55:47 2011 +0400
1.2 +++ b/src/main/java/ru/alphatech/icfpc/game/AbstractPolicy.java Sun Jun 19 19:13:42 2011 +0400
1.3 @@ -4,14 +4,9 @@
1.4 import java.util.Collections;
1.5 import java.util.List;
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 @@ -44,19 +39,17 @@
1.19 IValue targetValue = targetSlot.getValue();
1.20
1.21 if(targetValue instanceof ICard){
1.22 - retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), targetSlot));
1.23 - }
1.24 -
1.25 - Value numTargetValue = (Value) targetValue;
1.26 - if( numTargetValue.getValue() == number ){
1.27 - return retArray;
1.28 - }else
1.29 - if( numTargetValue.getValue() > number ){
1.30 - retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), targetSlot));
1.31 - retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), targetSlot));
1.32 - stupidAlg(0, number, targetSlot);
1.33 + retArray.addAll(smartAlg(0, number, targetSlot));
1.34 }else{
1.35 - stupidAlg(numTargetValue.getValue(), number, targetSlot);
1.36 + Value numTargetValue = (Value) targetValue;
1.37 + if( numTargetValue.getValue() == number ){
1.38 + return retArray;
1.39 + }else
1.40 + if( numTargetValue.getValue() > number ){
1.41 + retArray.addAll( smartAlg(0, number, targetSlot) );
1.42 + }else{
1.43 + retArray.addAll( smartAlg(numTargetValue.getValue(), number, targetSlot) );
1.44 + }
1.45 }
1.46
1.47 return retArray;
1.48 @@ -78,8 +71,12 @@
1.49
1.50 protected static List<Batch> smartAlg(int begin, int end, Slot targetSlot){
1.51 ArrayList<Batch> retArray = new ArrayList<Batch>();
1.52 - retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), targetSlot));
1.53 - retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), targetSlot));
1.54 +
1.55 + if(begin == 0){
1.56 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), targetSlot));
1.57 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), targetSlot));
1.58 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Succ(), targetSlot));
1.59 + }
1.60
1.61 List<Batch> list1 = buildNumberOperations(0, end, targetSlot);
1.62 List<Batch> list2 = buildNumberOperations(begin, end, targetSlot);
1.63 @@ -126,7 +123,7 @@
1.64 public static void main(String[] args)
1.65 {
1.66 Slot slot = new Slot(1);
1.67 - List<Batch> list = smartAlg(5, 12, slot);
1.68 + List<Batch> list = smartAlg(0, 8, slot);
1.69 System.out.println(list.toArray().toString());
1.70 }
1.71 }
2.1 --- a/src/main/java/ru/alphatech/icfpc/game/Run.java Sun Jun 19 18:55:47 2011 +0400
2.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Run.java Sun Jun 19 19:13:42 2011 +0400
2.3 @@ -6,6 +6,7 @@
2.4 package ru.alphatech.icfpc.game;
2.5
2.6 import java.io.BufferedReader;
2.7 +import java.io.File;
2.8 import java.io.IOException;
2.9 import java.io.InputStreamReader;
2.10
3.1 --- a/src/main/java/ru/alphatech/icfpc/game/strategy/SimplyStrategy.java Sun Jun 19 18:55:47 2011 +0400
3.2 +++ b/src/main/java/ru/alphatech/icfpc/game/strategy/SimplyStrategy.java Sun Jun 19 19:13:42 2011 +0400
3.3 @@ -1,9 +1,11 @@
3.4 package ru.alphatech.icfpc.game.strategy;
3.5
3.6 -import static ru.alphatech.icfpc.game.Batch.OperationType.CARD_TO_SLOT;
3.7 -import ru.alphatech.icfpc.cards.I;
3.8 +import java.util.LinkedList;
3.9 +
3.10 import ru.alphatech.icfpc.game.Batch;
3.11 import ru.alphatech.icfpc.game.Player;
3.12 +import ru.alphatech.icfpc.policy.AttackHelpPolicy;
3.13 +import ru.alphatech.icfpc.policy.AttackHelpPolicy.TYPE;
3.14
3.15 /**
3.16 * @author indvdum
3.17 @@ -12,10 +14,17 @@
3.18 */
3.19 public class SimplyStrategy implements IStrategy {
3.20
3.21 + LinkedList<Batch> batches = new LinkedList<Batch>();
3.22 +
3.23 + public SimplyStrategy() {
3.24 + for(int i=0; i<100; ++i){
3.25 + batches.addAll(new AttackHelpPolicy(TYPE.HELP, 10, 5, 5, 9999, true).getBatches());
3.26 + }
3.27 + }
3.28 +
3.29 @Override
3.30 public Batch move(Player proponent, Player opponent) {
3.31 - Batch batch = new Batch(CARD_TO_SLOT, new I(), opponent.getSlot(0));
3.32 - return batch;
3.33 + return batches.poll();//new Batch(OperationType.CARD_TO_SLOT, new I(), proponent.getSlot(0));//batches.poll();
3.34 }
3.35
3.36 }
4.1 --- a/src/main/java/ru/alphatech/icfpc/policy/AttackHelpPolicy.java Sun Jun 19 18:55:47 2011 +0400
4.2 +++ b/src/main/java/ru/alphatech/icfpc/policy/AttackHelpPolicy.java Sun Jun 19 19:13:42 2011 +0400
4.3 @@ -24,6 +24,7 @@
4.4 private int targetSlotIndex = -1;
4.5 private int pointsSlotIndex = -1;
4.6 private int processingSlotIndex = -1;
4.7 + private boolean execute = false;
4.8
4.9 private TYPE type;
4.10
4.11 @@ -33,17 +34,19 @@
4.12 }
4.13
4.14 /**
4.15 - *
4.16 + * @param type - ATTACK or HELP
4.17 * @param processingSlot - в какой ячейке проводить
4.18 * @param donor - от кого забирать хп
4.19 * @param target - слот который надо атаковать
4.20 * @param points - количество хп отнимаемое у донора
4.21 + * @param execute - выполнить после завершения либо просто сохранить в слоте.
4.22 */
4.23 - public AttackHelpPolicy(TYPE type, int processingSlot, int donor, int target, int points) {
4.24 + public AttackHelpPolicy(TYPE type, int processingSlot, int donor, int target, int points, boolean execute) {
4.25 this.donorSlotIndex = donor;
4.26 this.targetSlotIndex = target;
4.27 this.pointsSlotIndex = points;
4.28 this.processingSlotIndex = processingSlot;
4.29 + this.execute = execute;
4.30
4.31 this.type = type;
4.32 }
4.33 @@ -54,9 +57,9 @@
4.34
4.35 Slot processingSlot = Run.getProponent().getSlot(processingSlotIndex);
4.36
4.37 - numberIntoSlotField(Run.getRegisterByIndex(0), donorSlotIndex);
4.38 - numberIntoSlotField(Run.getRegisterByIndex(1), targetSlotIndex);
4.39 - numberIntoSlotField(Run.getRegisterByIndex(2), pointsSlotIndex);
4.40 + retArray.addAll(numberIntoSlotField(Run.getRegisterByIndex(0), donorSlotIndex));
4.41 + retArray.addAll(numberIntoSlotField(Run.getRegisterByIndex(1), targetSlotIndex));
4.42 + retArray.addAll(numberIntoSlotField(Run.getRegisterByIndex(2), pointsSlotIndex));
4.43
4.44 retArray.addAll(BcombineForFunctWith3ParamsInRegister(getCard(), processingSlot));
4.45
4.46 @@ -82,9 +85,6 @@
4.47 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
4.48
4.49 retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
4.50 -
4.51 - retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
4.52 - retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
4.53
4.54 retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
4.55
4.56 @@ -98,9 +98,6 @@
4.57
4.58 retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Succ(), processingSlot));
4.59
4.60 - retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
4.61 - retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
4.62 -
4.63 retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
4.64
4.65 retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
4.66 @@ -118,10 +115,8 @@
4.67
4.68 retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Succ(), processingSlot));
4.69
4.70 - retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
4.71 - retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
4.72 -
4.73 - retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
4.74 + if(execute)
4.75 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
4.76
4.77 return retArray;
4.78 }