UNPKG

@rbxts/tic-tac-toe

Version:

Modular tic-tac-toe without dependencies, because why not.

53 lines (52 loc) 1.65 kB
/// <reference types="@rbxts/compiler-types" /> import { TicTacToeBoard } from "../TicTacToeBoard"; import { TicTacToePlayer } from "./TicTacToePlayer"; /** * This config allows for further customization * of the manual player. */ export interface ManualPlayerConfig { /** * Whether the player should choose a random move * if no move is set. Defaults to true. */ alwaysHaveMove: boolean; } /** * A player that makes a move depending on the move set * externally, or randomly if desired and no move is set. */ export declare class TicTacToeManualPlayer extends TicTacToePlayer { private static DEFAULT_CONFIG; /** The next move that the player should make. */ private nextMove?; private config; /** * Constructs a new TicTacToeManualPlayer. * * @param name The name of the player. * @param config The config that controls this player */ constructor(name: string, config?: Partial<ManualPlayerConfig>); /** @hidden */ makeMove(board: TicTacToeBoard): { row: number; col: number; } | undefined; /** * Returns a random move based on empty cells on the given board. * * @param board The board to get a random move from. * @returns The random move. */ private getRandom; /** * Sets the coordinates of the next move * that the player should make. This * will be cleared after the next move. * * @param row The row of the next move. * @param col The column of the next move. */ setNext(row: number, col: number): void; }