by akhmetovlz
authorakhmetovlz
Sat, 18 Jun 2011 19:40:17 +0400
changeset 19624552552ae7
parent 18 37d36410db78
child 20 d73e75df3cb6
by akhmetovlz
src/main/java/ru/alphatech/icfpc/game/Player.java
src/main/java/ru/alphatech/icfpc/policy/AbstractPolicy.java
src/main/java/ru/alphatech/icfpc/policy/VitalityBoostPolicy.java
     1.1 --- a/src/main/java/ru/alphatech/icfpc/game/Player.java	Sat Jun 18 15:31:12 2011 +0400
     1.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Player.java	Sat Jun 18 19:40:17 2011 +0400
     1.3 @@ -17,4 +17,8 @@
     1.4  	public void applySlotToCard(Slot slot, ICard card){
     1.5  		throw new RuntimeException("Not impilemented yet.");
     1.6  	}
     1.7 +	
     1.8 +	public PlayerStatistic getStatistic(){
     1.9 +		throw new RuntimeException("Not impilemented yet.");
    1.10 +	}
    1.11  }
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/main/java/ru/alphatech/icfpc/policy/AbstractPolicy.java	Sat Jun 18 19:40:17 2011 +0400
     2.3 @@ -0,0 +1,35 @@
     2.4 +package ru.alphatech.icfpc.policy;
     2.5 +
     2.6 +import ru.alphatech.icfpc.game.Player;
     2.7 +
     2.8 +public abstract class AbstractPolicy {
     2.9 +
    2.10 +	protected Player player = null;
    2.11 +	
    2.12 +	private int turnCount   = 0;
    2.13 +	private int turnCurrent = 0;
    2.14 +	
    2.15 +	public AbstractPolicy(int turnCount, Player player){
    2.16 +		this.player = player;
    2.17 +		this.turnCount = turnCount;
    2.18 +		this.turnCurrent = 0;
    2.19 +	}
    2.20 +	
    2.21 +	public int getCurrentTurns() {
    2.22 +		return turnCurrent;
    2.23 +	}
    2.24 +	
    2.25 +	public int getTurnsCount(){
    2.26 +		return turnCount;
    2.27 +	}
    2.28 +	
    2.29 +	public boolean next(){
    2.30 +		if( turnCurrent < turnCount ){
    2.31 +			turnCurrent++;
    2.32 +			return true;
    2.33 +		}
    2.34 +		return false;
    2.35 +	}
    2.36 +	
    2.37 +	
    2.38 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/main/java/ru/alphatech/icfpc/policy/VitalityBoostPolicy.java	Sat Jun 18 19:40:17 2011 +0400
     3.3 @@ -0,0 +1,55 @@
     3.4 +package ru.alphatech.icfpc.policy;
     3.5 +
     3.6 +import ru.alphatech.icfpc.cards.Dbl;
     3.7 +import ru.alphatech.icfpc.cards.Succ;
     3.8 +import ru.alphatech.icfpc.cards.Zero;
     3.9 +import ru.alphatech.icfpc.game.Player;
    3.10 +
    3.11 +public class VitalityBoostPolicy extends AbstractPolicy {
    3.12 +	
    3.13 +	public static final int turnsCount = 100;
    3.14 +	
    3.15 +	public VitalityBoostPolicy(int targetSlot, Player player) {
    3.16 +		super(turnsCount, player);
    3.17 +		this.targetSlot = targetSlot;
    3.18 +		
    3.19 +		maxValueSlotNum = player.getStatistic().maxValueSlotNum;
    3.20 +		maxValue = player.getStatistic().maxValue;
    3.21 +		firstIdentitySlot = -1;
    3.22 +	}
    3.23 +	
    3.24 +	protected int targetSlot = -1;
    3.25 +	protected int maxValueSlotNum = -1;
    3.26 +	protected int maxValue = -1;
    3.27 +	protected int firstIdentitySlot = -1;
    3.28 +	
    3.29 +	public boolean next() {
    3.30 +		if ( super.next() ){
    3.31 +			
    3.32 +			switch (getCurrentTurns()) {
    3.33 +				case 0:
    3.34 +					player.applySlotToCard(player.getSlot(firstIdentitySlot), );
    3.35 +				break;
    3.36 +				case 1:
    3.37 +				case 2:
    3.38 +					player.applyCardToSlot(new Succ(), player.getSlot(incValueSlotNum));
    3.39 +				break;
    3.40 +				case 3:
    3.41 +				case 4:
    3.42 +				case 5:
    3.43 +				case 6:
    3.44 +				case 7:
    3.45 +				case 8:
    3.46 +				case 9:
    3.47 +				case 10:
    3.48 +					player.applyCardToSlot(new Dbl(), player.getSlot(incValueSlotNum));
    3.49 +				break;
    3.50 +				case 11:
    3.51 +				break;
    3.52 +			}
    3.53 +			
    3.54 +		}
    3.55 +		return false;
    3.56 +	}
    3.57 +
    3.58 +}