Cards bugs revealed.
1 /***********************************************
3 * بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِِ
4 * Time: 18.06.2011 11:37:46
5 ***********************************************/
6 package ru.alphatech.icfpc.game;
8 import java.io.BufferedReader;
9 import java.io.IOException;
10 import java.io.InputStreamReader;
12 import ru.alphatech.icfpc.cards.Attack;
13 import ru.alphatech.icfpc.cards.Copy;
14 import ru.alphatech.icfpc.cards.Dbl;
15 import ru.alphatech.icfpc.cards.Dec;
16 import ru.alphatech.icfpc.cards.Get;
17 import ru.alphatech.icfpc.cards.Help;
18 import ru.alphatech.icfpc.cards.I;
19 import ru.alphatech.icfpc.cards.ICard;
20 import ru.alphatech.icfpc.cards.Inc;
21 import ru.alphatech.icfpc.cards.K;
22 import ru.alphatech.icfpc.cards.Put;
23 import ru.alphatech.icfpc.cards.Revive;
24 import ru.alphatech.icfpc.cards.S;
25 import ru.alphatech.icfpc.cards.Succ;
26 import ru.alphatech.icfpc.cards.Zero;
27 import ru.alphatech.icfpc.cards.Zombie;
28 import ru.alphatech.icfpc.game.Batch.OperationType;
29 import ru.alphatech.icfpc.game.strategy.HelpStrategy;
30 import ru.alphatech.icfpc.game.strategy.IStrategy;
31 import ru.alphatech.icfpc.game.strategy.LenarStrategy;
35 private static int callcount = 0;
37 private static boolean automodeapply = false;
39 private static boolean endgame = false;
41 private static Player proponent = new Player();
43 private static Player opponent = new Player();
45 private static int registers[] = new int[4];
48 proponent.setMyOpponent(opponent);
49 opponent.setMyOpponent(proponent);
56 private static IStrategy strategy = new HelpStrategy();
58 public static Slot getRegisterByIndex(int registerIndex){
59 return proponent.getSlot( registers[registerIndex] );
62 public static int getRegisterSlotNum(int registerIndex ){
63 return registers[registerIndex];
66 public static Player getOpponent(){
70 public static Player getProponent(){
74 private static String[] doDebugRead()
76 return new String[] {"1", "I", "0"};
79 private static String[] doRealRead() throws IOException
81 BufferedReader breader = new BufferedReader(new InputStreamReader(System.in));
83 return new String[] {breader.readLine(), breader.readLine(), breader.readLine()};
86 private static void readOpponent() throws IOException
88 //String[] readData = doRealRead();
89 String[] readData = doDebugRead();
90 String sTurnCase = readData[0];
94 OperationType operationType = null;
98 if("1".equals(sTurnCase))
102 operationType = OperationType.CARD_TO_SLOT;
104 else if("2".equals(sTurnCase))
108 operationType = OperationType.SLOT_TO_CARD;
115 if(sTurnCase == null || sCard == null || sSlot == null)
121 slot = opponent.getSlot(Integer.parseInt(sSlot));
122 for(ICard iCard: new ICard[]{
139 if(sCard.equals(iCard.getName())){
144 Batch batch = new Batch(operationType, card, slot);
145 opponent.applyBatch(batch);
148 private static void writeMove()
150 Batch batch = strategy.move(proponent, opponent);
151 System.out.print(batch);
152 proponent.applyBatch(batch);
155 public static void resetCallCount()
160 public static int incCallCount()
167 public static boolean getAutoMode()
169 return automodeapply;
172 public static void setAutoMode(boolean b){
176 public static void main(String[] args) throws IOException
178 String playerNum = args[0];
180 if("1".equals(playerNum))
182 proponent.setPlayerNumber(1);
183 opponent.setPlayerNumber(0);
186 proponent.setPlayerNumber(0);
187 opponent.setPlayerNumber(1);