* analyzing
authorindvdum
Sun, 19 Jun 2011 19:44:06 +0400
changeset 106643b85a8a16b
parent 105 57368a3d0b15
child 107 6985d0b79267
child 108 4e9f892684f2
* analyzing
src/main/java/ru/alphatech/icfpc/game/Player.java
src/main/java/ru/alphatech/icfpc/game/Run.java
src/main/java/ru/alphatech/icfpc/game/Slot.java
     1.1 --- a/src/main/java/ru/alphatech/icfpc/game/Player.java	Sun Jun 19 19:14:45 2011 +0400
     1.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Player.java	Sun Jun 19 19:44:06 2011 +0400
     1.3 @@ -11,7 +11,7 @@
     1.4  
     1.5  	public Player()
     1.6      {
     1.7 -		for(int i = 0; i < 255; i++)
     1.8 +		for(int i = 0; i <= 255; i++)
     1.9  		{
    1.10  			slots[i] = new Slot(i);
    1.11  		}
    1.12 @@ -35,13 +35,26 @@
    1.13  	}
    1.14  	
    1.15  	public void applyBatch(Batch batch){
    1.16 -		switch(batch.operationType){
    1.17 -		case CARD_TO_SLOT:
    1.18 -			batch.card.returnValue(getSlot(batch.slot.getId()).getValue(), this, myOpponent);
    1.19 -			break;
    1.20 -		case SLOT_TO_CARD:
    1.21 -			getSlot(batch.slot.getId()).getValue().returnValue(batch.card, this, myOpponent);
    1.22 -			break;
    1.23 +		Run.setAutoMode(false);
    1.24 +		Run.resetCallCount();
    1.25 +		try{
    1.26 +			switch(batch.operationType){
    1.27 +			case CARD_TO_SLOT:
    1.28 +				batch.card.returnValue(getSlot(batch.slot.getId()).getValue(), this, myOpponent);
    1.29 +				break;
    1.30 +			case SLOT_TO_CARD:
    1.31 +				getSlot(batch.slot.getId()).getValue().returnValue(batch.card, this, myOpponent);
    1.32 +				break;
    1.33 +			}
    1.34 +		} catch (ICFPCException exception){
    1.35 +			getSlot(batch.slot.getId()).putValue(new I());
    1.36 +		}
    1.37 +		Run.setAutoMode(true);
    1.38 +		Run.resetCallCount();
    1.39 +		for(Slot slot: myOpponent.slots){
    1.40 +			if(slot.isZombie()){
    1.41 +				slot.getValue().returnValue(new I(), myOpponent, myOpponent.getMyOpponent());
    1.42 +			}
    1.43  		}
    1.44  	}
    1.45  	
     2.1 --- a/src/main/java/ru/alphatech/icfpc/game/Run.java	Sun Jun 19 19:14:45 2011 +0400
     2.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Run.java	Sun Jun 19 19:44:06 2011 +0400
     2.3 @@ -156,6 +156,10 @@
     2.4  		return automodeapply;
     2.5  	}
     2.6  	
     2.7 +	public static void setAutoMode(boolean b){
     2.8 +		automodeapply = b;
     2.9 +	}
    2.10 +	
    2.11  	public static void main(String[] args) throws IOException
    2.12      {
    2.13  	    String playerNum = args[0];
     3.1 --- a/src/main/java/ru/alphatech/icfpc/game/Slot.java	Sun Jun 19 19:14:45 2011 +0400
     3.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Slot.java	Sun Jun 19 19:44:06 2011 +0400
     3.3 @@ -30,6 +30,10 @@
     3.4  	{
     3.5  		return _vitality;	
     3.6  	}
     3.7 +	
     3.8 +	public boolean isZombie(){
     3.9 +		return _vitality == -1;
    3.10 +	}
    3.11  
    3.12  	public IValue getValue()
    3.13  	{