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;
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 SimplyStrategy();
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 void readOpponent() throws IOException
76 BufferedReader breader = new BufferedReader(new InputStreamReader(System.in));
77 String sTurnCase = breader.readLine();
81 OperationType operationType = null;
85 if("1".equals(sTurnCase))
87 sCard = breader.readLine();
88 sSlot = breader.readLine();
89 operationType = OperationType.CARD_TO_SLOT;
91 else if("2".equals(sTurnCase))
93 sSlot = breader.readLine();
94 sCard = breader.readLine();
95 operationType = OperationType.SLOT_TO_CARD;
102 if(sTurnCase == null || sCard == null || sSlot == null)
108 slot = opponent.getSlot(Integer.parseInt(sSlot));
109 for(ICard iCard: new ICard[]{
126 if(sCard.equals(iCard.getName())){
131 Batch batch = new Batch(operationType, card, slot);
132 opponent.applyBatch(batch);
135 private static void writeMove()
137 Batch batch = strategy.move(proponent, opponent);
138 System.out.print(batch);
139 proponent.applyBatch(batch);
142 public static void resetCallCount()
147 public static int incCallCount()
154 public static boolean getAutoMode()
156 return automodeapply;
159 public static void setAutoMode(boolean b){
163 public static void main(String[] args) throws IOException
165 String playerNum = args[0];
167 if("1".equals(playerNum))