(no commit message)
authorakhmetovlz
Sun, 19 Jun 2011 20:48:53 +0400
changeset 110d6c063577f0d
parent 109 6ae7d1eafd90
child 111 0b8b3ec13a82
child 112 d1b74db1d349
(no commit message)
src/main/java/ru/alphatech/icfpc/calculator/Calculator.java
src/main/java/ru/alphatech/icfpc/cards/AbstractCard.java
src/main/java/ru/alphatech/icfpc/game/Player.java
src/main/java/ru/alphatech/icfpc/game/strategy/SimplyStrategy.java
src/main/java/ru/alphatech/icfpc/policy/CallExpressionPolicy.java
     1.1 --- a/src/main/java/ru/alphatech/icfpc/calculator/Calculator.java	Sun Jun 19 20:22:02 2011 +0400
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,32 +0,0 @@
     1.4 -/**
     1.5 - * 
     1.6 - */
     1.7 -package ru.alphatech.icfpc.calculator;
     1.8 -
     1.9 -import javax.smartcardio.Card;
    1.10 -
    1.11 -import ru.alphatech.icfpc.cards.ICard;
    1.12 -import ru.alphatech.icfpc.game.IValue;
    1.13 -import ru.alphatech.icfpc.game.Player;
    1.14 -import ru.alphatech.icfpc.game.Value;
    1.15 -
    1.16 -/**
    1.17 - * @author rushan
    1.18 - *
    1.19 - */
    1.20 -public class Calculator
    1.21 -{
    1.22 -	public static IValue calculate(Player proponent, Player opponent, ICard function, IValue parameter)
    1.23 -	{
    1.24 -		if (parameter instanceof Value)
    1.25 -		{
    1.26 -			return function.returnValue(parameter, proponent, opponent);
    1.27 -		}
    1.28 -		else if (parameter instanceof ICard)
    1.29 -		{
    1.30 -//			IValue calc = calculate(proponent, opponent, parameter, parameter);
    1.31 -//			
    1.32 -		}
    1.33 -		return null;
    1.34 -	}
    1.35 -}
     2.1 --- a/src/main/java/ru/alphatech/icfpc/cards/AbstractCard.java	Sun Jun 19 20:22:02 2011 +0400
     2.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/AbstractCard.java	Sun Jun 19 20:48:53 2011 +0400
     2.3 @@ -5,12 +5,16 @@
     2.4   ***********************************************/
     2.5  package ru.alphatech.icfpc.cards;
     2.6  
     2.7 +//import java.util.ArrayList;
     2.8 +
     2.9  import ru.alphatech.icfpc.game.ICFPCException;
    2.10  import ru.alphatech.icfpc.game.Run;
    2.11  
    2.12  
    2.13  public abstract class AbstractCard implements ICard
    2.14  {
    2.15 +//	private ArrayList<ICard> hierarchy = new ArrayList<ICard>();
    2.16 +	
    2.17  	@Override
    2.18  	public void incAndTest()
    2.19  	{
    2.20 @@ -21,4 +25,6 @@
    2.21  			throw new ICFPCException();
    2.22  		}
    2.23  	}
    2.24 +	
    2.25 +	
    2.26  }
     3.1 --- a/src/main/java/ru/alphatech/icfpc/game/Player.java	Sun Jun 19 20:22:02 2011 +0400
     3.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Player.java	Sun Jun 19 20:48:53 2011 +0400
     3.3 @@ -1,6 +1,8 @@
     3.4  package ru.alphatech.icfpc.game;
     3.5  
     3.6  import ru.alphatech.icfpc.cards.I;
     3.7 +import ru.alphatech.icfpc.cards.ICard;
     3.8 +import ru.alphatech.icfpc.cards.Zero;
     3.9  
    3.10  
    3.11  
    3.12 @@ -40,7 +42,19 @@
    3.13  		try{
    3.14  			switch(batch.operationType){
    3.15  			case CARD_TO_SLOT:
    3.16 -				batch.card.returnValue(getSlot(batch.slot.getId()).getValue(), this, myOpponent);
    3.17 +				IValue value = getSlot(batch.slot.getId()).getValue();
    3.18 +				
    3.19 +				if(value instanceof Zero)
    3.20 +				{
    3.21 +					value = new Value(0);
    3.22 +				}
    3.23 +				
    3.24 +				if(batch.card instanceof Zero)
    3.25 +				{
    3.26 +					batch.card = (ICard) new Value(0);
    3.27 +				}
    3.28 +
    3.29 +				batch.card.returnValue(value, this, myOpponent);
    3.30  				break;
    3.31  			case SLOT_TO_CARD:
    3.32  				getSlot(batch.slot.getId()).getValue().returnValue(batch.card, this, myOpponent);
     4.1 --- a/src/main/java/ru/alphatech/icfpc/game/strategy/SimplyStrategy.java	Sun Jun 19 20:22:02 2011 +0400
     4.2 +++ b/src/main/java/ru/alphatech/icfpc/game/strategy/SimplyStrategy.java	Sun Jun 19 20:48:53 2011 +0400
     4.3 @@ -2,9 +2,12 @@
     4.4  
     4.5  import java.util.LinkedList;
     4.6  
     4.7 +import ru.alphatech.icfpc.cards.I;
     4.8  import ru.alphatech.icfpc.game.Batch;
     4.9  import ru.alphatech.icfpc.game.Player;
    4.10 +import ru.alphatech.icfpc.game.Batch.OperationType;
    4.11  import ru.alphatech.icfpc.policy.AttackHelpPolicy;
    4.12 +import ru.alphatech.icfpc.policy.CallExpressionPolicy;
    4.13  import ru.alphatech.icfpc.policy.AttackHelpPolicy.TYPE;
    4.14  
    4.15  /**
    4.16 @@ -19,12 +22,18 @@
    4.17  	public SimplyStrategy() {
    4.18  //		for(int i=0; i<100; ++i){
    4.19  		batches.addAll(new AttackHelpPolicy(TYPE.HELP, 10, 5, 5, 9999, false).getBatches());
    4.20 +		batches.addAll(new CallExpressionPolicy(8, 10, 0, true).getBatches());
    4.21 +		batches.addAll(new CallExpressionPolicy(8, 10, 0, true).getBatches());
    4.22 +		batches.addAll(new CallExpressionPolicy(8, 10, 0, true).getBatches());
    4.23 +		batches.addAll(new CallExpressionPolicy(8, 10, 0, true).getBatches());
    4.24 +		batches.addAll(new CallExpressionPolicy(8, 10, 0, true).getBatches());
    4.25  //		}
    4.26  	}
    4.27  	
    4.28  	@Override
    4.29  	public Batch move(Player proponent, Player opponent) {
    4.30 -		return batches.poll();//new Batch(OperationType.CARD_TO_SLOT, new I(), proponent.getSlot(0));//batches.poll();
    4.31 +		Batch batch = batches.poll();
    4.32 +		return batch != null ? batch : new Batch(OperationType.CARD_TO_SLOT, new I(), proponent.getSlot(0));
    4.33  	}
    4.34  
    4.35  }
     5.1 --- a/src/main/java/ru/alphatech/icfpc/policy/CallExpressionPolicy.java	Sun Jun 19 20:22:02 2011 +0400
     5.2 +++ b/src/main/java/ru/alphatech/icfpc/policy/CallExpressionPolicy.java	Sun Jun 19 20:48:53 2011 +0400
     5.3 @@ -60,7 +60,16 @@
     5.4  		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
     5.5  		
     5.6  		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
     5.7 +		
     5.8 +		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
     5.9 +		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
    5.10 +		
    5.11 +		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
    5.12 +		
    5.13  		//TODO от регистра
    5.14 +		if(execute)
    5.15 +		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
    5.16 +		
    5.17  		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
    5.18  		
    5.19  		return retArray;