# HG changeset patch # User akhmetovlz # Date 1308470029 -14400 # Node ID 04ac70718172085d0f196ac5d386a77a5e3dbc87 # Parent 7b9682308866e9293a06a5188a53928e503ad327 переделка стратегий diff -r 7b9682308866 -r 04ac70718172 src/main/java/ru/alphatech/icfpc/policy/AbstractPolicy.java --- a/src/main/java/ru/alphatech/icfpc/policy/AbstractPolicy.java Sun Jun 19 11:53:33 2011 +0400 +++ b/src/main/java/ru/alphatech/icfpc/policy/AbstractPolicy.java Sun Jun 19 11:53:49 2011 +0400 @@ -1,35 +1,77 @@ package ru.alphatech.icfpc.policy; +import java.util.ArrayList; + +import ru.alphatech.icfpc.cards.Dbl; +import ru.alphatech.icfpc.cards.ICard; +import ru.alphatech.icfpc.cards.Put; +import ru.alphatech.icfpc.cards.Zero; +import ru.alphatech.icfpc.game.Batch; +import ru.alphatech.icfpc.game.IValue; import ru.alphatech.icfpc.game.Player; +import ru.alphatech.icfpc.game.Slot; +import ru.alphatech.icfpc.game.Value; +import ru.alphatech.icfpc.game.Batch.OperationType; public abstract class AbstractPolicy { protected Player player = null; - private int turnCount = 0; - private int turnCurrent = 0; + protected ArrayList batches = new ArrayList(); - public AbstractPolicy(int turnCount, Player player){ + public AbstractPolicy(Player player){ this.player = player; - this.turnCount = turnCount; - this.turnCurrent = 0; + } + + public void setRegister0( int num ){ + } - public int getCurrentTurns() { - return turnCurrent; + public void setRegister1( int num ){ + } - public int getTurnsCount(){ - return turnCount; + public void setRegister2( int num ){ + } - public boolean next(){ - if( turnCurrent < turnCount ){ - turnCurrent++; - return true; + protected ArrayList numberIntoSlotField(int slot, int number) + { + ArrayList retArray = new ArrayList(); + + Slot targetSlot = player.getSlot(slot); + IValue targetValue = targetSlot.getValue(); + + if(targetValue instanceof ICard){ + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), targetSlot)); } - return false; + + Value numTargetValue = (Value) targetValue; + if( numTargetValue.getValue() == number ){ + return retArray; + }else + if( numTargetValue.getValue() < number ){ + int buffValue = numTargetValue.getValue(); + while( buffValue*2 < number){ + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Dbl(), targetSlot)); + } + while( buffValue != number){ + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Dbl(), targetSlot)); + } + }else{ + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), targetSlot)); + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), targetSlot)); + int buffValue = numTargetValue.getValue(); + while( buffValue*2 < number){ + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Dbl(), targetSlot)); + } + while( buffValue != number){ + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Dbl(), targetSlot)); + } + } + + return retArray; + } - } diff -r 7b9682308866 -r 04ac70718172 src/main/java/ru/alphatech/icfpc/policy/VitalityBoostPolicy.java --- a/src/main/java/ru/alphatech/icfpc/policy/VitalityBoostPolicy.java Sun Jun 19 11:53:33 2011 +0400 +++ b/src/main/java/ru/alphatech/icfpc/policy/VitalityBoostPolicy.java Sun Jun 19 11:53:49 2011 +0400 @@ -1,52 +1,11 @@ package ru.alphatech.icfpc.policy; -import ru.alphatech.icfpc.cards.Dbl; -import ru.alphatech.icfpc.cards.Succ; -import ru.alphatech.icfpc.cards.Zero; import ru.alphatech.icfpc.game.Player; public class VitalityBoostPolicy extends AbstractPolicy { - - public static final int turnsCount = 100; - - public VitalityBoostPolicy(int targetSlot, Player player) { - super(turnsCount, player); - this.targetSlot = targetSlot; - - maxValueSlotNum = player.getStatistic().maxValueSlotNum; - maxValue = player.getStatistic().maxValue; - firstIdentitySlot = -1; + + public VitalityBoostPolicy(Player player) { + super(player); } - protected int targetSlot = -1; - protected int maxValueSlotNum = -1; - protected int maxValue = -1; - protected int firstIdentitySlot = -1; - - public boolean next() { - if ( super.next() ){ - - switch (getCurrentTurns()) { - case 0: - break; - case 1: - case 2: - break; - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - break; - case 11: - break; - } - - } - return false; - } - }