Ejemplo n.º 1
0
  /**
   * 指定したサイズ、手番で詰碁の{@link RootGameTree}を作成します。
   *
   * @param sgfSize 碁盤の大きさ
   * @param playerToPlay 次の手番
   * @return 作成した詰碁。NOT NULL
   * @throws org.unitarou.lang.NullArgumentException 引数が <code>null</code>の場合
   */
  public static RootGameTree createProblem(SgfSize sgfSize, SgfColor playerToPlay) {
    ArgumentChecker.throwIfNull(sgfSize, playerToPlay);

    RootGameTree rgt = new RootGameTree();
    rgt.setSize(sgfSize);
    rgt.setFileFormat(FileFormat.VERSION_4);
    rgt.setCharset(new SgfCharset(Charset.defaultCharset()));
    rgt.setGameMode(GameMode.IGO);
    rgt.setGameType(GameType.PROBLEM);
    rgt.setStyle(Style.SIBLINGS_SHOW_VAL);

    Node node = rgt.getSequence().getFirst();
    node.addProperty(SgfId.PLAYER_TO_PLAY.makeProperty(playerToPlay));
    return rgt;
  }
Ejemplo n.º 2
0
  /**
   * 指定したサイズ、置石で棋譜の{@link RootGameTree}を作成します。
   *
   * @param sgfSize 碁盤の大きさ
   * @param handicap 置石の数(0:互先, 1:定先、2:二子…)
   * @return 作成した棋譜。NOT NULL
   * @throws org.unitarou.lang.NullArgumentException 引数が <code>null</code>の場合
   * @throws IllegalArgumentException sgfSizeが正方形以外でnumberが2以上の場合
   */
  public static RootGameTree createGame(SgfSize sgfSize, Handicap handicap) {
    ArgumentChecker.throwIfNull(sgfSize, handicap);

    RootGameTree rgt = new RootGameTree();
    rgt.setSize(sgfSize);
    rgt.setFileFormat(FileFormat.VERSION_4);
    rgt.setCharset(new SgfCharset(Charset.defaultCharset()));
    rgt.setGameMode(GameMode.IGO);
    rgt.setGameType(GameType.GAME);
    rgt.setStyle(Style.SIBLINGS_SHOW_VAL);

    Node node = rgt.getSequence().getFirst();
    node.addProperty(SgfId.HANDICAP.makeProperty(handicap));
    node.addProperty(
        SgfId.PLAYER_TO_PLAY.makeProperty(
            (1 < handicap.getIntValue()) ? SgfColor.WHITE : SgfColor.BLACK));

    Set<SgfPoint> handicappedStones = composeHandicapStone(sgfSize, handicap);
    if (!handicappedStones.isEmpty()) {
      node.addProperty(SgfId.ADD_BLACK.makeProperty(handicappedStones));
    }
    return rgt;
  }