-- Compiled with roblox-ts v1.2.7 local TS = _G[script] local TicTacToePlayer = TS.import(script, script.Parent, "TicTacToePlayer").TicTacToePlayer --[[ * * This config allows for further customization * of the manual player. ]] --[[ * * A player that makes a move depending on the move set * externally, or randomly if desired and no move is set. ]] local TicTacToeManualPlayer do local super = TicTacToePlayer TicTacToeManualPlayer = setmetatable({}, { __tostring = function() return "TicTacToeManualPlayer" end, __index = super, }) TicTacToeManualPlayer.__index = TicTacToeManualPlayer function TicTacToeManualPlayer.new(...) local self = setmetatable({}, TicTacToeManualPlayer) return self:constructor(...) or self end function TicTacToeManualPlayer:constructor(name, config) if config == nil then config = {} end super.constructor(self, name) local _object = {} for _k, _v in pairs(TicTacToeManualPlayer.DEFAULT_CONFIG) do _object[_k] = _v end for _k, _v in pairs(config) do _object[_k] = _v end self.config = _object end function TicTacToeManualPlayer:makeMove(board) if self.nextMove then local move = self.nextMove self.nextMove = nil return move end if self.config.alwaysHaveMove then return self:getRandom(board) end end function TicTacToeManualPlayer:getRandom(board) local emptyCells = board:getEmptyCells() local randomCell = emptyCells[math.floor(math.random() * #emptyCells) + 1] return { row = randomCell:getRow(), col = randomCell:getCol(), } end function TicTacToeManualPlayer:setNext(row, col) self.nextMove = { row = row, col = col, } end TicTacToeManualPlayer.DEFAULT_CONFIG = { alwaysHaveMove = true, } end return { TicTacToeManualPlayer = TicTacToeManualPlayer, }