1.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Dec.java Sun Jun 19 14:29:07 2011 +0400
1.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Dec.java Sun Jun 19 14:29:45 2011 +0400
1.3 @@ -14,13 +14,16 @@
1.4 {
1.5 int i = ((Value)value).getValue();
1.6
1.7 - if (i > 0 && i < 256)
1.8 + if (i >= 0 && i <= 255)
1.9 {
1.10 int v = proponent.getSlot(255 - i).getVitality();
1.11 - if (v < 65535 && v > 0)
1.12 +
1.13 + if (v > 0)
1.14 {
1.15 - proponent.getSlot(255 - i).setVitality(proponent.getSlot(255 - i).getVitality() - 1);
1.16 + proponent.getSlot(255 - i).setVitality(v - 1);
1.17 }
1.18 +
1.19 + return new I();
1.20 }
1.21 else
1.22 {
1.23 @@ -31,7 +34,5 @@
1.24 {
1.25 throw new ICFPCException();
1.26 }
1.27 -
1.28 - return new Value(-100);
1.29 }
1.30 }
2.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Inc.java Sun Jun 19 14:29:07 2011 +0400
2.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Inc.java Sun Jun 19 14:29:45 2011 +0400
2.3 @@ -14,13 +14,16 @@
2.4 {
2.5 int i = ((Value)value).getValue();
2.6
2.7 - if (i < 256 && i > 0)
2.8 + if (i >= 0 && i <= 255)
2.9 {
2.10 int v = proponent.getSlot(i).getVitality();
2.11 - if (v < 65535 && v > 0)
2.12 +
2.13 + if (v > 0 && v < 65535)
2.14 {
2.15 proponent.getSlot(i).setVitality(v + 1);
2.16 }
2.17 +
2.18 + return new I();
2.19 }
2.20 else
2.21 {
2.22 @@ -31,7 +34,5 @@
2.23 {
2.24 throw new ICFPCException();
2.25 }
2.26 -
2.27 - return new I();
2.28 }
2.29 }
3.1 --- a/src/main/java/ru/alphatech/icfpc/cards/K.java Sun Jun 19 14:29:07 2011 +0400
3.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/K.java Sun Jun 19 14:29:45 2011 +0400
3.3 @@ -5,7 +5,6 @@
3.4
3.5 public class K implements ICard
3.6 {
3.7 -
3.8 @Override
3.9 public IValue returnValue(final IValue x, Player proponent, Player opponent)
3.10 {
4.1 --- a/src/main/java/ru/alphatech/icfpc/cards/S.java Sun Jun 19 14:29:07 2011 +0400
4.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/S.java Sun Jun 19 14:29:45 2011 +0400
4.3 @@ -6,19 +6,20 @@
4.4 public class S implements ICard
4.5 {
4.6 @Override
4.7 - public IValue returnValue(final IValue x, Player proponent, Player opponent)
4.8 + public IValue returnValue(final IValue f, Player proponent, Player opponent)
4.9 {
4.10 return new ICard()
4.11 {
4.12 - public IValue returnValue(final IValue y, Player proponent, Player opponent)
4.13 + public IValue returnValue(final IValue g, Player proponent, Player opponent)
4.14 {
4.15 return new ICard()
4.16 {
4.17 - public IValue returnValue(final IValue z, Player proponent, Player opponent)
4.18 + public IValue returnValue(final IValue x, Player proponent, Player opponent)
4.19 {
4.20 - IValue h = x.returnValue(z, proponent, opponent);
4.21 - IValue g = y.returnValue(z, proponent, opponent);
4.22 - return h.returnValue(g, proponent, opponent);
4.23 + IValue h = f.returnValue(x, proponent, opponent);
4.24 + IValue y = g.returnValue(x, proponent, opponent);
4.25 +
4.26 + return h.returnValue(y, proponent, opponent);
4.27 }
4.28 };
4.29 }
5.1 --- a/src/main/java/ru/alphatech/icfpc/game/Run.java Sun Jun 19 14:29:07 2011 +0400
5.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Run.java Sun Jun 19 14:29:45 2011 +0400
5.3 @@ -11,6 +11,9 @@
5.4 import java.util.LinkedList;
5.5 import java.util.List;
5.6
5.7 +import ru.alphatech.icfpc.game.strategy.IStrategy;
5.8 +import ru.alphatech.icfpc.game.strategy.SimplyStrategy;
5.9 +
5.10 public class Run
5.11 {
5.12 private static boolean endgame = false;
5.13 @@ -30,6 +33,8 @@
5.14 registers[3] = 3;
5.15 }
5.16
5.17 + private static IStrategy strategy = new SimplyStrategy();
5.18 +
5.19 public static Slot getRegisterByIndex(int registerIdex){
5.20 return proponent.getSlot( registers[registerIdex] );
5.21 }
5.22 @@ -80,9 +85,7 @@
5.23
5.24 private static void writeMove()
5.25 {
5.26 - System.out.print(1 + "\n");
5.27 - System.out.print("I" + "\n");
5.28 - System.out.print(0 + "\n");
5.29 + strategy.moving(proponent, opponent, System.out);
5.30 }
5.31
5.32 public static void main(String[] args) throws IOException
6.1 --- a/src/main/java/ru/alphatech/icfpc/game/Value.java Sun Jun 19 14:29:07 2011 +0400
6.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Value.java Sun Jun 19 14:29:45 2011 +0400
6.3 @@ -23,6 +23,6 @@
6.4 @Override
6.5 public IValue returnValue(IValue value, Player proponent, Player opponent)
6.6 {
6.7 - return this;
6.8 + throw new ICFPCException();
6.9 }
6.10 }
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/src/main/java/ru/alphatech/icfpc/game/strategy/IStrategy.java Sun Jun 19 14:29:45 2011 +0400
7.3 @@ -0,0 +1,14 @@
7.4 +package ru.alphatech.icfpc.game.strategy;
7.5 +
7.6 +import java.io.PrintStream;
7.7 +
7.8 +import ru.alphatech.icfpc.game.Player;
7.9 +
7.10 +/**
7.11 + * @author indvdum
7.12 + * 19.06.2011 13:36:17
7.13 + *
7.14 + */
7.15 +public interface IStrategy {
7.16 + public void moving(Player proponent, Player opponent, PrintStream out);
7.17 +}
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/src/main/java/ru/alphatech/icfpc/game/strategy/SimplyStrategy.java Sun Jun 19 14:29:45 2011 +0400
8.3 @@ -0,0 +1,21 @@
8.4 +package ru.alphatech.icfpc.game.strategy;
8.5 +
8.6 +import java.io.PrintStream;
8.7 +
8.8 +import ru.alphatech.icfpc.game.Player;
8.9 +
8.10 +/**
8.11 + * @author indvdum
8.12 + * 19.06.2011 13:36:26
8.13 + *
8.14 + */
8.15 +public class SimplyStrategy implements IStrategy {
8.16 +
8.17 + @Override
8.18 + public void moving(Player proponent, Player opponent, PrintStream out) {
8.19 + out.print(1 + "\n");
8.20 + out.print("I" + "\n");
8.21 + out.print(0 + "\n");
8.22 + }
8.23 +
8.24 +}