Merge with 7e49c679fc70fb49d5168b5a9783a10088f171e0
authorAzamat S. Kalimoulline <turtle@bazon.ru>
Sun, 19 Jun 2011 13:32:30 +0400
changeset 5083ff9504b901
parent 49 2c94d860cd24
parent 48 7e49c679fc70
child 54 0ffe63f2aa46
child 57 4a82118416bd
Merge with 7e49c679fc70fb49d5168b5a9783a10088f171e0
src/test/java/ru/alphatech/icfpc/tests/TestGet.java
     1.1 --- a/src/main/java/ru/alphatech/icfpc/game/Player.java	Sun Jun 19 13:31:13 2011 +0400
     1.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Player.java	Sun Jun 19 13:32:30 2011 +0400
     1.3 @@ -6,7 +6,6 @@
     1.4  public class Player
     1.5  {
     1.6  	private Slot[] slots = new Slot[256];
     1.7 -	int registers[] = new int[4];
     1.8  	
     1.9  	public Player()
    1.10      {
    1.11 @@ -14,10 +13,6 @@
    1.12  		{
    1.13  			slots[i] = new Slot();
    1.14  		}
    1.15 -		registers[0] = 0;
    1.16 -		registers[1] = 1;
    1.17 -		registers[2] = 2;
    1.18 -		registers[3] = 3;
    1.19      }
    1.20  	
    1.21  	public Slot getSlot(int i)
    1.22 @@ -25,10 +20,6 @@
    1.23  		return slots[i];
    1.24  	}
    1.25  	
    1.26 -	public Slot getRegisterByIndex(int registerIdex){
    1.27 -		return getSlot( registers[registerIdex] );
    1.28 -	}
    1.29 -	
    1.30  	public void applyCardToSlot(ICard card, Slot slot){
    1.31  		throw new RuntimeException("Not impilemented yet.");
    1.32  	}
     2.1 --- a/src/main/java/ru/alphatech/icfpc/game/Run.java	Sun Jun 19 13:31:13 2011 +0400
     2.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Run.java	Sun Jun 19 13:32:30 2011 +0400
     2.3 @@ -19,14 +19,35 @@
     2.4  	
     2.5  	private static Player opponent = new Player();
     2.6  	
     2.7 -	private LinkedList<Batch> batches = new LinkedList<Batch>();
     2.8 +	private static LinkedList<Batch> batches = new LinkedList<Batch>();
     2.9  	
    2.10 -	public void clearBatcher(){
    2.11 +	private static int registers[] = new int[4];
    2.12 +	
    2.13 +	static {
    2.14 +		registers[0] = 0;
    2.15 +		registers[1] = 1;
    2.16 +		registers[2] = 2;
    2.17 +		registers[3] = 3;
    2.18 +	}
    2.19 +	
    2.20 +	public static Slot getRegisterByIndex(int registerIdex){
    2.21 +		return proponent.getSlot( registers[registerIdex] );
    2.22 +	}
    2.23 +	
    2.24 +	public static void clearBatcher(){
    2.25  		batches.removeAll(batches);
    2.26  	}
    2.27  	
    2.28 -	public void addBatcher(List<Batch> batches){
    2.29 -		this.batches.addAll(this.batches);
    2.30 +	public static void addBatcher(List<Batch> batches){
    2.31 +		batches.addAll(batches);
    2.32 +	}
    2.33 +	
    2.34 +	public static Player getOpponent(){
    2.35 +		return opponent;
    2.36 +	}
    2.37 +	
    2.38 +	public static Player getProponent(){
    2.39 +		return proponent;
    2.40  	}
    2.41  	
    2.42  	private static void readOpponent() throws IOException
     3.1 --- a/src/main/java/ru/alphatech/icfpc/policy/AbstractPolicy.java	Sun Jun 19 13:31:13 2011 +0400
     3.2 +++ b/src/main/java/ru/alphatech/icfpc/policy/AbstractPolicy.java	Sun Jun 19 13:32:30 2011 +0400
     3.3 @@ -10,6 +10,7 @@
     3.4  import ru.alphatech.icfpc.game.Batch;
     3.5  import ru.alphatech.icfpc.game.IValue;
     3.6  import ru.alphatech.icfpc.game.Player;
     3.7 +import ru.alphatech.icfpc.game.Run;
     3.8  import ru.alphatech.icfpc.game.Slot;
     3.9  import ru.alphatech.icfpc.game.Value;
    3.10  import ru.alphatech.icfpc.game.Batch.OperationType;
    3.11 @@ -23,17 +24,14 @@
    3.12   */
    3.13  public abstract class AbstractPolicy {
    3.14  
    3.15 -	protected Player player = null;
    3.16 -	
    3.17  	protected ArrayList<Batch> batches = new ArrayList<Batch>();
    3.18  	
    3.19 -	public AbstractPolicy(Player player){
    3.20 -		this.player = player;
    3.21 +	public AbstractPolicy(){
    3.22  	}	
    3.23  	
    3.24  	public void setRegister(int registerIndex, int num ){
    3.25  		if( registerIndex < 4) {
    3.26 -			Slot registerSlot = player.getRegisterByIndex(registerIndex);
    3.27 +			Slot registerSlot = Run.getRegisterByIndex(registerIndex);
    3.28  			batches.addAll( numberIntoSlotField( registerSlot, num ) );
    3.29  		}
    3.30  	}
     4.1 --- a/src/main/java/ru/alphatech/icfpc/policy/VitalityBoostPolicy.java	Sun Jun 19 13:31:13 2011 +0400
     4.2 +++ b/src/main/java/ru/alphatech/icfpc/policy/VitalityBoostPolicy.java	Sun Jun 19 13:32:30 2011 +0400
     4.3 @@ -3,12 +3,11 @@
     4.4  import java.util.ArrayList;
     4.5  
     4.6  import ru.alphatech.icfpc.game.Batch;
     4.7 -import ru.alphatech.icfpc.game.Player;
     4.8  
     4.9  public class VitalityBoostPolicy extends AbstractPolicy {
    4.10  
    4.11 -	public VitalityBoostPolicy(Player player) {
    4.12 -		super(player);
    4.13 +	public VitalityBoostPolicy() {
    4.14 +		super();
    4.15  	}
    4.16  
    4.17  	@Override
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/test/java/ru/alphatech/icfpc/cards/tests/TestGet.java	Sun Jun 19 13:32:30 2011 +0400
     5.3 @@ -0,0 +1,19 @@
     5.4 +package ru.alphatech.icfpc.cards.tests;
     5.5 +
     5.6 +import static org.junit.Assert.*;
     5.7 +
     5.8 +import org.junit.Test;
     5.9 +
    5.10 +/**
    5.11 + * @author indvdum
    5.12 + * 18.06.2011 19:42:44
    5.13 + *
    5.14 + */
    5.15 +public class TestGet {
    5.16 +
    5.17 +	@Test
    5.18 +	public final void testReturnValue() {
    5.19 +		assertEquals("test", "test");
    5.20 +	}
    5.21 +
    5.22 +}
     6.1 --- a/src/test/java/ru/alphatech/icfpc/tests/TestGet.java	Sun Jun 19 13:31:13 2011 +0400
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,19 +0,0 @@
     6.4 -package ru.alphatech.icfpc.tests;
     6.5 -
     6.6 -import static org.junit.Assert.*;
     6.7 -
     6.8 -import org.junit.Test;
     6.9 -
    6.10 -/**
    6.11 - * @author indvdum
    6.12 - * 18.06.2011 19:42:44
    6.13 - *
    6.14 - */
    6.15 -public class TestGet {
    6.16 -
    6.17 -	@Test
    6.18 -	public final void testReturnValue() {
    6.19 -		assertEquals("test", "test");
    6.20 -	}
    6.21 -
    6.22 -}