*
authorindvdum
Mon, 20 Jun 2011 01:59:43 +0400
changeset 122845c89fa268e
parent 121 ea793ae43d3e
child 123 6d4232b83c76
*
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
src/main/java/ru/alphatech/icfpc/game/strategy/YetAnotherStrategy.java
     1.1 --- a/src/main/java/ru/alphatech/icfpc/game/Player.java	Mon Jun 20 01:48:37 2011 +0400
     1.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Player.java	Mon Jun 20 01:59:43 2011 +0400
     1.3 @@ -8,6 +8,8 @@
     1.4  
     1.5  public class Player
     1.6  {
     1.7 +	private int playerNumber = -1;
     1.8 +
     1.9  	private Slot[] slots = new Slot[256];
    1.10  	private Player myOpponent = null;
    1.11  
    1.12 @@ -19,6 +21,14 @@
    1.13  		}
    1.14      }
    1.15  	
    1.16 +	public int getPlayerNumber() {
    1.17 +		return playerNumber;
    1.18 +	}
    1.19 +	
    1.20 +	public void setPlayerNumber(int playerNumber) {
    1.21 +		this.playerNumber = playerNumber;
    1.22 +	}
    1.23 +
    1.24  	public Player getMyOpponent() {
    1.25  		return myOpponent;
    1.26  	}
    1.27 @@ -33,7 +43,7 @@
    1.28  	}
    1.29  	
    1.30  	public PlayerStatistic getStatistic(){
    1.31 -		throw new RuntimeException("Not impilemented yet.");
    1.32 +		throw new RuntimeException("Not implemented yet.");
    1.33  	}
    1.34  	
    1.35  	public void applyBatch(Batch batch){
     2.1 --- a/src/main/java/ru/alphatech/icfpc/game/Run.java	Mon Jun 20 01:48:37 2011 +0400
     2.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Run.java	Mon Jun 20 01:59:43 2011 +0400
     2.3 @@ -167,7 +167,12 @@
     2.4  
     2.5  	    if("1".equals(playerNum))
     2.6  	    {
     2.7 +	    	proponent.setPlayerNumber(1);
     2.8 +	    	opponent.setPlayerNumber(0);
     2.9  	    	readOpponent();
    2.10 +	    } else {
    2.11 +	    	proponent.setPlayerNumber(0);
    2.12 +	    	opponent.setPlayerNumber(1);
    2.13  	    }
    2.14  	    
    2.15  	    while(!endgame)
     3.1 --- a/src/main/java/ru/alphatech/icfpc/game/Slot.java	Mon Jun 20 01:48:37 2011 +0400
     3.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Slot.java	Mon Jun 20 01:59:43 2011 +0400
     3.3 @@ -34,6 +34,10 @@
     3.4  	public boolean isZombie(){
     3.5  		return _vitality == -1;
     3.6  	}
     3.7 +	
     3.8 +	public boolean isDead(){
     3.9 +		return _vitality == 0 || _vitality == -1;
    3.10 +	}
    3.11  
    3.12  	public IValue getValue()
    3.13  	{
     4.1 --- a/src/main/java/ru/alphatech/icfpc/game/strategy/YetAnotherStrategy.java	Mon Jun 20 01:48:37 2011 +0400
     4.2 +++ b/src/main/java/ru/alphatech/icfpc/game/strategy/YetAnotherStrategy.java	Mon Jun 20 01:59:43 2011 +0400
     4.3 @@ -1,5 +1,9 @@
     4.4  package ru.alphatech.icfpc.game.strategy;
     4.5  
     4.6 +import java.io.FileWriter;
     4.7 +import java.io.IOException;
     4.8 +import java.io.OutputStream;
     4.9 +import java.io.PrintStream;
    4.10  import java.util.LinkedList;
    4.11  import java.util.Queue;
    4.12  
    4.13 @@ -17,36 +21,49 @@
    4.14  	private int lastAttackedSlot = lastAttackedDefaultSlot;
    4.15  	AttackHelpPolicy helpPolicy = null;
    4.16  	AttackHelpPolicy attackPolicy = null;
    4.17 -	CallExpressionPolicy callAttack = null;
    4.18 +//	CallExpressionPolicy callAttack = null;
    4.19 +	PrintStream log = null;
    4.20  	
    4.21  	public YetAnotherStrategy(){
    4.22 -		helpPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.HELP, lastUsedSlot++, 8, 6, 5000, true);
    4.23 -		attackPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.ATTACK, 5, 6, lastAttackedSlot++, 9000, false);
    4.24 -		callAttack = new CallExpressionPolicy(9, 5, 0, true);
    4.25 +		helpPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.HELP, 7, lastUsedSlot++, 6, 5000);
    4.26 +		attackPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.ATTACK, 5, 6, lastAttackedSlot++, 4000);
    4.27 +//		callAttack = new CallExpressionPolicy(9, 5, 0, true);
    4.28  		batches.addAll(helpPolicy.getBatches());
    4.29  		batches.addAll(attackPolicy.getBatches());
    4.30 -		batches.addAll(callAttack.getBatches());
    4.31 -		
    4.32 +//		batches.addAll(callAttack.getBatches());
    4.33 +		try {
    4.34 +			log = new PrintStream("strategy.log");
    4.35 +		} catch (IOException e) {
    4.36 +		}
    4.37  	}
    4.38  
    4.39  	@Override
    4.40  	public Batch move(Player proponent, Player opponent) {
    4.41  		if(opponent.getSlot(lastAttackedSlot-1).getVitality() <= 0){
    4.42 +			log.println("opponent slot " + (lastAttackedSlot-1) + " is dead");
    4.43  			if(lastAttackedSlot > 254)
    4.44  				lastAttackedSlot = lastAttackedDefaultSlot;
    4.45  			batches.clear();
    4.46 -			attackPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.ATTACK, 5, 6, lastAttackedSlot++, 10000, false);
    4.47 -			callAttack = new CallExpressionPolicy(9, 5, 0, true);
    4.48 +			attackPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.ATTACK, 5, 6, lastAttackedSlot++, 4000);
    4.49 +//			callAttack = new CallExpressionPolicy(9, 5, 0, true);
    4.50  			batches.addAll(attackPolicy.getBatches());
    4.51 -			batches.addAll(callAttack.getBatches());
    4.52 +//			batches.addAll(callAttack.getBatches());
    4.53  		}
    4.54  		if(!batches.isEmpty())
    4.55  			return batches.poll();
    4.56 -		if(lastUsedSlot > 254)
    4.57 +		if(lastUsedSlot > 255)
    4.58  			lastUsedSlot = lastUsedDefaultSlot;
    4.59 -		AttackHelpPolicy helpPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.HELP, lastUsedSlot++, 8, 6, 5000, true);
    4.60 +		for(int i = 0; i <= 255; i++)
    4.61 +			if(opponent.getSlot(i).getVitality() != 10000)
    4.62 +				log.println("opponent slot " + (i) + " has " + opponent.getSlot(i).getVitality() + " vitality");
    4.63 +		for(int i = 0; i <= 255; i++)
    4.64 +			if(proponent.getSlot(i).getVitality() != 10000)
    4.65 +				log.println("proponent slot " + (i) + " has " + proponent.getSlot(i).getVitality() + " vitality");
    4.66 +		helpPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.HELP, 7, lastUsedSlot++, 6, 5000);
    4.67  		batches.addAll(helpPolicy.getBatches());
    4.68 -		batches.addAll(callAttack.getBatches());
    4.69 +		attackPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.ATTACK, 5, 6, lastAttackedSlot-1, 4000);
    4.70 +		batches.addAll(attackPolicy.getBatches());
    4.71 +//		batches.addAll(callAttack.getBatches());
    4.72  		return move(proponent, opponent);
    4.73  	}
    4.74