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 boolean automodeapply = false;
37 private static boolean endgame = false;
39 private static Player proponent = new Player();
41 private static Player opponent = new Player();
43 private static int registers[] = new int[4];
46 proponent.setMyOpponent(opponent);
47 opponent.setMyOpponent(proponent);
54 private static IStrategy strategy = new SimplyStrategy();
56 public static Slot getRegisterByIndex(int registerIndex){
57 return proponent.getSlot( registers[registerIndex] );
60 public static int getRegisterSlotNum(int registerIndex ){
61 return registers[registerIndex];
64 public static Player getOpponent(){
68 public static Player getProponent(){
72 private static void readOpponent() throws IOException
74 BufferedReader breader = new BufferedReader(new InputStreamReader(System.in));
75 String sTurnCase = breader.readLine();
79 OperationType operationType = null;
83 if("1".equals(sTurnCase))
85 sCard = breader.readLine();
86 sSlot = breader.readLine();
87 operationType = OperationType.CARD_TO_SLOT;
89 else if("2".equals(sTurnCase))
91 sSlot = breader.readLine();
92 sCard = breader.readLine();
93 operationType = OperationType.SLOT_TO_CARD;
100 if(sTurnCase == null || sCard == null || sSlot == null)
106 slot = opponent.getSlot(Integer.parseInt(sSlot));
107 for(ICard iCard: new ICard[]{
124 if(sCard.equals(iCard.getName())){
129 Batch batch = new Batch(operationType, card, slot);
130 opponent.applyBatch(batch);
133 private static void writeMove()
135 Batch batch = strategy.move(proponent, opponent);
136 System.out.print(batch);
137 proponent.applyBatch(batch);
140 public static boolean getAutoMode()
142 return automodeapply;
145 public static void main(String[] args) throws IOException
147 String playerNum = args[0];
149 if("1".equals(playerNum))