src/main/java/ru/alphatech/icfpc/game/Run.java
author Igor R. Nikitin <0-range@bazon.ru>
Sun, 19 Jun 2011 12:13:34 +0400
changeset 36 5b57bc39cc92
parent 34 85894dec2280
child 37 6e56ba8c71c3
permissions -rw-r--r--
merge
     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 import java.util.ArrayList;
    12 import java.util.LinkedList;
    13 import java.util.List;
    14 
    15 public class Run
    16 {
    17 	private static boolean endgame = false;
    18 	
    19 	private static Player proponent = new Player();
    20 	
    21 	private static Player opponent = new Player();
    22 	
    23 	private LinkedList<Batch> batches = new LinkedList<Batch>();
    24 	
    25 	public void clearBatcher(){
    26 		batches.removeAll(batches);
    27 	}
    28 	
    29 	public void addBatcher(List<Batch> batches){
    30 		this.batches.addAll(this.batches);
    31 	}
    32 	
    33 	private static void readOpponent() throws IOException
    34 	{
    35 		BufferedReader breader = new BufferedReader(new InputStreamReader(System.in));
    36 		String turnCase = breader.readLine();
    37 		String card = null;
    38 		String slot = null;
    39 		
    40 		if("1".equals(turnCase))
    41 		{
    42 			card = breader.readLine();
    43 			slot = breader.readLine();
    44 		}
    45 		else if("2".equals(turnCase))
    46 		{
    47 			slot = breader.readLine();
    48 			card = breader.readLine();
    49 		}
    50 		else
    51 		{
    52 			// do nothing
    53 		}
    54 		
    55 		if(turnCase == null || card == null || slot == null)
    56 		{
    57 			endgame = true;
    58 		}
    59 	}
    60 	
    61 	private static void writeMove()
    62     {
    63 		System.out.print(1 + "\n");
    64 		System.out.print("I" + "\n");
    65 		System.out.print(0 + "\n");
    66     }
    67 	
    68 	public static void main(String[] args) throws IOException
    69     {
    70 	    String playerNum = args[0];
    71 
    72 	    if("1".equals(playerNum))
    73 	    {
    74 	    	readOpponent();
    75 	    }
    76 	    
    77 	    while(!endgame)
    78 	    {
    79 		    writeMove();
    80 		    readOpponent();
    81 	    }
    82     }
    83 }