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 }