public int toDOT(FileWriter fr, boolean redColored, int i) throws IOException { String red, format, val, blue; int me = i, aux; if (redColored) { red = "color=red, style=filled, "; } else { red = ""; } if (value == Integer.MAX_VALUE || value == Integer.MIN_VALUE) { val = ""; blue = "color=blue, style=filled, "; } else { val = "" + value; blue = ""; } format = getDOTFormat(); fr.append(me + " [" + red + blue + format + "label=\"" + pos.toString() + " " + val + "\"];\n"); boolean redSon, selected = true; for (Node son : childs) { if (selected && son.value == value) { selected = false; redSon = true; } else { redSon = false; } aux = i + 1; i = son.toDOT(fr, redSon, ++i); fr.append(me + " -> " + aux + ";\n"); } return i; }
/** Return an icon for the gold on tile n, or null otherwise. */ public BufferedImage getGoldIcon(Node n) { double gold = n.getTile().getGold(); if (gold == Cavern.TASTY_VALUE) return tasty; gold *= ((double) COIN_SPRITES_PER_ROW * COIN_SPRITES_PER_COL) / Cavern.MAX_GOLD_VALUE; int spriteIndex = (int) gold; int rowIndex = spriteIndex / COIN_SPRITES_PER_ROW; int colIndex = spriteIndex % COIN_SPRITES_PER_ROW; return coinSheet.getSprite(rowIndex, colIndex); }
public Position nextMove( int maxLevel, long level, boolean prune, Integer parentVal, TimeInfo timeInfo) { if (timeInfo != null) { timeInfo.update(); } if (maxLevel == level) { getHeuristicalValue(); return pos; } Position nextPos = pos; setChilds(); level++; for (Node child : childs) { if (prune && pruneBranch(parentVal)) { return null; } if (child.chooseMove(value)) { child.nextMove(maxLevel, level, prune, value, timeInfo); nextPos = child.pos; value = child.value; } } return nextPos; }