src/main/java/ru/alphatech/icfpc/game/Run.java
author Azamat S. Kalimoulline <turtle@bazon.ru>
Sun, 19 Jun 2011 11:18:57 +0400
changeset 29 9f1b16124685
parent 15 380a98ded3a0
child 34 85894dec2280
permissions -rw-r--r--
Reading opponent input.
     1 /***********************************************
     2  * icfpc-2011
     3  * بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِِ
     4  * Time: 18.06.2011 11:37:46
     5  ***********************************************/
     6 package ru.alphatech.icfpc.game;
     7 
     8 import java.io.BufferedReader;
     9 import java.io.IOException;
    10 import java.io.InputStreamReader;
    11 
    12 public class Run
    13 {
    14 	private static boolean endgame = false;
    15 	
    16 	private static Player proponent = new Player();
    17 	
    18 	private static Player opponent = new Player();
    19 	
    20 	private static void readOpponent() throws IOException
    21 	{
    22 		BufferedReader breader = new BufferedReader(new InputStreamReader(System.in));
    23 		String turnCase = breader.readLine();
    24 		String card = null;
    25 		String slot = null;
    26 		
    27 		if("1".equals(turnCase))
    28 		{
    29 			card = breader.readLine();
    30 			slot = breader.readLine();
    31 		}
    32 		else if("2".equals(turnCase))
    33 		{
    34 			slot = breader.readLine();
    35 			card = breader.readLine();
    36 		}
    37 		else
    38 		{
    39 			// do nothing
    40 		}
    41 		
    42 		if(turnCase == null || card == null || slot == null)
    43 		{
    44 			endgame = true;
    45 		}
    46 	}
    47 	
    48 	private static void writeMove()
    49     {
    50 		System.out.print(1 + "\n");
    51 		System.out.print("I" + "\n");
    52 		System.out.print(0 + "\n");
    53     }
    54 	
    55 	public static void main(String[] args) throws IOException
    56     {
    57 	    String playerNum = args[0];
    58 
    59 	    if("1".equals(playerNum))
    60 	    {
    61 	    	readOpponent();
    62 	    }
    63 	    
    64 	    while(!endgame)
    65 	    {
    66 		    writeMove();
    67 		    readOpponent();
    68 	    }
    69     }
    70 }