# HG changeset patch # User indvdum # Date 1308520783 -14400 # Node ID 845c89fa268ebb930c933b83ac0857f42a9637de # Parent ea793ae43d3edd6d77f0ddc437aa3429c27d7e6b * diff -r ea793ae43d3e -r 845c89fa268e src/main/java/ru/alphatech/icfpc/game/Player.java --- a/src/main/java/ru/alphatech/icfpc/game/Player.java Mon Jun 20 01:48:37 2011 +0400 +++ b/src/main/java/ru/alphatech/icfpc/game/Player.java Mon Jun 20 01:59:43 2011 +0400 @@ -8,6 +8,8 @@ public class Player { + private int playerNumber = -1; + private Slot[] slots = new Slot[256]; private Player myOpponent = null; @@ -19,6 +21,14 @@ } } + public int getPlayerNumber() { + return playerNumber; + } + + public void setPlayerNumber(int playerNumber) { + this.playerNumber = playerNumber; + } + public Player getMyOpponent() { return myOpponent; } @@ -33,7 +43,7 @@ } public PlayerStatistic getStatistic(){ - throw new RuntimeException("Not impilemented yet."); + throw new RuntimeException("Not implemented yet."); } public void applyBatch(Batch batch){ diff -r ea793ae43d3e -r 845c89fa268e src/main/java/ru/alphatech/icfpc/game/Run.java --- a/src/main/java/ru/alphatech/icfpc/game/Run.java Mon Jun 20 01:48:37 2011 +0400 +++ b/src/main/java/ru/alphatech/icfpc/game/Run.java Mon Jun 20 01:59:43 2011 +0400 @@ -167,7 +167,12 @@ if("1".equals(playerNum)) { + proponent.setPlayerNumber(1); + opponent.setPlayerNumber(0); readOpponent(); + } else { + proponent.setPlayerNumber(0); + opponent.setPlayerNumber(1); } while(!endgame) diff -r ea793ae43d3e -r 845c89fa268e src/main/java/ru/alphatech/icfpc/game/Slot.java --- a/src/main/java/ru/alphatech/icfpc/game/Slot.java Mon Jun 20 01:48:37 2011 +0400 +++ b/src/main/java/ru/alphatech/icfpc/game/Slot.java Mon Jun 20 01:59:43 2011 +0400 @@ -34,6 +34,10 @@ public boolean isZombie(){ return _vitality == -1; } + + public boolean isDead(){ + return _vitality == 0 || _vitality == -1; + } public IValue getValue() { diff -r ea793ae43d3e -r 845c89fa268e src/main/java/ru/alphatech/icfpc/game/strategy/YetAnotherStrategy.java --- a/src/main/java/ru/alphatech/icfpc/game/strategy/YetAnotherStrategy.java Mon Jun 20 01:48:37 2011 +0400 +++ b/src/main/java/ru/alphatech/icfpc/game/strategy/YetAnotherStrategy.java Mon Jun 20 01:59:43 2011 +0400 @@ -1,5 +1,9 @@ package ru.alphatech.icfpc.game.strategy; +import java.io.FileWriter; +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintStream; import java.util.LinkedList; import java.util.Queue; @@ -17,36 +21,49 @@ private int lastAttackedSlot = lastAttackedDefaultSlot; AttackHelpPolicy helpPolicy = null; AttackHelpPolicy attackPolicy = null; - CallExpressionPolicy callAttack = null; +// CallExpressionPolicy callAttack = null; + PrintStream log = null; public YetAnotherStrategy(){ - helpPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.HELP, lastUsedSlot++, 8, 6, 5000, true); - attackPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.ATTACK, 5, 6, lastAttackedSlot++, 9000, false); - callAttack = new CallExpressionPolicy(9, 5, 0, true); + helpPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.HELP, 7, lastUsedSlot++, 6, 5000); + attackPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.ATTACK, 5, 6, lastAttackedSlot++, 4000); +// callAttack = new CallExpressionPolicy(9, 5, 0, true); batches.addAll(helpPolicy.getBatches()); batches.addAll(attackPolicy.getBatches()); - batches.addAll(callAttack.getBatches()); - +// batches.addAll(callAttack.getBatches()); + try { + log = new PrintStream("strategy.log"); + } catch (IOException e) { + } } @Override public Batch move(Player proponent, Player opponent) { if(opponent.getSlot(lastAttackedSlot-1).getVitality() <= 0){ + log.println("opponent slot " + (lastAttackedSlot-1) + " is dead"); if(lastAttackedSlot > 254) lastAttackedSlot = lastAttackedDefaultSlot; batches.clear(); - attackPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.ATTACK, 5, 6, lastAttackedSlot++, 10000, false); - callAttack = new CallExpressionPolicy(9, 5, 0, true); + attackPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.ATTACK, 5, 6, lastAttackedSlot++, 4000); +// callAttack = new CallExpressionPolicy(9, 5, 0, true); batches.addAll(attackPolicy.getBatches()); - batches.addAll(callAttack.getBatches()); +// batches.addAll(callAttack.getBatches()); } if(!batches.isEmpty()) return batches.poll(); - if(lastUsedSlot > 254) + if(lastUsedSlot > 255) lastUsedSlot = lastUsedDefaultSlot; - AttackHelpPolicy helpPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.HELP, lastUsedSlot++, 8, 6, 5000, true); + for(int i = 0; i <= 255; i++) + if(opponent.getSlot(i).getVitality() != 10000) + log.println("opponent slot " + (i) + " has " + opponent.getSlot(i).getVitality() + " vitality"); + for(int i = 0; i <= 255; i++) + if(proponent.getSlot(i).getVitality() != 10000) + log.println("proponent slot " + (i) + " has " + proponent.getSlot(i).getVitality() + " vitality"); + helpPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.HELP, 7, lastUsedSlot++, 6, 5000); batches.addAll(helpPolicy.getBatches()); - batches.addAll(callAttack.getBatches()); + attackPolicy = new AttackHelpPolicy(AttackHelpPolicy.TYPE.ATTACK, 5, 6, lastAttackedSlot-1, 4000); + batches.addAll(attackPolicy.getBatches()); +// batches.addAll(callAttack.getBatches()); return move(proponent, opponent); }