1.1 --- a/src/main/java/ru/alphatech/icfpc/game/Batch.java Sun Jun 19 17:47:28 2011 +0400
1.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Batch.java Sun Jun 19 18:16:08 2011 +0400
1.3 @@ -15,6 +15,8 @@
1.4 public Slot slot = null;
1.5
1.6 public Batch(OperationType type, ICard card, Slot slot){
1.7 + if(type == null || card == null || slot == null)
1.8 + throw new ICFPCException("Illegal constructor using!");
1.9 this.operationType = type;
1.10 this.card = card;
1.11 this.slot = slot;
2.1 --- a/src/main/java/ru/alphatech/icfpc/game/ICFPCException.java Sun Jun 19 17:47:28 2011 +0400
2.2 +++ b/src/main/java/ru/alphatech/icfpc/game/ICFPCException.java Sun Jun 19 18:16:08 2011 +0400
2.3 @@ -4,4 +4,12 @@
2.4 public class ICFPCException extends RuntimeException
2.5 {
2.6
2.7 + public ICFPCException(){
2.8 + super();
2.9 + }
2.10 +
2.11 + public ICFPCException(String string) {
2.12 + super(string);
2.13 + }
2.14 +
2.15 }
3.1 --- a/src/main/java/ru/alphatech/icfpc/game/Player.java Sun Jun 19 17:47:28 2011 +0400
3.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Player.java Sun Jun 19 18:16:08 2011 +0400
3.3 @@ -1,6 +1,5 @@
3.4 package ru.alphatech.icfpc.game;
3.5
3.6 -import ru.alphatech.icfpc.cards.ICard;
3.7
3.8
3.9 public class Player
4.1 --- a/src/main/java/ru/alphatech/icfpc/game/Run.java Sun Jun 19 17:47:28 2011 +0400
4.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Run.java Sun Jun 19 18:16:08 2011 +0400
4.3 @@ -9,6 +9,23 @@
4.4 import java.io.IOException;
4.5 import java.io.InputStreamReader;
4.6
4.7 +import ru.alphatech.icfpc.cards.Attack;
4.8 +import ru.alphatech.icfpc.cards.Copy;
4.9 +import ru.alphatech.icfpc.cards.Dbl;
4.10 +import ru.alphatech.icfpc.cards.Dec;
4.11 +import ru.alphatech.icfpc.cards.Get;
4.12 +import ru.alphatech.icfpc.cards.Help;
4.13 +import ru.alphatech.icfpc.cards.I;
4.14 +import ru.alphatech.icfpc.cards.ICard;
4.15 +import ru.alphatech.icfpc.cards.Inc;
4.16 +import ru.alphatech.icfpc.cards.K;
4.17 +import ru.alphatech.icfpc.cards.Put;
4.18 +import ru.alphatech.icfpc.cards.Revive;
4.19 +import ru.alphatech.icfpc.cards.S;
4.20 +import ru.alphatech.icfpc.cards.Succ;
4.21 +import ru.alphatech.icfpc.cards.Zero;
4.22 +import ru.alphatech.icfpc.cards.Zombie;
4.23 +import ru.alphatech.icfpc.game.Batch.OperationType;
4.24 import ru.alphatech.icfpc.game.strategy.IStrategy;
4.25 import ru.alphatech.icfpc.game.strategy.SimplyStrategy;
4.26
4.27 @@ -52,32 +69,62 @@
4.28 private static void readOpponent() throws IOException
4.29 {
4.30 BufferedReader breader = new BufferedReader(new InputStreamReader(System.in));
4.31 - String turnCase = breader.readLine();
4.32 - String card = null;
4.33 - String slot = null;
4.34 + String sTurnCase = breader.readLine();
4.35 + String sCard = null;
4.36 + String sSlot = null;
4.37
4.38 - if("1".equals(turnCase))
4.39 + OperationType operationType = null;
4.40 + ICard card = null;
4.41 + Slot slot = null;
4.42 +
4.43 + if("1".equals(sTurnCase))
4.44 {
4.45 - card = breader.readLine();
4.46 - slot = breader.readLine();
4.47 + sCard = breader.readLine();
4.48 + sSlot = breader.readLine();
4.49 + operationType = OperationType.CARD_TO_SLOT;
4.50 }
4.51 - else if("2".equals(turnCase))
4.52 + else if("2".equals(sTurnCase))
4.53 {
4.54 - slot = breader.readLine();
4.55 - card = breader.readLine();
4.56 + sSlot = breader.readLine();
4.57 + sCard = breader.readLine();
4.58 + operationType = OperationType.SLOT_TO_CARD;
4.59 }
4.60 else
4.61 {
4.62 // do nothing
4.63 }
4.64
4.65 - if(turnCase == null || card == null || slot == null)
4.66 + if(sTurnCase == null || sCard == null || sSlot == null)
4.67 {
4.68 endgame = true;
4.69 return;
4.70 }
4.71
4.72 -
4.73 + slot = opponent.getSlot(Integer.parseInt(sSlot));
4.74 + for(ICard iCard: new ICard[]{
4.75 + new Attack(),
4.76 + new Copy(),
4.77 + new Dbl(),
4.78 + new Dec(),
4.79 + new Get(),
4.80 + new Help(),
4.81 + new I(),
4.82 + new Inc(),
4.83 + new K(),
4.84 + new Put(),
4.85 + new Revive(),
4.86 + new S(),
4.87 + new Succ(),
4.88 + new Zero(),
4.89 + new Zombie(),
4.90 + }){
4.91 + if(sCard.equals(iCard.getName())){
4.92 + card = iCard;
4.93 + break;
4.94 + }
4.95 + }
4.96 + Batch batch = new Batch(operationType, card, slot);
4.97 + opponent.applyBatch(batch);
4.98 }
4.99
4.100 private static void writeMove()