merge
author0-range@bazon.ru
Sun, 19 Jun 2011 18:42:07 +0400
changeset 9819dba9e387ce
parent 97 89f13f209302
parent 96 8c40512777a1
child 100 875773ff406b
child 102 cc814352ab43
merge
     1.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Attack.java	Sun Jun 19 17:53:59 2011 +0400
     1.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Attack.java	Sun Jun 19 18:42:07 2011 +0400
     1.3 @@ -3,21 +3,36 @@
     1.4  import ru.alphatech.icfpc.game.ICFPCException;
     1.5  import ru.alphatech.icfpc.game.IValue;
     1.6  import ru.alphatech.icfpc.game.Player;
     1.7 +import ru.alphatech.icfpc.game.Run;
     1.8  import ru.alphatech.icfpc.game.Value;
     1.9  
    1.10  public class Attack implements ICard
    1.11  {
    1.12  	@Override
    1.13 +	public String getName() {
    1.14 +		return "attack";
    1.15 +	}
    1.16 +
    1.17 +	@Override
    1.18  	public IValue returnValue(final IValue iobj, Player proponent, Player opponent)
    1.19  	{
    1.20  		return new ICard()
    1.21  		{
    1.22  			@Override
    1.23 +			public String getName() {
    1.24 +				return "";
    1.25 +			}
    1.26 +			
    1.27 +			@Override
    1.28  			public IValue returnValue(final IValue jobj, Player proponent, Player opponent)
    1.29  			{
    1.30  				return new ICard()
    1.31  				{
    1.32  					@Override
    1.33 +					public String getName() {
    1.34 +						return "";
    1.35 +					}
    1.36 +					@Override
    1.37  					public IValue returnValue(final IValue nobj, Player proponent, Player opponent)
    1.38  					{
    1.39  						if(iobj instanceof Value && nobj instanceof Value)
    1.40 @@ -39,13 +54,26 @@
    1.41  										{
    1.42  											int w = opponent.getSlot(255 - j).getVitality();
    1.43  											
    1.44 -											if (w > 0)
    1.45 +											if(Run.getAutoMode())
    1.46  											{
    1.47 -												int wdec = (int) Math.floor(9 * n / 10);
    1.48 -												int resw = w - wdec;
    1.49 +												if(w > 0)
    1.50 +												{
    1.51 +													int wdec = (int) Math.floor(9 * n / 10);
    1.52 +													int resw = w + wdec;
    1.53  
    1.54 -												opponent.getSlot(255 - j).setVitality(resw < 0 ? 0 : w);
    1.55 +													opponent.getSlot(255 - j).setVitality(resw > 65535 ? 65535 : w);
    1.56 +												}
    1.57  											}
    1.58 +											else
    1.59 +											{
    1.60 +												if (w > 0)
    1.61 +												{
    1.62 +													int wdec = (int) Math.floor(9 * n / 10);
    1.63 +													int resw = w - wdec;
    1.64 +
    1.65 +													opponent.getSlot(255 - j).setVitality(resw < 0 ? 0 : w);
    1.66 +												}
    1.67 +											}											
    1.68  
    1.69  											return new I();
    1.70  										}
     2.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Copy.java	Sun Jun 19 17:53:59 2011 +0400
     2.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Copy.java	Sun Jun 19 18:42:07 2011 +0400
     2.3 @@ -8,6 +8,11 @@
     2.4  public class Copy implements ICard
     2.5  {
     2.6  	@Override
     2.7 +	public String getName() {
     2.8 +		return "copy";
     2.9 +	}
    2.10 +	
    2.11 +	@Override
    2.12  	public IValue returnValue(IValue iobj, Player proponent, Player opponent)
    2.13  	{
    2.14  		if (iobj instanceof Value)
     3.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Dbl.java	Sun Jun 19 17:53:59 2011 +0400
     3.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Dbl.java	Sun Jun 19 18:42:07 2011 +0400
     3.3 @@ -8,6 +8,11 @@
     3.4  public class Dbl implements ICard
     3.5  {
     3.6  	@Override
     3.7 +	public String getName() {
     3.8 +		return "dbl";
     3.9 +	}
    3.10 +	
    3.11 +	@Override
    3.12  	public IValue returnValue(IValue nobj, Player proponent, Player opponent)
    3.13  	{
    3.14  		if(nobj instanceof Value)
     4.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Dec.java	Sun Jun 19 17:53:59 2011 +0400
     4.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Dec.java	Sun Jun 19 18:42:07 2011 +0400
     4.3 @@ -3,11 +3,17 @@
     4.4  import ru.alphatech.icfpc.game.ICFPCException;
     4.5  import ru.alphatech.icfpc.game.IValue;
     4.6  import ru.alphatech.icfpc.game.Player;
     4.7 +import ru.alphatech.icfpc.game.Run;
     4.8  import ru.alphatech.icfpc.game.Value;
     4.9  
    4.10  public class Dec implements ICard
    4.11  {
    4.12  	@Override
    4.13 +	public String getName() {
    4.14 +		return "dec";
    4.15 +	}
    4.16 +	
    4.17 +	@Override
    4.18  	public IValue returnValue(IValue iobj, Player proponent, Player opponent)
    4.19  	{
    4.20  		if(iobj instanceof Value)
    4.21 @@ -18,9 +24,19 @@
    4.22  			{
    4.23  				int v = proponent.getSlot(255 - i).getVitality();
    4.24  				
    4.25 -				if (v > 0)
    4.26 +				if(Run.getAutoMode())
    4.27  				{
    4.28 -					proponent.getSlot(255 - i).setVitality(v - 1);
    4.29 +					if(v > 0 && v < 65535)
    4.30 +					{
    4.31 +						proponent.getSlot(255 - i).setVitality(v + 1);
    4.32 +					}
    4.33 +				}
    4.34 +				else
    4.35 +				{
    4.36 +					if (v > 0)
    4.37 +					{
    4.38 +						proponent.getSlot(255 - i).setVitality(v - 1);
    4.39 +					}
    4.40  				}
    4.41  
    4.42  				return new I();
     5.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Get.java	Sun Jun 19 17:53:59 2011 +0400
     5.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Get.java	Sun Jun 19 18:42:07 2011 +0400
     5.3 @@ -8,6 +8,11 @@
     5.4  public class Get implements ICard
     5.5  {
     5.6  	@Override
     5.7 +	public String getName() {
     5.8 +		return "get";
     5.9 +	}
    5.10 +	
    5.11 +	@Override
    5.12  	public IValue returnValue(IValue iobj, Player proponent, Player opponent)
    5.13  	{
    5.14  		if (iobj instanceof Value)
     6.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Help.java	Sun Jun 19 17:53:59 2011 +0400
     6.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Help.java	Sun Jun 19 18:42:07 2011 +0400
     6.3 @@ -3,21 +3,37 @@
     6.4  import ru.alphatech.icfpc.game.ICFPCException;
     6.5  import ru.alphatech.icfpc.game.IValue;
     6.6  import ru.alphatech.icfpc.game.Player;
     6.7 +import ru.alphatech.icfpc.game.Run;
     6.8  import ru.alphatech.icfpc.game.Value;
     6.9  
    6.10  public class Help implements ICard
    6.11  {
    6.12  	@Override
    6.13 +	public String getName() {
    6.14 +		return "help";
    6.15 +	}
    6.16 +	
    6.17 +	@Override
    6.18  	public IValue returnValue(final IValue iobj, Player proponent, Player opponent)
    6.19  	{
    6.20  		return new ICard()
    6.21  		{
    6.22  			@Override
    6.23 +			public String getName() {
    6.24 +				return "";
    6.25 +			}
    6.26 +			
    6.27 +			@Override
    6.28  			public IValue returnValue(final IValue jobj, Player proponent, Player opponent)
    6.29  			{
    6.30  				return new ICard()
    6.31  				{
    6.32  					@Override
    6.33 +					public String getName() {
    6.34 +						return "";
    6.35 +					}
    6.36 +					
    6.37 +					@Override
    6.38  					public IValue returnValue(final IValue nobj, Player proponent, Player opponent)
    6.39  					{
    6.40  						if(iobj instanceof Value && nobj instanceof Value)
    6.41 @@ -39,13 +55,26 @@
    6.42  										{
    6.43  											int w = proponent.getSlot(j).getVitality();
    6.44  											
    6.45 -											if(w > 0)
    6.46 +											if(Run.getAutoMode())
    6.47  											{
    6.48 -												int winc = (int) Math.floor(11 * n / 10);
    6.49 -												int resw = w + winc;
    6.50 -												
    6.51 -												proponent.getSlot(j).setVitality(resw > 65535 ? 65535 : resw);
    6.52 +												if(w > 0)
    6.53 +												{
    6.54 +													int winc = (int) Math.floor(11 * n / 10);
    6.55 +													int resw = w - winc;
    6.56 +													
    6.57 +													proponent.getSlot(j).setVitality(resw < 0 ? 0 : resw);
    6.58 +												}
    6.59  											}
    6.60 +											else
    6.61 +											{
    6.62 +												if(w > 0)
    6.63 +												{
    6.64 +													int winc = (int) Math.floor(11 * n / 10);
    6.65 +													int resw = w + winc;
    6.66 +													
    6.67 +													proponent.getSlot(j).setVitality(resw > 65535 ? 65535 : resw);
    6.68 +												}
    6.69 +											}											
    6.70  											
    6.71  											return new I();
    6.72  										}
     7.1 --- a/src/main/java/ru/alphatech/icfpc/cards/I.java	Sun Jun 19 17:53:59 2011 +0400
     7.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/I.java	Sun Jun 19 18:42:07 2011 +0400
     7.3 @@ -6,6 +6,11 @@
     7.4  public class I implements ICard
     7.5  {
     7.6  	@Override
     7.7 +	public String getName() {
     7.8 +		return "I";
     7.9 +	}
    7.10 +	
    7.11 +	@Override
    7.12  	public IValue returnValue(IValue x, Player proponent, Player opponent)
    7.13  	{
    7.14  		return x;
     8.1 --- a/src/main/java/ru/alphatech/icfpc/cards/ICard.java	Sun Jun 19 17:53:59 2011 +0400
     8.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/ICard.java	Sun Jun 19 18:42:07 2011 +0400
     8.3 @@ -5,5 +5,6 @@
     8.4  
     8.5  public interface ICard extends IValue
     8.6  {
     8.7 +	public String getName();
     8.8  	public IValue returnValue(final IValue value, Player proponent, Player opponent);
     8.9  }
     9.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Inc.java	Sun Jun 19 17:53:59 2011 +0400
     9.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Inc.java	Sun Jun 19 18:42:07 2011 +0400
     9.3 @@ -3,11 +3,17 @@
     9.4  import ru.alphatech.icfpc.game.ICFPCException;
     9.5  import ru.alphatech.icfpc.game.IValue;
     9.6  import ru.alphatech.icfpc.game.Player;
     9.7 +import ru.alphatech.icfpc.game.Run;
     9.8  import ru.alphatech.icfpc.game.Value;
     9.9  
    9.10  public class Inc implements ICard
    9.11  {
    9.12  	@Override
    9.13 +	public String getName() {
    9.14 +		return "inc";
    9.15 +	}
    9.16 +	
    9.17 +	@Override
    9.18  	public IValue returnValue(IValue iobj, Player proponent, Player opponent)
    9.19  	{
    9.20  		if(iobj instanceof Value)
    9.21 @@ -18,9 +24,19 @@
    9.22  			{
    9.23  				int v = proponent.getSlot(i).getVitality();
    9.24  				
    9.25 -				if (v > 0 && v < 65535)
    9.26 +				if(Run.getAutoMode())
    9.27  				{
    9.28 -					proponent.getSlot(i).setVitality(v + 1);
    9.29 +					if(v > 0)
    9.30 +					{
    9.31 +						proponent.getSlot(i).setVitality(v - 1);
    9.32 +					}
    9.33 +				}
    9.34 +				else
    9.35 +				{
    9.36 +					if (v > 0 && v < 65535)
    9.37 +					{
    9.38 +						proponent.getSlot(i).setVitality(v + 1);
    9.39 +					}
    9.40  				}
    9.41  				
    9.42  				return new I();
    10.1 --- a/src/main/java/ru/alphatech/icfpc/cards/K.java	Sun Jun 19 17:53:59 2011 +0400
    10.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/K.java	Sun Jun 19 18:42:07 2011 +0400
    10.3 @@ -6,10 +6,20 @@
    10.4  public class K implements ICard
    10.5  {
    10.6  	@Override
    10.7 +	public String getName() {
    10.8 +		return "K";
    10.9 +	}
   10.10 +	
   10.11 +	@Override
   10.12  	public IValue returnValue(final IValue x, Player proponent, Player opponent)
   10.13  	{
   10.14  		return new ICard()
   10.15  		{
   10.16 +			@Override
   10.17 +			public String getName() {
   10.18 +				return "";
   10.19 +			}
   10.20 +			
   10.21  			public IValue returnValue(IValue y, Player proponent, Player opponent)
   10.22  			{
   10.23  				return y;
    11.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Put.java	Sun Jun 19 17:53:59 2011 +0400
    11.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Put.java	Sun Jun 19 18:42:07 2011 +0400
    11.3 @@ -6,11 +6,21 @@
    11.4  public class Put implements ICard
    11.5  {
    11.6  	@Override
    11.7 +	public String getName() {
    11.8 +		return "put";
    11.9 +	}
   11.10 +	
   11.11 +	@Override
   11.12  	public IValue returnValue(IValue x, Player proponent, Player opponent)
   11.13  	{
   11.14  		return new ICard()
   11.15  		{
   11.16  			@Override
   11.17 +			public String getName() {
   11.18 +				return "";
   11.19 +			}
   11.20 +			
   11.21 +			@Override
   11.22  			public IValue returnValue(IValue value, Player proponent, Player opponent)
   11.23  			{
   11.24  				return new I();
    12.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Revive.java	Sun Jun 19 17:53:59 2011 +0400
    12.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Revive.java	Sun Jun 19 18:42:07 2011 +0400
    12.3 @@ -8,6 +8,11 @@
    12.4  public class Revive implements ICard
    12.5  {
    12.6  	@Override
    12.7 +	public String getName() {
    12.8 +		return "revive";
    12.9 +	}
   12.10 +	
   12.11 +	@Override
   12.12  	public IValue returnValue(IValue iobj, Player proponent, Player opponent)
   12.13  	{
   12.14  		if (iobj instanceof Value)
    13.1 --- a/src/main/java/ru/alphatech/icfpc/cards/S.java	Sun Jun 19 17:53:59 2011 +0400
    13.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/S.java	Sun Jun 19 18:42:07 2011 +0400
    13.3 @@ -6,14 +6,29 @@
    13.4  public class S implements ICard
    13.5  {
    13.6  	@Override
    13.7 +	public String getName() {
    13.8 +		return "S";
    13.9 +	}
   13.10 +	
   13.11 +	@Override
   13.12  	public IValue returnValue(final IValue f, Player proponent, Player opponent)
   13.13  	{
   13.14  		return new ICard()
   13.15  		{
   13.16 +			@Override
   13.17 +			public String getName() {
   13.18 +				return "";
   13.19 +			}
   13.20 +			
   13.21  			public IValue returnValue(final IValue g, Player proponent, Player opponent)
   13.22  			{
   13.23  				return new ICard()
   13.24  				{
   13.25 +					@Override
   13.26 +					public String getName() {
   13.27 +						return "";
   13.28 +					}
   13.29 +					
   13.30  					public IValue returnValue(final IValue x, Player proponent, Player opponent)
   13.31  					{
   13.32  						IValue h = f.returnValue(x, proponent, opponent);
    14.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Succ.java	Sun Jun 19 17:53:59 2011 +0400
    14.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Succ.java	Sun Jun 19 18:42:07 2011 +0400
    14.3 @@ -8,6 +8,11 @@
    14.4  public class Succ implements ICard
    14.5  {
    14.6  	@Override
    14.7 +	public String getName() {
    14.8 +		return "succ";
    14.9 +	}
   14.10 +	
   14.11 +	@Override
   14.12  	public IValue returnValue(IValue nobj, Player proponent, Player opponent)
   14.13  	{
   14.14  		if(nobj instanceof Value)
    15.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Zero.java	Sun Jun 19 17:53:59 2011 +0400
    15.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Zero.java	Sun Jun 19 18:42:07 2011 +0400
    15.3 @@ -6,6 +6,11 @@
    15.4  
    15.5  public class Zero implements ICard
    15.6  {
    15.7 +	@Override
    15.8 +	public String getName() {
    15.9 +		return "zero";
   15.10 +	}
   15.11 +	
   15.12  	public IValue returnValue(IValue value, Player proponent, Player opponent)
   15.13  	{
   15.14  		return new Value(0);
    16.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Zombie.java	Sun Jun 19 17:53:59 2011 +0400
    16.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Zombie.java	Sun Jun 19 18:42:07 2011 +0400
    16.3 @@ -8,11 +8,21 @@
    16.4  public class Zombie implements ICard
    16.5  {
    16.6  	@Override
    16.7 +	public String getName() {
    16.8 +		return "zombie";
    16.9 +	}
   16.10 +	
   16.11 +	@Override
   16.12  	public IValue returnValue(final IValue iobj, Player proponent, Player opponent)
   16.13  	{
   16.14  		return new ICard()
   16.15  		{
   16.16  			@Override
   16.17 +			public String getName() {
   16.18 +				return "";
   16.19 +			}
   16.20 +			
   16.21 +			@Override
   16.22  			public IValue returnValue(final IValue x, Player proponent, Player opponent)
   16.23  			{
   16.24  				if (iobj instanceof Value)
    17.1 --- a/src/main/java/ru/alphatech/icfpc/game/AbstractPolicy.java	Sun Jun 19 17:53:59 2011 +0400
    17.2 +++ b/src/main/java/ru/alphatech/icfpc/game/AbstractPolicy.java	Sun Jun 19 18:42:07 2011 +0400
    17.3 @@ -1,6 +1,8 @@
    17.4  package ru.alphatech.icfpc.game;
    17.5  
    17.6  import java.util.ArrayList;
    17.7 +import java.util.Collections;
    17.8 +import java.util.List;
    17.9  
   17.10  import ru.alphatech.icfpc.cards.Attack;
   17.11  import ru.alphatech.icfpc.cards.Dbl;
   17.12 @@ -74,80 +76,57 @@
   17.13  		return retArray;
   17.14  	}
   17.15  	
   17.16 -	protected ArrayList<Batch> smartAlg(int begin, int end, Slot targetSlot){
   17.17 +	protected static List<Batch> smartAlg(int begin, int end, Slot targetSlot){
   17.18  		ArrayList<Batch> retArray = new ArrayList<Batch>();
   17.19  		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), targetSlot));
   17.20  		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), targetSlot));
   17.21 -		while(end >= 2){
   17.22 -			int d = end % 2;
   17.23 -			if( d == 0 ) {
   17.24 -				retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Dbl() , targetSlot));
   17.25 -			} else {
   17.26 -				retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Dbl() , targetSlot));
   17.27 -				retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Succ(), targetSlot));
   17.28 -			}
   17.29 -			end = end / 2; 
   17.30 +		
   17.31 +		List<Batch> list1 = buildNumberOperations(0, end, targetSlot);
   17.32 +		List<Batch> list2 = buildNumberOperations(begin, end, targetSlot);
   17.33 +		if (list1.size() <= list2.size())
   17.34 +		{
   17.35 +			Collections.reverse(list1);
   17.36 +			retArray.addAll(list1);
   17.37 +		}
   17.38 +		else
   17.39 +		{
   17.40 +			Collections.reverse(list2);
   17.41 +			retArray.addAll(list2);
   17.42  		}
   17.43  		return retArray;
   17.44  	}
   17.45  	
   17.46 -	protected ArrayList<Batch> BcombineForFunctWith3ParamsInRegister(ICard function, Slot processingSlot){
   17.47 -		ArrayList<Batch> retArray = new ArrayList<Batch>();
   17.48 +	protected static List<Batch> buildNumberOperations(int begin, int end, Slot targetSlot){
   17.49 +		List<Batch> list = new ArrayList<Batch>();
   17.50  		
   17.51 -		if(!(function instanceof Attack || function instanceof Help)){
   17.52 -			throw new ICFPCException();
   17.53 +		while(end >= 2){
   17.54 +			int d = end % 2;
   17.55 +			if (begin > 0 && 2*begin > end)
   17.56 +			{
   17.57 +				for (int i = 0; i < end - begin; i++)
   17.58 +				{
   17.59 +					list.add(new Batch(OperationType.CARD_TO_SLOT, new Succ(), targetSlot));
   17.60 +				}
   17.61 +				break;
   17.62 +			}
   17.63 +			if( d == 0 ) {
   17.64 +				list.add(new Batch(OperationType.CARD_TO_SLOT, new Dbl() , targetSlot));
   17.65 +				end = end / 2;
   17.66 +			} else {
   17.67 +				list.add(new Batch(OperationType.CARD_TO_SLOT, new Succ(), targetSlot));
   17.68 +				list.add(new Batch(OperationType.CARD_TO_SLOT, new Dbl() , targetSlot));
   17.69 +				end = (end-1) / 2;
   17.70 +			}
   17.71  		}
   17.72 -		
   17.73 -		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), processingSlot));
   17.74 -		retArray.add(new Batch(OperationType.SLOT_TO_CARD, function,  processingSlot));
   17.75 -		
   17.76 -		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
   17.77 -		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
   17.78 -		
   17.79 -		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
   17.80 -
   17.81 -		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
   17.82 -		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
   17.83 -		
   17.84 -		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
   17.85 -		
   17.86 -		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
   17.87 -		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
   17.88 -		
   17.89 -		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
   17.90 -
   17.91 -		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
   17.92 -		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
   17.93 -		
   17.94 -		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Succ(), processingSlot));
   17.95 -		
   17.96 -		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
   17.97 -		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
   17.98 -		
   17.99 -		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
  17.100 -		
  17.101 -		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
  17.102 -		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
  17.103 -		
  17.104 -		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
  17.105 -
  17.106 -		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
  17.107 -		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
  17.108 -		
  17.109 -		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Succ(), processingSlot));
  17.110 -		
  17.111 -		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
  17.112 -		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
  17.113 -		
  17.114 -		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Succ(), processingSlot));
  17.115 -		
  17.116 -		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
  17.117 -		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
  17.118 -		
  17.119 -		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
  17.120 -		
  17.121 -		return retArray;
  17.122 +		return list;
  17.123  	}
  17.124  	
  17.125  	public abstract ArrayList<Batch> getBatches();
  17.126 +	
  17.127 +	public static void main(String[] args)
  17.128 +	{
  17.129 +		Slot slot = new Slot(1);
  17.130 +		List<Batch> list = smartAlg(5, 12, slot);
  17.131 +		System.out.println(list.toArray().toString());
  17.132 +	}
  17.133  }
    18.1 --- a/src/main/java/ru/alphatech/icfpc/game/Batch.java	Sun Jun 19 17:53:59 2011 +0400
    18.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Batch.java	Sun Jun 19 18:42:07 2011 +0400
    18.3 @@ -15,9 +15,31 @@
    18.4  	public Slot  slot = null;
    18.5  	
    18.6  	public Batch(OperationType type, ICard card, Slot slot){
    18.7 +		if(type == null || card == null || slot == null)
    18.8 +			throw new ICFPCException("Illegal constructor using!");
    18.9  		this.operationType = type;
   18.10  		this.card = card;
   18.11  		this.slot = slot;
   18.12  	}
   18.13 +
   18.14 +	@Override
   18.15 +	public String toString() {
   18.16 +		if(operationType == null || card == null || slot == null)
   18.17 +			throw new ICFPCException();
   18.18 +		StringBuilder ret = new StringBuilder();
   18.19 +		switch(operationType){
   18.20 +		case CARD_TO_SLOT:
   18.21 +			ret.append("1\n");
   18.22 +			ret.append(card.getName() + "\n");
   18.23 +			ret.append(slot.getId() + "\n");
   18.24 +			break;
   18.25 +		case SLOT_TO_CARD:
   18.26 +			ret.append("2\n");
   18.27 +			ret.append(slot.getId() + "\n");
   18.28 +			ret.append(card.getName() + "\n");
   18.29 +			break;
   18.30 +		}
   18.31 +		return ret.toString();
   18.32 +	}
   18.33  	
   18.34  }
    19.1 --- a/src/main/java/ru/alphatech/icfpc/game/ICFPCException.java	Sun Jun 19 17:53:59 2011 +0400
    19.2 +++ b/src/main/java/ru/alphatech/icfpc/game/ICFPCException.java	Sun Jun 19 18:42:07 2011 +0400
    19.3 @@ -4,4 +4,12 @@
    19.4  public class ICFPCException extends RuntimeException
    19.5  {
    19.6  	
    19.7 +	public ICFPCException(){
    19.8 +		super();
    19.9 +	}
   19.10 +
   19.11 +	public ICFPCException(String string) {
   19.12 +		super(string);
   19.13 +	}
   19.14 +	
   19.15  }
    20.1 --- a/src/main/java/ru/alphatech/icfpc/game/Player.java	Sun Jun 19 17:53:59 2011 +0400
    20.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Player.java	Sun Jun 19 18:42:07 2011 +0400
    20.3 @@ -1,6 +1,5 @@
    20.4  package ru.alphatech.icfpc.game;
    20.5  
    20.6 -import ru.alphatech.icfpc.cards.ICard;
    20.7  
    20.8  
    20.9  public class Player
   20.10 @@ -11,7 +10,7 @@
   20.11      {
   20.12  		for(int i = 0; i < 255; i++)
   20.13  		{
   20.14 -			slots[i] = new Slot();
   20.15 +			slots[i] = new Slot(i);
   20.16  		}
   20.17      }
   20.18  	
   20.19 @@ -20,17 +19,12 @@
   20.20  		return slots[i];
   20.21  	}
   20.22  	
   20.23 -	public void applyCardToSlot(ICard card, Slot slot){
   20.24 -		throw new RuntimeException("Not impilemented yet.");
   20.25 -	}
   20.26 -	
   20.27 -	public void applySlotToCard(Slot slot, ICard card){
   20.28 -		throw new RuntimeException("Not impilemented yet.");
   20.29 -	}
   20.30 -	
   20.31  	public PlayerStatistic getStatistic(){
   20.32  		throw new RuntimeException("Not impilemented yet.");
   20.33  	}
   20.34  	
   20.35 +	public void applyBatch(Batch batch){
   20.36 +		
   20.37 +	}
   20.38  	
   20.39  }
    21.1 --- a/src/main/java/ru/alphatech/icfpc/game/Run.java	Sun Jun 19 17:53:59 2011 +0400
    21.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Run.java	Sun Jun 19 18:42:07 2011 +0400
    21.3 @@ -8,22 +8,37 @@
    21.4  import java.io.BufferedReader;
    21.5  import java.io.IOException;
    21.6  import java.io.InputStreamReader;
    21.7 -import java.util.LinkedList;
    21.8 -import java.util.List;
    21.9  
   21.10 +import ru.alphatech.icfpc.cards.Attack;
   21.11 +import ru.alphatech.icfpc.cards.Copy;
   21.12 +import ru.alphatech.icfpc.cards.Dbl;
   21.13 +import ru.alphatech.icfpc.cards.Dec;
   21.14 +import ru.alphatech.icfpc.cards.Get;
   21.15 +import ru.alphatech.icfpc.cards.Help;
   21.16 +import ru.alphatech.icfpc.cards.I;
   21.17 +import ru.alphatech.icfpc.cards.ICard;
   21.18 +import ru.alphatech.icfpc.cards.Inc;
   21.19 +import ru.alphatech.icfpc.cards.K;
   21.20 +import ru.alphatech.icfpc.cards.Put;
   21.21 +import ru.alphatech.icfpc.cards.Revive;
   21.22 +import ru.alphatech.icfpc.cards.S;
   21.23 +import ru.alphatech.icfpc.cards.Succ;
   21.24 +import ru.alphatech.icfpc.cards.Zero;
   21.25 +import ru.alphatech.icfpc.cards.Zombie;
   21.26 +import ru.alphatech.icfpc.game.Batch.OperationType;
   21.27  import ru.alphatech.icfpc.game.strategy.IStrategy;
   21.28  import ru.alphatech.icfpc.game.strategy.SimplyStrategy;
   21.29  
   21.30  public class Run
   21.31  {
   21.32 +	private static boolean automodeapply = false;
   21.33 +
   21.34  	private static boolean endgame = false;
   21.35  	
   21.36  	private static Player proponent = new Player();
   21.37  	
   21.38  	private static Player opponent = new Player();
   21.39  	
   21.40 -	private static LinkedList<Batch> batches = new LinkedList<Batch>();
   21.41 -	
   21.42  	private static int registers[] = new int[4];
   21.43  	
   21.44  	static {
   21.45 @@ -35,16 +50,12 @@
   21.46  	
   21.47  	private static IStrategy strategy = new SimplyStrategy();
   21.48  	
   21.49 -	public static Slot getRegisterByIndex(int registerIdex){
   21.50 -		return proponent.getSlot( registers[registerIdex] );
   21.51 +	public static Slot getRegisterByIndex(int registerIndex){
   21.52 +		return proponent.getSlot( registers[registerIndex] );
   21.53  	}
   21.54  	
   21.55 -	public static void clearBatcher(){
   21.56 -		batches.removeAll(batches);
   21.57 -	}
   21.58 -	
   21.59 -	public static void addBatcher(List<Batch> batches){
   21.60 -		batches.addAll(batches);
   21.61 +	public static int getRegisterSlotNum(int registerIndex ){
   21.62 +		return registers[registerIndex];
   21.63  	}
   21.64  	
   21.65  	public static Player getOpponent(){
   21.66 @@ -58,36 +69,76 @@
   21.67  	private static void readOpponent() throws IOException
   21.68  	{
   21.69  		BufferedReader breader = new BufferedReader(new InputStreamReader(System.in));
   21.70 -		String turnCase = breader.readLine();
   21.71 -		String card = null;
   21.72 -		String slot = null;
   21.73 +		String sTurnCase = breader.readLine();
   21.74 +		String sCard = null;
   21.75 +		String sSlot = null;
   21.76  		
   21.77 -		if("1".equals(turnCase))
   21.78 +		OperationType operationType = null;
   21.79 +		ICard card = null;
   21.80 +		Slot slot = null;
   21.81 +		
   21.82 +		if("1".equals(sTurnCase))
   21.83  		{
   21.84 -			card = breader.readLine();
   21.85 -			slot = breader.readLine();
   21.86 +			sCard = breader.readLine();
   21.87 +			sSlot = breader.readLine();
   21.88 +			operationType = OperationType.CARD_TO_SLOT;
   21.89  		}
   21.90 -		else if("2".equals(turnCase))
   21.91 +		else if("2".equals(sTurnCase))
   21.92  		{
   21.93 -			slot = breader.readLine();
   21.94 -			card = breader.readLine();
   21.95 +			sSlot = breader.readLine();
   21.96 +			sCard = breader.readLine();
   21.97 +			operationType = OperationType.SLOT_TO_CARD;
   21.98  		}
   21.99  		else
  21.100  		{
  21.101  			// do nothing
  21.102  		}
  21.103  		
  21.104 -		if(turnCase == null || card == null || slot == null)
  21.105 +		if(sTurnCase == null || sCard == null || sSlot == null)
  21.106  		{
  21.107  			endgame = true;
  21.108 +			return;
  21.109  		}
  21.110 +		
  21.111 +		slot = opponent.getSlot(Integer.parseInt(sSlot));
  21.112 +		for(ICard iCard: new ICard[]{
  21.113 +				new Attack(),
  21.114 +				new Copy(),
  21.115 +				new Dbl(),
  21.116 +				new Dec(),
  21.117 +				new Get(),
  21.118 +				new Help(),
  21.119 +				new I(),
  21.120 +				new Inc(),
  21.121 +				new K(),
  21.122 +				new Put(),
  21.123 +				new Revive(),
  21.124 +				new S(),
  21.125 +				new Succ(),
  21.126 +				new Zero(),
  21.127 +				new Zombie(),
  21.128 +				}){
  21.129 +			if(sCard.equals(iCard.getName())){
  21.130 +				card = iCard;
  21.131 +				break;
  21.132 +			}
  21.133 +		}
  21.134 +		Batch batch = new Batch(operationType, card, slot);
  21.135 +		opponent.applyBatch(batch);
  21.136  	}
  21.137  	
  21.138  	private static void writeMove()
  21.139      {
  21.140 -		strategy.moving(proponent, opponent, System.out);
  21.141 +		Batch batch = strategy.move(proponent, opponent);
  21.142 +		System.out.print(batch);
  21.143 +		proponent.applyBatch(batch);
  21.144      }
  21.145  	
  21.146 +	public static boolean getAutoMode()
  21.147 +	{
  21.148 +		return automodeapply;
  21.149 +	}
  21.150 +	
  21.151  	public static void main(String[] args) throws IOException
  21.152      {
  21.153  	    String playerNum = args[0];
    22.1 --- a/src/main/java/ru/alphatech/icfpc/game/Slot.java	Sun Jun 19 17:53:59 2011 +0400
    22.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Slot.java	Sun Jun 19 18:42:07 2011 +0400
    22.3 @@ -9,6 +9,18 @@
    22.4  
    22.5  	private IValue _value = new I();
    22.6  	
    22.7 +	private int id = -1;
    22.8 +	
    22.9 +	public int getId() {
   22.10 +		return id;
   22.11 +	}
   22.12 +
   22.13 +	public Slot(int id){
   22.14 +		if(id < 0 || id > 255)
   22.15 +			throw new ICFPCException();
   22.16 +		this.id = id;
   22.17 +	}
   22.18 +	
   22.19  	public void setVitality(int vitality)
   22.20  	{
   22.21  		_vitality = vitality;
    23.1 --- a/src/main/java/ru/alphatech/icfpc/game/strategy/IStrategy.java	Sun Jun 19 17:53:59 2011 +0400
    23.2 +++ b/src/main/java/ru/alphatech/icfpc/game/strategy/IStrategy.java	Sun Jun 19 18:42:07 2011 +0400
    23.3 @@ -1,7 +1,6 @@
    23.4  package ru.alphatech.icfpc.game.strategy;
    23.5  
    23.6 -import java.io.PrintStream;
    23.7 -
    23.8 +import ru.alphatech.icfpc.game.Batch;
    23.9  import ru.alphatech.icfpc.game.Player;
   23.10  
   23.11  /**
   23.12 @@ -10,5 +9,5 @@
   23.13   *
   23.14   */
   23.15  public interface IStrategy {
   23.16 -	public void moving(Player proponent, Player opponent, PrintStream out);
   23.17 +	public Batch move(Player proponent, Player opponent);
   23.18  }
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/src/main/java/ru/alphatech/icfpc/game/strategy/OtherStrategy.java	Sun Jun 19 18:42:07 2011 +0400
    24.3 @@ -0,0 +1,28 @@
    24.4 +package ru.alphatech.icfpc.game.strategy;
    24.5 +
    24.6 +import java.io.PrintStream;
    24.7 +import java.util.LinkedList;
    24.8 +import java.util.List;
    24.9 +import java.util.Queue;
   24.10 +
   24.11 +import ru.alphatech.icfpc.game.Batch;
   24.12 +import ru.alphatech.icfpc.game.Player;
   24.13 +
   24.14 +public class OtherStrategy implements IStrategy {
   24.15 +	
   24.16 +	private static Queue<Batch> batches = new LinkedList<Batch>();
   24.17 +	
   24.18 +	public void clearBatcher(){
   24.19 +		batches.removeAll(batches);
   24.20 +	}
   24.21 +	
   24.22 +	public void addBatcher(List<Batch> batches){
   24.23 +		this.batches.addAll(batches);
   24.24 +	}
   24.25 +	
   24.26 +	@Override
   24.27 +	public Batch move(Player proponent, Player opponent) {
   24.28 +		return batches.poll();
   24.29 +	}
   24.30 +
   24.31 +}
    25.1 --- a/src/main/java/ru/alphatech/icfpc/game/strategy/SimplyStrategy.java	Sun Jun 19 17:53:59 2011 +0400
    25.2 +++ b/src/main/java/ru/alphatech/icfpc/game/strategy/SimplyStrategy.java	Sun Jun 19 18:42:07 2011 +0400
    25.3 @@ -1,7 +1,8 @@
    25.4  package ru.alphatech.icfpc.game.strategy;
    25.5  
    25.6 -import java.io.PrintStream;
    25.7 -
    25.8 +import static ru.alphatech.icfpc.game.Batch.OperationType.CARD_TO_SLOT;
    25.9 +import ru.alphatech.icfpc.cards.I;
   25.10 +import ru.alphatech.icfpc.game.Batch;
   25.11  import ru.alphatech.icfpc.game.Player;
   25.12  
   25.13  /**
   25.14 @@ -12,10 +13,9 @@
   25.15  public class SimplyStrategy implements IStrategy {
   25.16  
   25.17  	@Override
   25.18 -	public void moving(Player proponent, Player opponent, PrintStream out) {
   25.19 -		out.print(1 + "\n");
   25.20 -		out.print("I" + "\n");
   25.21 -		out.print(0 + "\n");
   25.22 +	public Batch move(Player proponent, Player opponent) {
   25.23 +		Batch batch = new Batch(CARD_TO_SLOT, new I(), opponent.getSlot(0));
   25.24 +		return batch;
   25.25  	}
   25.26  
   25.27  }
    26.1 --- a/src/main/java/ru/alphatech/icfpc/policy/AttackHelpPolicy.java	Sun Jun 19 17:53:59 2011 +0400
    26.2 +++ b/src/main/java/ru/alphatech/icfpc/policy/AttackHelpPolicy.java	Sun Jun 19 18:42:07 2011 +0400
    26.3 @@ -67,7 +67,8 @@
    26.4  		return type == TYPE.ATTACK ? new Attack() : new Help();
    26.5  	}
    26.6  	
    26.7 -	protected ArrayList<Batch> BcombineForFunctWith3ParamsInRegister(ICard function, Slot processingSlot){
    26.8 +	protected ArrayList<Batch> BcombineForFunctWith3ParamsInRegister(ICard function, Slot processingSlot)
    26.9 +	{
   26.10  		ArrayList<Batch> retArray = new ArrayList<Batch>();
   26.11  		
   26.12  		if(!(function instanceof Attack || function instanceof Help)){
    27.1 --- a/src/main/java/ru/alphatech/icfpc/policy/CompositionPolicy.java	Sun Jun 19 17:53:59 2011 +0400
    27.2 +++ b/src/main/java/ru/alphatech/icfpc/policy/CompositionPolicy.java	Sun Jun 19 18:42:07 2011 +0400
    27.3 @@ -5,19 +5,19 @@
    27.4  import ru.alphatech.icfpc.game.AbstractPolicy;
    27.5  import ru.alphatech.icfpc.game.Batch;
    27.6  
    27.7 -public class CompositionPolicy extends AbstractPolicy{
    27.8 +public abstract class CompositionPolicy extends AbstractPolicy{
    27.9  	
   27.10  	protected ArrayList<AbstractPolicy> policies = new ArrayList<AbstractPolicy>();
   27.11  
   27.12 -	public void addPolicy(AbstractPolicy policy){
   27.13 +	protected void addPolicy(AbstractPolicy policy){
   27.14  		policies.add(policy);
   27.15  	}
   27.16  	
   27.17 -	public void removePolicy(AbstractPolicy policy){
   27.18 +	protected void removePolicy(AbstractPolicy policy){
   27.19  		policies.remove(policy);
   27.20  	}
   27.21  	
   27.22 -	public AbstractPolicy getPolicy(int index){
   27.23 +	protected AbstractPolicy getPolicy(int index){
   27.24  		return policies.get(index);
   27.25  	}
   27.26  	
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/src/main/java/ru/alphatech/icfpc/policy/OneArgumentCardsPolicy.java	Sun Jun 19 18:42:07 2011 +0400
    28.3 @@ -0,0 +1,104 @@
    28.4 +package ru.alphatech.icfpc.policy;
    28.5 +
    28.6 +import java.util.ArrayList;
    28.7 +
    28.8 +import ru.alphatech.icfpc.cards.Copy;
    28.9 +import ru.alphatech.icfpc.cards.Dec;
   28.10 +import ru.alphatech.icfpc.cards.Get;
   28.11 +import ru.alphatech.icfpc.cards.ICard;
   28.12 +import ru.alphatech.icfpc.cards.Inc;
   28.13 +import ru.alphatech.icfpc.cards.K;
   28.14 +import ru.alphatech.icfpc.cards.Put;
   28.15 +import ru.alphatech.icfpc.cards.Revive;
   28.16 +import ru.alphatech.icfpc.cards.S;
   28.17 +import ru.alphatech.icfpc.cards.Zero;
   28.18 +import ru.alphatech.icfpc.game.AbstractPolicy;
   28.19 +import ru.alphatech.icfpc.game.Batch;
   28.20 +import ru.alphatech.icfpc.game.IValue;
   28.21 +import ru.alphatech.icfpc.game.Run;
   28.22 +import ru.alphatech.icfpc.game.Slot;
   28.23 +import ru.alphatech.icfpc.game.Value;
   28.24 +import ru.alphatech.icfpc.game.Batch.OperationType;
   28.25 +
   28.26 +public class OneArgumentCardsPolicy extends AbstractPolicy{
   28.27 +	
   28.28 +	public enum TYPE {
   28.29 +		DEC,
   28.30 +		INC,
   28.31 +		COPY,
   28.32 +		REVIVE
   28.33 +	}
   28.34 +	
   28.35 +	private TYPE type;
   28.36 +	private int processingSlotIndex = -1;
   28.37 +	private int registerIndex = -1;
   28.38 +	private int targetSlotIndex = -1;
   28.39 +	
   28.40 +	
   28.41 +	public OneArgumentCardsPolicy(TYPE type, int processingSlot, int target, int registerIndex) {
   28.42 +		this.type = type;
   28.43 +		this.processingSlotIndex = processingSlot;
   28.44 +		this.targetSlotIndex = target;
   28.45 +		this.registerIndex = registerIndex;
   28.46 +	}
   28.47 +	
   28.48 +	public ICard getCard(){
   28.49 +		switch (type) {
   28.50 +			case DEC:
   28.51 +			return new Dec();
   28.52 +			case INC:
   28.53 +			return new Inc();
   28.54 +			case COPY:
   28.55 +			return new Copy();
   28.56 +			case REVIVE:
   28.57 +			return new Revive();
   28.58 +		}
   28.59 +		return null;
   28.60 +	}
   28.61 +	
   28.62 +	protected boolean isEqualsCard(IValue value){
   28.63 +		if(value instanceof IValue)
   28.64 +			return false;
   28.65 +		if( type == TYPE.DEC && value instanceof Dec)
   28.66 +			return true;
   28.67 +		if( type == TYPE.INC && value instanceof Inc)
   28.68 +			return true;
   28.69 +		if( type == TYPE.COPY && value instanceof Copy)
   28.70 +			return true;
   28.71 +		if( type == TYPE.REVIVE && value instanceof Revive)
   28.72 +			return true;
   28.73 +		return false;
   28.74 +	}
   28.75 +
   28.76 +	@Override
   28.77 +	public ArrayList<Batch> getBatches() {
   28.78 +		ArrayList<Batch> retArray = new ArrayList<Batch>();
   28.79 +		
   28.80 +		retArray.addAll(numberIntoSlotField(Run.getRegisterByIndex(registerIndex), targetSlotIndex));
   28.81 +		
   28.82 +		Slot processingSlot = Run.getProponent().getSlot(processingSlotIndex);
   28.83 +		IValue slotValue = processingSlot.getValue();
   28.84 +		
   28.85 +		if(slotValue instanceof Value){
   28.86 +			retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), processingSlot));
   28.87 +			retArray.add(new Batch(OperationType.SLOT_TO_CARD, getCard(), processingSlot));
   28.88 +		}else{
   28.89 +			ICard currentCard = (ICard) slotValue;
   28.90 +			if(!(currentCard instanceof Dec && type == TYPE.DEC) || 
   28.91 +			   !(currentCard instanceof Inc && type == TYPE.INC))
   28.92 +			{
   28.93 +				retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), processingSlot));
   28.94 +				retArray.add(new Batch(OperationType.SLOT_TO_CARD, getCard(), processingSlot));
   28.95 +			}
   28.96 +		}
   28.97 +		
   28.98 +		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
   28.99 +		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
  28.100 +		
  28.101 +		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
  28.102 +		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
  28.103 +		
  28.104 +		return retArray;
  28.105 +	}
  28.106 +	
  28.107 +}
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/src/main/java/ru/alphatech/icfpc/policy/ZombiePolicy.java	Sun Jun 19 18:42:07 2011 +0400
    29.3 @@ -0,0 +1,75 @@
    29.4 +package ru.alphatech.icfpc.policy;
    29.5 +
    29.6 +import java.util.ArrayList;
    29.7 +
    29.8 +import ru.alphatech.icfpc.cards.Get;
    29.9 +import ru.alphatech.icfpc.cards.K;
   29.10 +import ru.alphatech.icfpc.cards.Put;
   29.11 +import ru.alphatech.icfpc.cards.S;
   29.12 +import ru.alphatech.icfpc.cards.Succ;
   29.13 +import ru.alphatech.icfpc.cards.Zero;
   29.14 +import ru.alphatech.icfpc.cards.Zombie;
   29.15 +import ru.alphatech.icfpc.game.AbstractPolicy;
   29.16 +import ru.alphatech.icfpc.game.Batch;
   29.17 +import ru.alphatech.icfpc.game.Run;
   29.18 +import ru.alphatech.icfpc.game.Slot;
   29.19 +import ru.alphatech.icfpc.game.Batch.OperationType;
   29.20 +
   29.21 +public class ZombiePolicy extends AbstractPolicy {
   29.22 +	
   29.23 +	private int processingSlotIndex = -1;
   29.24 +	private int targetSlotIndex = -1;
   29.25 +	private int valueSlotIndex = -1;
   29.26 +	
   29.27 +	/**
   29.28 +	 * 
   29.29 +	 * @param processingSlotIndex - слот в котором выполниться процесс зомбирования =)
   29.30 +	 * @param targetSlot - слот который будет зомби
   29.31 +	 * @param valueSlot слот в котором лежит содержиме которое поместиться в зомби
   29.32 +	 */
   29.33 +	public ZombiePolicy(int processingSlotIndex, int targetSlot, int valueSlot) {
   29.34 +		this.processingSlotIndex = processingSlotIndex;
   29.35 +		this.targetSlotIndex = targetSlot;
   29.36 +		this.valueSlotIndex = valueSlot;
   29.37 +	}
   29.38 +
   29.39 +	@Override
   29.40 +	public ArrayList<Batch> getBatches() {
   29.41 +		ArrayList<Batch> retArray = new ArrayList<Batch>();
   29.42 +		
   29.43 +		numberIntoSlotField(Run.getRegisterByIndex(1), targetSlotIndex);
   29.44 +		Slot processingSlot = Run.getProponent().getSlot(processingSlotIndex);
   29.45 +		
   29.46 +		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new Put(), processingSlot));
   29.47 +		
   29.48 +		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zombie(), processingSlot));
   29.49 +		
   29.50 +		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
   29.51 +		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
   29.52 +		
   29.53 +		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
   29.54 +		
   29.55 +		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
   29.56 +		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
   29.57 +		
   29.58 +		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
   29.59 +		
   29.60 +		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
   29.61 +		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
   29.62 +		
   29.63 +		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Get(), processingSlot));
   29.64 +		
   29.65 +		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
   29.66 +		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
   29.67 +		
   29.68 +		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Succ(), processingSlot));
   29.69 +		
   29.70 +		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new K(), processingSlot));
   29.71 +		retArray.add(new Batch(OperationType.CARD_TO_SLOT, new S(), processingSlot));
   29.72 +		
   29.73 +		retArray.add(new Batch(OperationType.SLOT_TO_CARD, new Zero(), processingSlot));
   29.74 +		
   29.75 +		return retArray;
   29.76 +	}
   29.77 +
   29.78 +}