1.1 --- a/src/main/java/ru/alphatech/icfpc/policy/DecIncPolicy.java Sun Jun 19 17:12:05 2011 +0400
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,74 +0,0 @@
1.4 -package ru.alphatech.icfpc.policy;
1.5 -
1.6 -import java.util.ArrayList;
1.7 -
1.8 -import ru.alphatech.icfpc.cards.Dec;
1.9 -import ru.alphatech.icfpc.cards.Get;
1.10 -import ru.alphatech.icfpc.cards.ICard;
1.11 -import ru.alphatech.icfpc.cards.Inc;
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.Zero;
1.16 -import ru.alphatech.icfpc.game.AbstractPolicy;
1.17 -import ru.alphatech.icfpc.game.Batch;
1.18 -import ru.alphatech.icfpc.game.IValue;
1.19 -import ru.alphatech.icfpc.game.Run;
1.20 -import ru.alphatech.icfpc.game.Slot;
1.21 -import ru.alphatech.icfpc.game.Value;
1.22 -import ru.alphatech.icfpc.game.Batch.OperationType;
1.23 -
1.24 -public class DecIncPolicy extends AbstractPolicy{
1.25 -
1.26 - public enum TYPE {
1.27 - DEC,
1.28 - INC
1.29 - }
1.30 -
1.31 - private TYPE type;
1.32 - private int processingSlotIndex = -1;
1.33 - private int targetSlotIndex = -1;
1.34 -
1.35 -
1.36 - public DecIncPolicy(TYPE type, int processingSlot, int target) {
1.37 - this.type = type;
1.38 - this.processingSlotIndex = processingSlot;
1.39 - this.targetSlotIndex = target;
1.40 - }
1.41 -
1.42 - public ICard getCard(){
1.43 - return type == TYPE.DEC ? new Dec() : new Inc();
1.44 - }
1.45 -
1.46 - @Override
1.47 - public ArrayList<Batch> getBatches() {
1.48 - ArrayList<Batch> retArray = new ArrayList<Batch>();
1.49 -
1.50 - retArray.addAll(numberIntoSlotField(Run.getRegisterByIndex(0), targetSlotIndex));
1.51 -
1.52 - Slot processingSlot = Run.getProponent().getSlot(processingSlotIndex);
1.53 - IValue slotValue = processingSlot.getValue();
1.54 -
1.55 - if(slotValue instanceof Value){
1.56 - retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), processingSlot));
1.57 - retArray.add(new Batch(OperationType.SLOT_TO_CARD, getCard(), processingSlot));
1.58 - }else{
1.59 - ICard currentCard = (ICard) slotValue;
1.60 - if(!(currentCard instanceof Dec && type == TYPE.DEC) ||
1.61 - !(currentCard instanceof Inc && type == TYPE.INC))
1.62 - {
1.63 - retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), processingSlot));
1.64 - retArray.add(new Batch(OperationType.SLOT_TO_CARD, getCard(), processingSlot));
1.65 - }
1.66 - }
1.67 -
1.68 - retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
1.69 - retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
1.70 -
1.71 - retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
1.72 - retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
1.73 -
1.74 - return retArray;
1.75 - }
1.76 -
1.77 -}
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/src/main/java/ru/alphatech/icfpc/policy/OneArgumentCardsPolicy.java Sun Jun 19 17:13:33 2011 +0400
2.3 @@ -0,0 +1,103 @@
2.4 +package ru.alphatech.icfpc.policy;
2.5 +
2.6 +import java.util.ArrayList;
2.7 +
2.8 +import ru.alphatech.icfpc.cards.Copy;
2.9 +import ru.alphatech.icfpc.cards.Dec;
2.10 +import ru.alphatech.icfpc.cards.Get;
2.11 +import ru.alphatech.icfpc.cards.ICard;
2.12 +import ru.alphatech.icfpc.cards.Inc;
2.13 +import ru.alphatech.icfpc.cards.K;
2.14 +import ru.alphatech.icfpc.cards.Put;
2.15 +import ru.alphatech.icfpc.cards.Revive;
2.16 +import ru.alphatech.icfpc.cards.S;
2.17 +import ru.alphatech.icfpc.cards.Zero;
2.18 +import ru.alphatech.icfpc.game.AbstractPolicy;
2.19 +import ru.alphatech.icfpc.game.Batch;
2.20 +import ru.alphatech.icfpc.game.IValue;
2.21 +import ru.alphatech.icfpc.game.Run;
2.22 +import ru.alphatech.icfpc.game.Slot;
2.23 +import ru.alphatech.icfpc.game.Value;
2.24 +import ru.alphatech.icfpc.game.Batch.OperationType;
2.25 +
2.26 +public class OneArgumentCardsPolicy extends AbstractPolicy{
2.27 +
2.28 + public enum TYPE {
2.29 + DEC,
2.30 + INC,
2.31 + COPY,
2.32 + REVIVE
2.33 + }
2.34 +
2.35 + private TYPE type;
2.36 + private int processingSlotIndex = -1;
2.37 + private int registerIndex = -1;
2.38 + private int targetSlotIndex = -1;
2.39 +
2.40 +
2.41 + public OneArgumentCardsPolicy(TYPE type, int processingSlot, int target) {
2.42 + this.type = type;
2.43 + this.processingSlotIndex = processingSlot;
2.44 + this.targetSlotIndex = target;
2.45 + }
2.46 +
2.47 + public ICard getCard(){
2.48 + switch (type) {
2.49 + case DEC:
2.50 + return new Dec();
2.51 + case INC:
2.52 + return new Inc();
2.53 + case COPY:
2.54 + return new Copy();
2.55 + case REVIVE:
2.56 + return new Revive();
2.57 + }
2.58 + return null;
2.59 + }
2.60 +
2.61 + protected boolean isEqualsCard(IValue value){
2.62 + if(value instanceof IValue)
2.63 + return false;
2.64 + if( type == TYPE.DEC && value instanceof Dec)
2.65 + return true;
2.66 + if( type == TYPE.INC && value instanceof Inc)
2.67 + return true;
2.68 + if( type == TYPE.COPY && value instanceof Copy)
2.69 + return true;
2.70 + if( type == TYPE.REVIVE && value instanceof Revive)
2.71 + return true;
2.72 + return false;
2.73 + }
2.74 +
2.75 + @Override
2.76 + public ArrayList<Batch> getBatches() {
2.77 + ArrayList<Batch> retArray = new ArrayList<Batch>();
2.78 +
2.79 + retArray.addAll(numberIntoSlotField(Run.getRegisterByIndex(0), targetSlotIndex));
2.80 +
2.81 + Slot processingSlot = Run.getProponent().getSlot(processingSlotIndex);
2.82 + IValue slotValue = processingSlot.getValue();
2.83 +
2.84 + if(slotValue instanceof Value){
2.85 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), processingSlot));
2.86 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, getCard(), processingSlot));
2.87 + }else{
2.88 + ICard currentCard = (ICard) slotValue;
2.89 + if(!(currentCard instanceof Dec && type == TYPE.DEC) ||
2.90 + !(currentCard instanceof Inc && type == TYPE.INC))
2.91 + {
2.92 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), processingSlot));
2.93 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, getCard(), processingSlot));
2.94 + }
2.95 + }
2.96 +
2.97 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
2.98 + retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
2.99 +
2.100 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
2.101 + retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
2.102 +
2.103 + return retArray;
2.104 + }
2.105 +
2.106 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/src/main/java/ru/alphatech/icfpc/policy/ZombiePolicy.java Sun Jun 19 17:13:33 2011 +0400
3.3 @@ -0,0 +1,16 @@
3.4 +package ru.alphatech.icfpc.policy;
3.5 +
3.6 +import java.util.ArrayList;
3.7 +
3.8 +import ru.alphatech.icfpc.game.AbstractPolicy;
3.9 +import ru.alphatech.icfpc.game.Batch;
3.10 +
3.11 +public class ZombiePolicy extends AbstractPolicy {
3.12 +
3.13 + @Override
3.14 + public ArrayList<Batch> getBatches() {
3.15 + // TODO Auto-generated method stub
3.16 + return null;
3.17 + }
3.18 +
3.19 +}