goban-engine
Version:
This contains the built Go engine that is used by the Goban package. There are no display components in this package, only the logic for playing the game of Go, making it suitable for usage in node.js or other server-side environments.
38 lines (37 loc) • 1.85 kB
TypeScript
import { JGOFNumericPlayerColor, JGOFIntersection } from "./formats/JGOF";
/** A raw stone string is simply an array of intersections */
export type RawStoneString = Array<JGOFIntersection>;
/**
* A StoneString instance represents a group of intersections that
* are connected to each other and are all the same color.
*/
export declare class StoneString {
readonly intersections: Array<JGOFIntersection>;
readonly neighbors: Array<StoneString>;
readonly color: JGOFNumericPlayerColor;
readonly id: number;
territory_color: JGOFNumericPlayerColor;
is_territory: boolean;
private __added_neighbors;
private neighboring_space;
private neighboring_stone_strings;
constructor(id: number, color: JGOFNumericPlayerColor);
map(fn: (loc: JGOFIntersection) => void): void;
foreachNeighboringString(fn: (stone_string: StoneString) => void): void;
foreachNeighboringEmptyString(fn: (stone_string: StoneString) => void): void;
foreachNeighboringStoneString(fn: (stone_string: StoneString) => void): void;
size(): number;
/** Add a stone to the group. This should probably only be called by StoneStringBuilder. */
_addStone(x: number, y: number): void;
/** Adds a stone string to our neighbor list. This should probably only be called by StoneStringBuilder. */
_addNeighborGroup(group: StoneString): void;
/**
* Compute if this string is considered potential territory (if all of it's
* neighbors are the same color). NOTE: This does not perform any advanced
* logic to determine seki status or anything like that, this only looks to
* see if the string contains EMPTY locations and that all of the
* surrounding neighboring are the same color. This should probably only
* be called by StoneStringBuilder.
*/
_computeIsTerritory(): void;
}