diff -r 89f13f209302 -r 19dba9e387ce src/main/java/ru/alphatech/icfpc/game/Run.java --- a/src/main/java/ru/alphatech/icfpc/game/Run.java Sun Jun 19 17:53:59 2011 +0400 +++ b/src/main/java/ru/alphatech/icfpc/game/Run.java Sun Jun 19 18:42:07 2011 +0400 @@ -8,22 +8,37 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; -import java.util.LinkedList; -import java.util.List; +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; public class Run { + private static boolean automodeapply = false; + private static boolean endgame = false; private static Player proponent = new Player(); private static Player opponent = new Player(); - private static LinkedList batches = new LinkedList(); - private static int registers[] = new int[4]; static { @@ -35,16 +50,12 @@ private static IStrategy strategy = new SimplyStrategy(); - public static Slot getRegisterByIndex(int registerIdex){ - return proponent.getSlot( registers[registerIdex] ); + public static Slot getRegisterByIndex(int registerIndex){ + return proponent.getSlot( registers[registerIndex] ); } - public static void clearBatcher(){ - batches.removeAll(batches); - } - - public static void addBatcher(List batches){ - batches.addAll(batches); + public static int getRegisterSlotNum(int registerIndex ){ + return registers[registerIndex]; } public static Player getOpponent(){ @@ -58,36 +69,76 @@ 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() { - strategy.moving(proponent, opponent, System.out); + Batch batch = strategy.move(proponent, opponent); + System.out.print(batch); + proponent.applyBatch(batch); } + public static boolean getAutoMode() + { + return automodeapply; + } + public static void main(String[] args) throws IOException { String playerNum = args[0];