1.1 --- a/src/main/java/ru/alphatech/icfpc/policy/AbstractPolicy.java Sun Jun 19 11:53:33 2011 +0400
1.2 +++ b/src/main/java/ru/alphatech/icfpc/policy/AbstractPolicy.java Sun Jun 19 11:53:49 2011 +0400
1.3 @@ -1,35 +1,77 @@
1.4 package ru.alphatech.icfpc.policy;
1.5
1.6 +import java.util.ArrayList;
1.7 +
1.8 +import ru.alphatech.icfpc.cards.Dbl;
1.9 +import ru.alphatech.icfpc.cards.ICard;
1.10 +import ru.alphatech.icfpc.cards.Put;
1.11 +import ru.alphatech.icfpc.cards.Zero;
1.12 +import ru.alphatech.icfpc.game.Batch;
1.13 +import ru.alphatech.icfpc.game.IValue;
1.14 import ru.alphatech.icfpc.game.Player;
1.15 +import ru.alphatech.icfpc.game.Slot;
1.16 +import ru.alphatech.icfpc.game.Value;
1.17 +import ru.alphatech.icfpc.game.Batch.OperationType;
1.18
1.19 public abstract class AbstractPolicy {
1.20
1.21 protected Player player = null;
1.22
1.23 - private int turnCount = 0;
1.24 - private int turnCurrent = 0;
1.25 + protected ArrayList<Batch> batches = new ArrayList<Batch>();
1.26
1.27 - public AbstractPolicy(int turnCount, Player player){
1.28 + public AbstractPolicy(Player player){
1.29 this.player = player;
1.30 - this.turnCount = turnCount;
1.31 - this.turnCurrent = 0;
1.32 + }
1.33 +
1.34 + public void setRegister0( int num ){
1.35 +
1.36 }
1.37
1.38 - public int getCurrentTurns() {
1.39 - return turnCurrent;
1.40 + public void setRegister1( int num ){
1.41 +
1.42 }
1.43
1.44 - public int getTurnsCount(){
1.45 - return turnCount;
1.46 + public void setRegister2( int num ){
1.47 +
1.48 }
1.49
1.50 - public boolean next(){
1.51 - if( turnCurrent < turnCount ){
1.52 - turnCurrent++;
1.53 - return true;
1.54 + protected ArrayList<Batch> numberIntoSlotField(int slot, int number)
1.55 + {
1.56 + ArrayList<Batch> retArray = new ArrayList<Batch>();
1.57 +
1.58 + Slot targetSlot = player.getSlot(slot);
1.59 + IValue targetValue = targetSlot.getValue();
1.60 +
1.61 + if(targetValue instanceof ICard){
1.62 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), targetSlot));
1.63 }
1.64 - return false;
1.65 +
1.66 + Value numTargetValue = (Value) targetValue;
1.67 + if( numTargetValue.getValue() == number ){
1.68 + return retArray;
1.69 + }else
1.70 + if( numTargetValue.getValue() < number ){
1.71 + int buffValue = numTargetValue.getValue();
1.72 + while( buffValue*2 < number){
1.73 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Dbl(), targetSlot));
1.74 + }
1.75 + while( buffValue != number){
1.76 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Dbl(), targetSlot));
1.77 + }
1.78 + }else{
1.79 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), targetSlot));
1.80 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), targetSlot));
1.81 + int buffValue = numTargetValue.getValue();
1.82 + while( buffValue*2 < number){
1.83 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Dbl(), targetSlot));
1.84 + }
1.85 + while( buffValue != number){
1.86 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Dbl(), targetSlot));
1.87 + }
1.88 + }
1.89 +
1.90 + return retArray;
1.91 +
1.92 }
1.93
1.94 -
1.95 }
2.1 --- a/src/main/java/ru/alphatech/icfpc/policy/VitalityBoostPolicy.java Sun Jun 19 11:53:33 2011 +0400
2.2 +++ b/src/main/java/ru/alphatech/icfpc/policy/VitalityBoostPolicy.java Sun Jun 19 11:53:49 2011 +0400
2.3 @@ -1,52 +1,11 @@
2.4 package ru.alphatech.icfpc.policy;
2.5
2.6 -import ru.alphatech.icfpc.cards.Dbl;
2.7 -import ru.alphatech.icfpc.cards.Succ;
2.8 -import ru.alphatech.icfpc.cards.Zero;
2.9 import ru.alphatech.icfpc.game.Player;
2.10
2.11 public class VitalityBoostPolicy extends AbstractPolicy {
2.12 -
2.13 - public static final int turnsCount = 100;
2.14 -
2.15 - public VitalityBoostPolicy(int targetSlot, Player player) {
2.16 - super(turnsCount, player);
2.17 - this.targetSlot = targetSlot;
2.18 -
2.19 - maxValueSlotNum = player.getStatistic().maxValueSlotNum;
2.20 - maxValue = player.getStatistic().maxValue;
2.21 - firstIdentitySlot = -1;
2.22 +
2.23 + public VitalityBoostPolicy(Player player) {
2.24 + super(player);
2.25 }
2.26
2.27 - protected int targetSlot = -1;
2.28 - protected int maxValueSlotNum = -1;
2.29 - protected int maxValue = -1;
2.30 - protected int firstIdentitySlot = -1;
2.31 -
2.32 - public boolean next() {
2.33 - if ( super.next() ){
2.34 -
2.35 - switch (getCurrentTurns()) {
2.36 - case 0:
2.37 - break;
2.38 - case 1:
2.39 - case 2:
2.40 - break;
2.41 - case 3:
2.42 - case 4:
2.43 - case 5:
2.44 - case 6:
2.45 - case 7:
2.46 - case 8:
2.47 - case 9:
2.48 - case 10:
2.49 - break;
2.50 - case 11:
2.51 - break;
2.52 - }
2.53 -
2.54 - }
2.55 - return false;
2.56 - }
2.57 -
2.58 }