diff -r 743564afa994 -r 5b57bc39cc92 src/main/java/ru/alphatech/icfpc/policy/AbstractPolicy.java --- a/src/main/java/ru/alphatech/icfpc/policy/AbstractPolicy.java Sun Jun 19 12:12:55 2011 +0400 +++ b/src/main/java/ru/alphatech/icfpc/policy/AbstractPolicy.java Sun Jun 19 12:13:34 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; + } - }