package net.ciklum.icfpc11.domain import net.ciklum.icfpc11.parser.Command import net.ciklum.icfpc11.domain.greenspoon10.Identity /** * blabla * @author vic */ @Typed class Player { final List slots final String name Player(String name) { this.name = name slots = (0..255).collect{ new Slot() } } boolean isValidSlotNumber(int i) { i >= 0 && i <= 255 } Slot getSlot(int index) { if (!isValidSlotNumber(index)) { throw new GameError("Index is not a valid slot number: $index") } slots[index] } Command getNextCommand() { throw new RuntimeException('Not implemented for abstract Player') } /** * Callback to notify - what Command opponent issues. * Used to send back AI's commands to console and to notify AI what's opponent doing */ void respondCommand(Command response) { // throw new RuntimeException('Not implemented for abstract Player') } final boolean isDead() { slots.find{ it.alive } == null } String slotsToString() { def sb = new StringBuilder() slots.eachWithIndex{ Slot it, int i -> if (it.value != Identity.IDENTITY || it.vitality != 10000) { sb.append("$i=$it\n") } } if (sb.length() > 0) { sb.deleteCharAt(sb.length()-1) } sb } }