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 void readOpponent() throws IOException
77 BufferedReader breader = new BufferedReader(new InputStreamReader(System.in));
78 String sTurnCase = breader.readLine();
82 OperationType operationType = null;
86 if("1".equals(sTurnCase))
88 sCard = breader.readLine();
89 sSlot = breader.readLine();
90 operationType = OperationType.CARD_TO_SLOT;
92 else if("2".equals(sTurnCase))
94 sSlot = breader.readLine();
95 sCard = breader.readLine();
96 operationType = OperationType.SLOT_TO_CARD;
103 if(sTurnCase == null || sCard == null || sSlot == null)
109 slot = opponent.getSlot(Integer.parseInt(sSlot));
110 for(ICard iCard: new ICard[]{
127 if(sCard.equals(iCard.getName())){
132 Batch batch = new Batch(operationType, card, slot);
133 opponent.applyBatch(batch);
136 private static void writeMove()
138 Batch batch = strategy.move(proponent, opponent);
139 System.out.print(batch);
140 proponent.applyBatch(batch);
143 public static void resetCallCount()
148 public static int incCallCount()
155 public static boolean getAutoMode()
157 return automodeapply;
160 public static void setAutoMode(boolean b){
164 public static void main(String[] args) throws IOException
166 String playerNum = args[0];
168 if("1".equals(playerNum))
170 proponent.setPlayerNumber(1);
171 opponent.setPlayerNumber(0);
174 proponent.setPlayerNumber(0);
175 opponent.setPlayerNumber(1);