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.IStrategy;
30 import ru.alphatech.icfpc.game.strategy.LenarStrategy;
34 private static int callcount = 0;
36 private static boolean automodeapply = false;
38 private static boolean endgame = false;
40 private static Player proponent = new Player();
42 private static Player opponent = new Player();
44 private static int registers[] = new int[4];
47 proponent.setMyOpponent(opponent);
48 opponent.setMyOpponent(proponent);
55 private static IStrategy strategy = new LenarStrategy();
57 public static Slot getRegisterByIndex(int registerIndex){
58 return proponent.getSlot( registers[registerIndex] );
61 public static int getRegisterSlotNum(int registerIndex ){
62 return registers[registerIndex];
65 public static Player getOpponent(){
69 public static Player getProponent(){
73 private static String[] doDebugRead()
75 return new String[] {"1", "I", "0"};
78 private static String[] doRealRead() throws IOException
80 BufferedReader breader = new BufferedReader(new InputStreamReader(System.in));
82 return new String[] {breader.readLine(), breader.readLine(), breader.readLine()};
85 private static void readOpponent() throws IOException
87 String[] readData = doRealRead();
88 String sTurnCase = readData[0];
92 OperationType operationType = null;
96 if("1".equals(sTurnCase))
100 operationType = OperationType.CARD_TO_SLOT;
102 else if("2".equals(sTurnCase))
106 operationType = OperationType.SLOT_TO_CARD;
113 if(sTurnCase == null || sCard == null || sSlot == null)
119 slot = opponent.getSlot(Integer.parseInt(sSlot));
120 for(ICard iCard: new ICard[]{
137 if(sCard.equals(iCard.getName())){
142 Batch batch = new Batch(operationType, card, slot);
143 opponent.applyBatch(batch);
146 private static void writeMove()
148 Batch batch = strategy.move(proponent, opponent);
149 System.out.print(batch);
150 proponent.applyBatch(batch);
153 public static void resetCallCount()
158 public static int incCallCount()
165 public static boolean getAutoMode()
167 return automodeapply;
170 public static void setAutoMode(boolean b){
174 public static void main(String[] args) throws IOException
176 String playerNum = args[0];
178 if("1".equals(playerNum))
180 proponent.setPlayerNumber(1);
181 opponent.setPlayerNumber(0);
184 proponent.setPlayerNumber(0);
185 opponent.setPlayerNumber(1);