1.1 --- a/src/main/java/ru/alphatech/icfpc/game/Batch.java Sun Jun 19 17:21:54 2011 +0400
1.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Batch.java Sun Jun 19 17:22:00 2011 +0400
1.3 @@ -19,5 +19,25 @@
1.4 this.card = card;
1.5 this.slot = slot;
1.6 }
1.7 +
1.8 + @Override
1.9 + public String toString() {
1.10 + if(operationType == null || card == null || slot == null)
1.11 + throw new ICFPCException();
1.12 + StringBuilder ret = new StringBuilder();
1.13 + switch(operationType){
1.14 + case CARD_TO_SLOT:
1.15 + ret.append("1\n");
1.16 + ret.append(card.getName() + "\n");
1.17 + ret.append(slot.getId() + "\n");
1.18 + break;
1.19 + case SLOT_TO_CARD:
1.20 + ret.append("2\n");
1.21 + ret.append(slot.getId() + "\n");
1.22 + ret.append(card.getName() + "\n");
1.23 + break;
1.24 + }
1.25 + return ret.toString();
1.26 + }
1.27
1.28 }
2.1 --- a/src/main/java/ru/alphatech/icfpc/game/Player.java Sun Jun 19 17:21:54 2011 +0400
2.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Player.java Sun Jun 19 17:22:00 2011 +0400
2.3 @@ -11,7 +11,7 @@
2.4 {
2.5 for(int i = 0; i < 255; i++)
2.6 {
2.7 - slots[i] = new Slot();
2.8 + slots[i] = new Slot(i);
2.9 }
2.10 }
2.11
3.1 --- a/src/main/java/ru/alphatech/icfpc/game/Run.java Sun Jun 19 17:21:54 2011 +0400
3.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Run.java Sun Jun 19 17:22:00 2011 +0400
3.3 @@ -8,8 +8,6 @@
3.4 import java.io.BufferedReader;
3.5 import java.io.IOException;
3.6 import java.io.InputStreamReader;
3.7 -import java.util.LinkedList;
3.8 -import java.util.List;
3.9
3.10 import ru.alphatech.icfpc.game.strategy.IStrategy;
3.11 import ru.alphatech.icfpc.game.strategy.SimplyStrategy;
3.12 @@ -24,8 +22,6 @@
3.13
3.14 private static Player opponent = new Player();
3.15
3.16 - private static LinkedList<Batch> batches = new LinkedList<Batch>();
3.17 -
3.18 private static int registers[] = new int[4];
3.19
3.20 static {
3.21 @@ -41,14 +37,6 @@
3.22 return proponent.getSlot( registers[registerIdex] );
3.23 }
3.24
3.25 - public static void clearBatcher(){
3.26 - batches.removeAll(batches);
3.27 - }
3.28 -
3.29 - public static void addBatcher(List<Batch> batches){
3.30 - batches.addAll(batches);
3.31 - }
3.32 -
3.33 public static Player getOpponent(){
3.34 return opponent;
3.35 }
4.1 --- a/src/main/java/ru/alphatech/icfpc/game/Slot.java Sun Jun 19 17:21:54 2011 +0400
4.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Slot.java Sun Jun 19 17:22:00 2011 +0400
4.3 @@ -9,6 +9,18 @@
4.4
4.5 private IValue _value = new I();
4.6
4.7 + private int id = -1;
4.8 +
4.9 + public int getId() {
4.10 + return id;
4.11 + }
4.12 +
4.13 + public Slot(int id){
4.14 + if(id < 0 || id > 255)
4.15 + throw new ICFPCException();
4.16 + this.id = id;
4.17 + }
4.18 +
4.19 public void setVitality(int vitality)
4.20 {
4.21 _vitality = vitality;
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/src/main/java/ru/alphatech/icfpc/game/strategy/OtherStrategy.java Sun Jun 19 17:22:00 2011 +0400
5.3 @@ -0,0 +1,28 @@
5.4 +package ru.alphatech.icfpc.game.strategy;
5.5 +
5.6 +import java.io.PrintStream;
5.7 +import java.util.LinkedList;
5.8 +import java.util.List;
5.9 +import java.util.Queue;
5.10 +
5.11 +import ru.alphatech.icfpc.game.Batch;
5.12 +import ru.alphatech.icfpc.game.Player;
5.13 +
5.14 +public class OtherStrategy implements IStrategy {
5.15 +
5.16 + private static Queue<Batch> batches = new LinkedList<Batch>();
5.17 +
5.18 + public void clearBatcher(){
5.19 + batches.removeAll(batches);
5.20 + }
5.21 +
5.22 + public void addBatcher(List<Batch> batches){
5.23 + this.batches.addAll(batches);
5.24 + }
5.25 +
5.26 + @Override
5.27 + public void moving(Player proponent, Player opponent, PrintStream out) {
5.28 + out.print(batches.poll());
5.29 + }
5.30 +
5.31 +}
6.1 --- a/src/main/java/ru/alphatech/icfpc/game/strategy/SimplyStrategy.java Sun Jun 19 17:21:54 2011 +0400
6.2 +++ b/src/main/java/ru/alphatech/icfpc/game/strategy/SimplyStrategy.java Sun Jun 19 17:22:00 2011 +0400
6.3 @@ -2,7 +2,10 @@
6.4
6.5 import java.io.PrintStream;
6.6
6.7 +import ru.alphatech.icfpc.cards.I;
6.8 +import ru.alphatech.icfpc.game.Batch;
6.9 import ru.alphatech.icfpc.game.Player;
6.10 +import static ru.alphatech.icfpc.game.Batch.OperationType.*;
6.11
6.12 /**
6.13 * @author indvdum
6.14 @@ -13,9 +16,8 @@
6.15
6.16 @Override
6.17 public void moving(Player proponent, Player opponent, PrintStream out) {
6.18 - out.print(1 + "\n");
6.19 - out.print("I" + "\n");
6.20 - out.print(0 + "\n");
6.21 + Batch batch = new Batch(CARD_TO_SLOT, new I(), opponent.getSlot(0));
6.22 + out.print(batch);
6.23 }
6.24
6.25 }