Наброски по дебагу.
1 /***********************************************
3 * بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِِ
4 * Time: 18.06.2011 11:37:46
5 ***********************************************/
6 package ru.alphatech.icfpc.game;
8 import java.io.BufferedReader;
10 import java.io.IOException;
11 import java.io.InputStreamReader;
13 import ru.alphatech.icfpc.cards.Attack;
14 import ru.alphatech.icfpc.cards.Copy;
15 import ru.alphatech.icfpc.cards.Dbl;
16 import ru.alphatech.icfpc.cards.Dec;
17 import ru.alphatech.icfpc.cards.Get;
18 import ru.alphatech.icfpc.cards.Help;
19 import ru.alphatech.icfpc.cards.I;
20 import ru.alphatech.icfpc.cards.ICard;
21 import ru.alphatech.icfpc.cards.Inc;
22 import ru.alphatech.icfpc.cards.K;
23 import ru.alphatech.icfpc.cards.Put;
24 import ru.alphatech.icfpc.cards.Revive;
25 import ru.alphatech.icfpc.cards.S;
26 import ru.alphatech.icfpc.cards.Succ;
27 import ru.alphatech.icfpc.cards.Zero;
28 import ru.alphatech.icfpc.cards.Zombie;
29 import ru.alphatech.icfpc.game.Batch.OperationType;
30 import ru.alphatech.icfpc.game.strategy.IStrategy;
31 import ru.alphatech.icfpc.game.strategy.SimplyStrategy;
32 import ru.alphatech.icfpc.game.strategy.YetAnotherStrategy;
36 private static int callcount = 0;
38 private static boolean automodeapply = false;
40 private static boolean endgame = false;
42 private static Player proponent = new Player();
44 private static Player opponent = new Player();
46 private static int registers[] = new int[4];
49 proponent.setMyOpponent(opponent);
50 opponent.setMyOpponent(proponent);
57 private static IStrategy strategy = new YetAnotherStrategy();
59 public static Slot getRegisterByIndex(int registerIndex){
60 return proponent.getSlot( registers[registerIndex] );
63 public static int getRegisterSlotNum(int registerIndex ){
64 return registers[registerIndex];
67 public static Player getOpponent(){
71 public static Player getProponent(){
75 private static String[] doDebugRead()
77 return new String[] {"1", "I", "0"};
80 private static String[] doRealRead() throws IOException
82 BufferedReader breader = new BufferedReader(new InputStreamReader(System.in));
84 return new String[] {breader.readLine(), breader.readLine(), breader.readLine()};
87 private static void readOpponent() throws IOException
89 //String[] readData = doRealRead();
90 String[] readData = doDebugRead();
91 String sTurnCase = readData[0];
95 OperationType operationType = null;
99 if("1".equals(sTurnCase))
103 operationType = OperationType.CARD_TO_SLOT;
105 else if("2".equals(sTurnCase))
109 operationType = OperationType.SLOT_TO_CARD;
116 if(sTurnCase == null || sCard == null || sSlot == null)
122 slot = opponent.getSlot(Integer.parseInt(sSlot));
123 for(ICard iCard: new ICard[]{
140 if(sCard.equals(iCard.getName())){
145 Batch batch = new Batch(operationType, card, slot);
146 opponent.applyBatch(batch);
149 private static void writeMove()
151 Batch batch = strategy.move(proponent, opponent);
152 System.out.print(batch);
153 proponent.applyBatch(batch);
156 public static void resetCallCount()
161 public static int incCallCount()
168 public static boolean getAutoMode()
170 return automodeapply;
173 public static void setAutoMode(boolean b){
177 public static void main(String[] args) throws IOException
179 String playerNum = args[0];
181 if("1".equals(playerNum))
183 proponent.setPlayerNumber(1);
184 opponent.setPlayerNumber(0);
187 proponent.setPlayerNumber(0);
188 opponent.setPlayerNumber(1);