Example #1
0
from game.game import Game
from ai.count_evaluator import CountEvaluator
from ai.tree_search import TreeSearch

from random import randint

# Game Rules
game = Game()
game.board_size = [7, 7]
game.start_pos = [3, 3]
game.num_colors = 6

tree_search = TreeSearch()

num_moves = []
e = 0
while True:
	e += 1
	game.reset()

	for n_moves in range(1000):
		best_move, best_tile, best_score, legal_moves = tree_search.find_best_move(game, 4)

		if len(legal_moves) > 0:
			game.play(best_move, best_tile)

		else:
			break

	num_moves.append(game.num_moves)
Example #2
0
def calc_max_cursor(game: Game):
    if game.get_stage() == 0:
        return game.notch_width() - 1
    if game.get_stage() == 1:
        return game.board_size() - 1
    return 1
Example #3
0
from game.game import Game
from ai.move_eval import count_obstructing
import numpy as np

game = Game()

game.board_size = [3, 3]
game.start_pos = [1, 1]
game.reset()

game.board = np.array([[2, 1, 0], [1, 0, 0], [0, 0, 0]])

assert count_obstructing(game, [1, 1], [1, 1], 3) == 1
assert count_obstructing(game, [1, 1], [1, 1], 2) == 1
assert count_obstructing(game, [1, 1], [1, 1], 1) == 0

game.board = np.array([[0, 1, 0], [1, 0, 0], [0, 0, 0]])

assert count_obstructing(game, [1, 1], [1, 1], 3) == 0