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