src/main/java/ru/alphatech/icfpc/game/Run.java
author akhmetovlz
Sun, 19 Jun 2011 13:36:19 +0400
changeset 53 126046a20107
parent 48 7e49c679fc70
child 55 26d05bc45f1d
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 static LinkedList<Batch> batches = new LinkedList<Batch>();
    23 	
    24 	private static int registers[] = new int[4];
    25 	
    26 	static {
    27 		registers[0] = 0;
    28 		registers[1] = 1;
    29 		registers[2] = 2;
    30 		registers[3] = 3;
    31 	}
    32 	
    33 	public static Slot getRegisterByIndex(int registerIdex){
    34 		return proponent.getSlot( registers[registerIdex] );
    35 	}
    36 	
    37 	public static void clearBatcher(){
    38 		batches.removeAll(batches);
    39 	}
    40 	
    41 	public static void addBatcher(List<Batch> batches){
    42 		batches.addAll(batches);
    43 	}
    44 	
    45 	public static Player getOpponent(){
    46 		return opponent;
    47 	}
    48 	
    49 	public static Player getProponent(){
    50 		return proponent;
    51 	}
    52 	
    53 	private static void readOpponent() throws IOException
    54 	{
    55 		BufferedReader breader = new BufferedReader(new InputStreamReader(System.in));
    56 		String turnCase = breader.readLine();
    57 		String card = null;
    58 		String slot = null;
    59 		
    60 		if("1".equals(turnCase))
    61 		{
    62 			card = breader.readLine();
    63 			slot = breader.readLine();
    64 		}
    65 		else if("2".equals(turnCase))
    66 		{
    67 			slot = breader.readLine();
    68 			card = breader.readLine();
    69 		}
    70 		else
    71 		{
    72 			// do nothing
    73 		}
    74 		
    75 		if(turnCase == null || card == null || slot == null)
    76 		{
    77 			endgame = true;
    78 		}
    79 	}
    80 	
    81 	private static void writeMove()
    82     {
    83 		System.out.print(1 + "\n");
    84 		System.out.print("I" + "\n");
    85 		System.out.print(0 + "\n");
    86     }
    87 	
    88 	public static void main(String[] args) throws IOException
    89     {
    90 	    String playerNum = args[0];
    91 
    92 	    if("1".equals(playerNum))
    93 	    {
    94 	    	readOpponent();
    95 	    }
    96 	    
    97 	    while(!endgame)
    98 	    {
    99 		    writeMove();
   100 		    readOpponent();
   101 	    }
   102     }
   103 }