def big_move_test(r=3, c=1):
    states = []
    board = Board.Board(7)
    print("Initial board:")
    board.print()
    states.append(board)

    # available_move_test
    print("available move test")
    d = available_move_test(board, r, c)

    # move_test
    print("move test")
    if (len(d) != 0):
        print(d)
        b = move_test(board, int(d[0]), r, c)
        states.append(b)
        # b.print()
    else:
        print("no move")
    b = move_test(b, 4, 3, 4)
    states.append(b)
    # b.print()

    path_print(states)
    print("in")
    sted = AStar.h2(states)
    path_print(sted)
 def __init__(self):
     self.board = Board()
     self.myShip = Spaceship('$', 56, self.board)
     self.miss1 = []
     self.miss2 = []
     self.aliens = []
     self.score = 0
     self.start = time.time()
     self.getch = GetInput._getChUnix()
def iterative_bfs_test():
    board = Board.Board(7)
    bfs = Bfs.Bfs(board)
    result, queue, path = bfs.iterative_bfs()
    print("Final state: ")
    result.print()
    print("Peg count is: ", result.count_pegs())
    # print("Path is: ")
    # for i in path:
    #     i.print()

    print(bfs.get_gen_cnt(), " nodes are generated")
    print(bfs.get_ext_cnt(), " nodes are extended")
        if board.three_in_a_row() == 1:
            print("X Win!")
            return
        elif board.three_in_a_row() == 2:
            print("O Win!")
            return

        # KI turn
        best = MCTS.choose_best_move(board, 1500)
        print(best)
        board.make_move(best)
        print(board)

        if board.three_in_a_row() == 1:
            print("X Win!")
            return
        elif board.three_in_a_row() == 2:
            print("O Win!")
            return


print("Start")

board = Board.Board()
print(board)

play(board)


Exemple #5
0
how_many_pellets = 20




bot = Bot(start_loc=(0,0))

finish = Finish()

actors = [bot, finish]
for _ in range(how_many_pellets):
    actors.append(Pellet())

dimension = 20
display_size = 600


board = Board(dimension, display_size, initial_randomness, randomness_decay, gamma=gamma, FPS=FPS)
board.set_actors(actors)

pygame.init()
pygame.display.set_caption("TIMBERLEE'S Journey")

for i in range(total_iterations):
    print(i)
    print(board.randomness)
    if i >= total_iterations - 2:
        show_board = True
    board.run_episode(show=show_board)
    board.reset_board()
        "                     Welcome to the memory game! \n"
        "                 Please indicate how many pairs you want!\n"
        "            Remember that this game only accept numbers as answers\n"
        "-------------------------------------------------------------------------"
    )
    Cards = int(input("Number of pairs: "))

    return Cards


A = Cards(menu())
x, y = Cards.tablero(A)

Pt_1 = 0  #Jugadores
Pt_2 = 0
B = Board(x, y)

B.Print()

Turn = False  #False jugador 1 True jugador 2
while True:
    if Turn:
        print("\nPlayer 2 turn!\n")
    else:
        print("\nPlayer 1 turn!\n")

    Comp, puntos, Symbols, Matrix = B.Coords()

    if Turn:
        Pt_2 += puntos
    else:
Exemple #7
0
import sys
import datetime
import os

sys.path.append('Classes')

from Classes import Board, Interface

CURRENT_OS = os.name
BOARD_SIZE_ROW = 300
BOARD_SIZE_COLUMN = 300
# Make a X,Y game board. 0,0 is the upper left corner.
GameBoard = Board.Board(size_row=BOARD_SIZE_ROW, size_column=BOARD_SIZE_COLUMN)

# Open HWInterface only on the pi
if CURRENT_OS == 'posix':
    HWInterface = Interface.HWInterface(size_row=BOARD_SIZE_ROW,
                                        size_column=BOARD_SIZE_COLUMN)

# Seed the board with a pattern
# TODO: Randomize a starting patern or import/create a known pattern
GameBoard.Create_Glider(5, 5)
a = datetime.datetime.now()
round_num = 0

while round_num < 15:
    b = datetime.datetime.now()
    if ((b - a).seconds % 2 == 1):  # Delay the processing
        game_state = GameBoard.Process()

        # If on posix then we are in the raspberrypi
def bfs_test():
    sys.setrecursionlimit(10000)
    board = Board.Board(7)
    bfs = Bfs.Bfs(board)
    result, queue, path = bfs.bfs()
    print_results(result, bfs)
def dfs_test():
    board = Board.Board(7)
    dfs = Dfs.Dfs(board)
    result, stack, path = dfs.dfs()
    print_results(result, dfs)
def a_star_test(hn):
    sys.setrecursionlimit(10000)
    board = Board.Board(7)
    a_star = AStar.AStar(board, hn)
    result, queue, path = a_star.a_star()
    print_results(result, a_star)
def peg_indexes_test():
    m = Board.Board(7)
    print(m.peg_indexes())
Exemple #12
0
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (0, 150, 0)
RED = (255, 0, 0)

# This sets the WIDTH and HEIGHT of each grid location
WIDTH = 40
HEIGHT = 40

# This sets the margin between each cell
MARGIN = 5
WINDOW_SIZE = [365, 420]

# Initializes the board
board = Board()

# Score text
BLACK_SCORE = 'Black\n{}'

WHITE_SCORE = 'White\n{}'


def turn(position, player, p1_pos, p2_pos):
    '''
        structures the turn for each player
    '''
    board.show_valid(player)


def text_obj(text, font, color):