removalmove.java

来自「ErGo是一个很早的Java通用围棋服务器(IGS/NNGS)客户端程序。有全部」· Java 代码 · 共 72 行

JAVA
72
字号
package ergo.logic;

// $Id: RemovalMove.java,v 1.2 1999/08/13 01:17:49 sigue Exp $

/*
 *  Copyright (C) 1999  Carl L. Gay and Antranig M. Basman.
 *  See the file copyright.txt, distributed with this software,
 *  for further information.
 */

import ergo.util.*;
import java.io.PrintWriter;

/**
 * A RemovalMove represents a group removed during game scoring.
 * It copies the timeleft from its parent, and it is never a variation.
 */
  // +++ Would be nice to store the name of the player who removed
  //     this group.
public class RemovalMove extends Move {

  Position pos;
  SimpleGroupVector capturedGroups = new SimpleGroupVector(1);

  public RemovalMove (Move parent, Position pos, int num, boolean isVar) {
    super(parent, parent.timeLeft, num, parent.nextColor(), isVar);
    this.pos = pos;
  }

  public String toString () {
    return "Removed " + pos + " group";
  }

  public PositionVector placedPositions (int x) {
    return null;
  }

  public boolean isLegal (Game game, boolean fast, ILMV result) {
    SimpleGroup group = game.groupAt(pos.row, pos.column);
    if (group == null) {
      result.failureReason = "No group to remove at " + pos + ".";
      return false;
    }
    else {
      capturedGroups.addElement(group);
      return true;
    }
  }

  public boolean equals (Move m) {
    return false;		// No two removal moves are the same.
  }

  public int numberOfStones () {
    return 0;
  }

  public SimpleGroupVector capturedGroups () {
    return capturedGroups;
  }

  public boolean occupiesPosition (Position pos) {
    return false;
  }

  public void writeSGF (PrintWriter out, Game game, int n) {
    out.print(";C[Ergo: " + this + "]");
    super.writeSGF(out, game, n);
  }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?