# HG changeset patch # User indvdum # Date 1308492968 -14400 # Node ID 8c40512777a1e11813cad2d9612e21cf4295b604 # Parent 598cbc609683cbbd466fd9dff863f94081494fd2 + parsing opponent batch diff -r 598cbc609683 -r 8c40512777a1 src/main/java/ru/alphatech/icfpc/game/Batch.java --- a/src/main/java/ru/alphatech/icfpc/game/Batch.java Sun Jun 19 17:47:28 2011 +0400 +++ b/src/main/java/ru/alphatech/icfpc/game/Batch.java Sun Jun 19 18:16:08 2011 +0400 @@ -15,6 +15,8 @@ public Slot slot = null; public Batch(OperationType type, ICard card, Slot slot){ + if(type == null || card == null || slot == null) + throw new ICFPCException("Illegal constructor using!"); this.operationType = type; this.card = card; this.slot = slot; diff -r 598cbc609683 -r 8c40512777a1 src/main/java/ru/alphatech/icfpc/game/ICFPCException.java --- a/src/main/java/ru/alphatech/icfpc/game/ICFPCException.java Sun Jun 19 17:47:28 2011 +0400 +++ b/src/main/java/ru/alphatech/icfpc/game/ICFPCException.java Sun Jun 19 18:16:08 2011 +0400 @@ -4,4 +4,12 @@ public class ICFPCException extends RuntimeException { + public ICFPCException(){ + super(); + } + + public ICFPCException(String string) { + super(string); + } + } diff -r 598cbc609683 -r 8c40512777a1 src/main/java/ru/alphatech/icfpc/game/Player.java --- a/src/main/java/ru/alphatech/icfpc/game/Player.java Sun Jun 19 17:47:28 2011 +0400 +++ b/src/main/java/ru/alphatech/icfpc/game/Player.java Sun Jun 19 18:16:08 2011 +0400 @@ -1,6 +1,5 @@ package ru.alphatech.icfpc.game; -import ru.alphatech.icfpc.cards.ICard; public class Player diff -r 598cbc609683 -r 8c40512777a1 src/main/java/ru/alphatech/icfpc/game/Run.java --- a/src/main/java/ru/alphatech/icfpc/game/Run.java Sun Jun 19 17:47:28 2011 +0400 +++ b/src/main/java/ru/alphatech/icfpc/game/Run.java Sun Jun 19 18:16:08 2011 +0400 @@ -9,6 +9,23 @@ import java.io.IOException; import java.io.InputStreamReader; +import ru.alphatech.icfpc.cards.Attack; +import ru.alphatech.icfpc.cards.Copy; +import ru.alphatech.icfpc.cards.Dbl; +import ru.alphatech.icfpc.cards.Dec; +import ru.alphatech.icfpc.cards.Get; +import ru.alphatech.icfpc.cards.Help; +import ru.alphatech.icfpc.cards.I; +import ru.alphatech.icfpc.cards.ICard; +import ru.alphatech.icfpc.cards.Inc; +import ru.alphatech.icfpc.cards.K; +import ru.alphatech.icfpc.cards.Put; +import ru.alphatech.icfpc.cards.Revive; +import ru.alphatech.icfpc.cards.S; +import ru.alphatech.icfpc.cards.Succ; +import ru.alphatech.icfpc.cards.Zero; +import ru.alphatech.icfpc.cards.Zombie; +import ru.alphatech.icfpc.game.Batch.OperationType; import ru.alphatech.icfpc.game.strategy.IStrategy; import ru.alphatech.icfpc.game.strategy.SimplyStrategy; @@ -52,32 +69,62 @@ private static void readOpponent() throws IOException { BufferedReader breader = new BufferedReader(new InputStreamReader(System.in)); - String turnCase = breader.readLine(); - String card = null; - String slot = null; + String sTurnCase = breader.readLine(); + String sCard = null; + String sSlot = null; - if("1".equals(turnCase)) + OperationType operationType = null; + ICard card = null; + Slot slot = null; + + if("1".equals(sTurnCase)) { - card = breader.readLine(); - slot = breader.readLine(); + sCard = breader.readLine(); + sSlot = breader.readLine(); + operationType = OperationType.CARD_TO_SLOT; } - else if("2".equals(turnCase)) + else if("2".equals(sTurnCase)) { - slot = breader.readLine(); - card = breader.readLine(); + sSlot = breader.readLine(); + sCard = breader.readLine(); + operationType = OperationType.SLOT_TO_CARD; } else { // do nothing } - if(turnCase == null || card == null || slot == null) + if(sTurnCase == null || sCard == null || sSlot == null) { endgame = true; return; } - + slot = opponent.getSlot(Integer.parseInt(sSlot)); + for(ICard iCard: new ICard[]{ + new Attack(), + new Copy(), + new Dbl(), + new Dec(), + new Get(), + new Help(), + new I(), + new Inc(), + new K(), + new Put(), + new Revive(), + new S(), + new Succ(), + new Zero(), + new Zombie(), + }){ + if(sCard.equals(iCard.getName())){ + card = iCard; + break; + } + } + Batch batch = new Batch(operationType, card, slot); + opponent.applyBatch(batch); } private static void writeMove()