1.1 --- a/src/main/java/ru/alphatech/icfpc/game/Run.java Sun Jun 19 20:48:53 2011 +0400
1.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Run.java Sun Jun 19 21:15:49 2011 +0400
1.3 @@ -29,6 +29,7 @@
1.4 import ru.alphatech.icfpc.game.Batch.OperationType;
1.5 import ru.alphatech.icfpc.game.strategy.IStrategy;
1.6 import ru.alphatech.icfpc.game.strategy.SimplyStrategy;
1.7 +import ru.alphatech.icfpc.game.strategy.YetAnotherStrategy;
1.8
1.9 public class Run
1.10 {
1.11 @@ -53,7 +54,7 @@
1.12 registers[3] = 3;
1.13 }
1.14
1.15 - private static IStrategy strategy = new SimplyStrategy();
1.16 + private static IStrategy strategy = new YetAnotherStrategy();
1.17
1.18 public static Slot getRegisterByIndex(int registerIndex){
1.19 return proponent.getSlot( registers[registerIndex] );
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/src/main/java/ru/alphatech/icfpc/game/strategy/YetAnotherStrategy.java Sun Jun 19 21:15:49 2011 +0400
2.3 @@ -0,0 +1,53 @@
2.4 +package ru.alphatech.icfpc.game.strategy;
2.5 +
2.6 +import java.util.LinkedList;
2.7 +import java.util.Queue;
2.8 +
2.9 +import ru.alphatech.icfpc.game.Batch;
2.10 +import ru.alphatech.icfpc.game.Player;
2.11 +import ru.alphatech.icfpc.policy.AttackHelpPolicy;
2.12 +import ru.alphatech.icfpc.policy.CallExpressionPolicy;
2.13 +
2.14 +public class YetAnotherStrategy implements IStrategy {
2.15 +
2.16 + private static Queue<Batch> batches = new LinkedList<Batch>();
2.17 + private int lastUsedDefaultSlot = 10;
2.18 + private int lastUsedSlot = lastUsedDefaultSlot;
2.19 + private int lastAttackedDefaultSlot = 0;
2.20 + private int lastAttackedSlot = lastAttackedDefaultSlot;
2.21 + AttackHelpPolicy helpPolicy = null;
2.22 + AttackHelpPolicy attackPolicy = null;
2.23 + CallExpressionPolicy callAttack = null;
2.24 +
2.25 + public YetAnotherStrategy(){
2.26 + helpPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.HELP, lastUsedSlot++, 8, 6, 5000, true);
2.27 + attackPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.ATTACK, 5, 6, lastAttackedSlot++, 9000, false);
2.28 + callAttack = new CallExpressionPolicy(9, 5, 0, true);
2.29 + batches.addAll(helpPolicy.getBatches());
2.30 + batches.addAll(attackPolicy.getBatches());
2.31 + batches.addAll(callAttack.getBatches());
2.32 +
2.33 + }
2.34 +
2.35 + @Override
2.36 + public Batch move(Player proponent, Player opponent) {
2.37 + if(lastAttackedSlot > 254)
2.38 + lastAttackedSlot = lastAttackedDefaultSlot;
2.39 + if(lastUsedSlot > 254)
2.40 + lastUsedSlot = lastUsedDefaultSlot;
2.41 + if(opponent.getSlot(lastAttackedSlot-1).getVitality() <= 0){
2.42 + batches.clear();
2.43 + attackPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.ATTACK, 5, 6, lastAttackedSlot++, 10000, false);
2.44 + callAttack = new CallExpressionPolicy(9, 5, 0, true);
2.45 + batches.addAll(attackPolicy.getBatches());
2.46 + batches.addAll(callAttack.getBatches());
2.47 + }
2.48 + if(!batches.isEmpty())
2.49 + return batches.poll();
2.50 + AttackHelpPolicy helpPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.HELP, lastUsedSlot++, 8, 6, 5000, true);
2.51 + batches.addAll(helpPolicy.getBatches());
2.52 + batches.addAll(callAttack.getBatches());
2.53 + return move(proponent, opponent);
2.54 + }
2.55 +
2.56 +}