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