turtle@13: /*********************************************** turtle@13: * icfpc-2011 turtle@13: * بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِِ turtle@13: * Time: 18.06.2011 11:37:46 turtle@13: ***********************************************/ turtle@13: package ru.alphatech.icfpc.game; turtle@13: turtle@14: import java.io.BufferedReader; turtle@14: import java.io.IOException; turtle@14: import java.io.InputStreamReader; akhmetovlz@31: import java.util.ArrayList; akhmetovlz@31: import java.util.LinkedList; akhmetovlz@31: import java.util.List; turtle@14: turtle@13: public class Run turtle@13: { turtle@15: private static boolean endgame = false; turtle@15: turtle@14: private static Player proponent = new Player(); turtle@14: turtle@14: private static Player opponent = new Player(); turtle@14: akhmetovlz@31: private LinkedList batches = new LinkedList(); akhmetovlz@31: akhmetovlz@31: public void clearBatcher(){ akhmetovlz@31: batches.removeAll(batches); akhmetovlz@31: } akhmetovlz@31: akhmetovlz@31: public void addBatcher(List batches){ akhmetovlz@31: this.batches.addAll(this.batches); akhmetovlz@31: } akhmetovlz@31: turtle@14: private static void readOpponent() throws IOException turtle@14: { turtle@14: BufferedReader breader = new BufferedReader(new InputStreamReader(System.in)); turtle@29: String turnCase = breader.readLine(); turtle@29: String card = null; turtle@29: String slot = null; turtle@14: turtle@29: if("1".equals(turnCase)) turtle@29: { turtle@29: card = breader.readLine(); turtle@29: slot = breader.readLine(); turtle@29: } turtle@29: else if("2".equals(turnCase)) turtle@29: { turtle@29: slot = breader.readLine(); turtle@29: card = breader.readLine(); turtle@29: } turtle@29: else turtle@29: { turtle@29: // do nothing turtle@29: } turtle@15: turtle@29: if(turnCase == null || card == null || slot == null) turtle@15: { turtle@15: endgame = true; turtle@15: } turtle@14: } turtle@14: turtle@14: private static void writeMove() turtle@14: { turtle@15: System.out.print(1 + "\n"); turtle@15: System.out.print("I" + "\n"); turtle@15: System.out.print(0 + "\n"); turtle@14: } turtle@15: turtle@14: public static void main(String[] args) throws IOException turtle@13: { turtle@13: String playerNum = args[0]; turtle@15: turtle@14: if("1".equals(playerNum)) turtle@14: { turtle@14: readOpponent(); turtle@14: } turtle@14: turtle@15: while(!endgame) turtle@15: { turtle@15: writeMove(); turtle@15: readOpponent(); turtle@15: } turtle@13: } turtle@13: }