def simulate_random_game(game): bots = { Player.black: agent.RandomBot(), Player.white: agent.RandomBot() } while not game.is_over(): bot_move = bots[game.next_player].select_move(game) game = game.apply_move(bot_move) return game.winner()
def main(): board_size = 9 game = goboard.GameState.new_game(board_size) bots = { gotypes.Player.black: agent.RandomBot(), gotypes.Player.white: agent.RandomBot(), } while not game.is_over(): print_board(game.board) bot_move = bots[game.next_player].select_move(game) print_move(game.next_player, bot_move) game = game.apply_move(game.next_player, bot_move)
def main(): board_size = 9 game = goboard.GameState.new_game(board_size) bots = { gotypes.Player.black: agent.RandomBot(), gotypes.Player.white: agent.RandomBot(), } while not game.is_over(): time.sleep(0.3) print(chr(27) + "[2J") print_board(game.board) bot_move(game.next_player, bot_move) game = game.apply_move(bot_move)
def main(): while True: board_size = input( 'Enter the dimensions of the square Go board. (Integer between 5 and 19):' ) try: board_size = int(board_size) except ValueError: print('Invalid Entry') continue if board_size in range(5, 20): break else: print('Invalid Entry') game = goboard.GameState.new_game(board_size) bot = agent.RandomBot() while not game.is_over(): print(chr(27) + "[2J") compute_score(game.board) print_board(game.board) if game.next_player == gotypes.Player.black: human_move = input('-- ') point = point_from_coords(human_move.strip()) move = goboard.Move.play(point) else: move = bot.select_move(game) print_move(game.next_player, move) game = game.apply_move(move)
def main(): board_size = 9 game = goboard.GameState.new_game(board_size) bot = agent.RandomBot() while not game.is_over(): print(chr(27) + "[2J") print_board(game.board) if game.next_player == gotypes.Player.black: human_move = input('-- ') point = point_from_coords(human_move.strip()) move = goboard.Move.play(point) else: move = bot.select_move(game) print_move(game.next_player, move) game = game.apply_move(move)
def main(): board_size = 0 while not 5 <= board_size <= 19: board_size = int(input("Enter Board Size (5X5 - 19X19) : ")) game = goboard.GameState.new_game(board_size) bot = agent.RandomBot() while not game.is_over(): #print(chr(27) + "[2J") print_board(game.board) if game.next_player == gotypes.Player.black: human_move = input('-- ') if human_move == 'pass': move = goboard.Move.pass_turn() elif human_move == 'resign': move = goboard.Move.resign() else: point = point_from_coords(human_move.strip()) move = goboard.Move.play(point) else: move = bot.select_move(game) print_move(game.next_player, move) game = game.apply_move(move)
import discord from discord.ext import commands from dlgo import agent from dlgo import goboard_slow as goboard from dlgo import gotypes from dlgo.utils import * with open('token.txt') as f: token = f.readline()[:-1] board_size = 13 human = gotypes.Player.black client = commands.Bot(command_prefix='') game = goboard.GameState.new_game(board_size) bot = agent.RandomBot() @client.event async def on_ready(): print('Logged in as', client.user.name) @client.command() async def show(context): await context.send(print_board(game.board)) @client.command() async def play(context, *args): global game