예제 #1
0
 def __init__(self):
     Tk.__init__(self)
     self.title("Andantino - Hexagon Grid")
     self.can = Canvas(self,
                       width=config.width,
                       height=config.height,
                       bg="#60ace6")
     self.size = config.size
     self.state = 0
     self.start = 1
     self.can.pack(padx=0)
     self.hexagons = []
     self.hexagons_board = []
     self.hexagons_white = []
     self.hex_append = []
     self.list_of_neigh = []
     self.hexagons_black = []
     self.neigh_append = []
     self.hex_closest1 = []
     self.first_n = []
     self.hex_glob = []
     self.glob_inter = []
     self.first_hex = []
     self.glob_line = []
     self.initGrid(config.rows, config.cols, self.size)
     # print("number of hexes in total : " + str(len(self.hexagons)))
     self.create_hexes_board()
     draw.draw_player(self.can, self.hexagons_board, self.size)
     self.can.bind("<Button-1>", self.click_pos)
     frame = Frame()
     frame.pack()
     draw.draw_board(self.can, self.hexagons_board, self.size)
     draw.draw_neighb(self.can, self.add_first_hex(), self.size)
예제 #2
0
def test_draw_board():

    img = draw.create_image(80, 80, color='red')
    assert img.width == 80
    assert img.height == 80

    draw.draw_board(img, 10, 0, 0, 'white', 'black')
    color_list = img.getcolors()
    assert len(color_list) == 2
예제 #3
0
# モデル読み込み
agent.model.load_state_dict(
    torch.load('data/model_15984.pth', map_location=torch.device('cpu')))

env.reset()
state_t_1, reward_t, terminal = env.observe()
legal_hands = env.legal_hands[0]
player_no = 1

# passしたらTrueにし、passでなかったらFalseに戻す
# Trueの時に再びpassが起きたらゲーム終了
pass_flag = False

# board描画
draw_board(state_t_1, screen, 1, stop)
indicate_legal_hands(state_t_1, screen, legal_hands)

pygame.display.update()  # 画面を更新

# ゲームループ
while True:

    # イベント処理
    for event in pygame.event.get():
        if event.type == QUIT:
            sys.exit()

        # 左クリックで石おく
        elif event.type == MOUSEBUTTONDOWN and event.button == 1:
            # 状態を更新
예제 #4
0
from draw import draw_board, draw_star
import time
import curses
import keyboard
from block import draw_block
import random

width = 10
height = 10
speed = 0.75
y_start = width // 2
x_start = 1
draw_board(width, height)  # draw a board
time.sleep(1)  # wait a second
star_y = y_start
star_x = x_start
revolve = 1
# pattern = random.randint(1, 7)
pattern = 2
floor = height - 2
state = [[0] * width for i in range(height)]


def keyhandler(e):
    global star_y
    global star_x
    global revolve
    global pattern
    global state
    if (e.name == "right"):
        draw_block(star_x, star_y, revolve, pattern, state, " ")
예제 #5
0
from winner import who_wins

# Set a while flag
playing = True

game = [
    [" ", " ", " "],
    [" ", " ", " "],
    [" ", " ", " "],
]

player1 = "X"
player2 = "O"

clear()
draw_board(game)
while playing:

    winner = who_wins(game)
    if check_if_finished(game) and not winner:
        take_input_from_player(player1, game)

    winner = who_wins(game)
    if check_if_finished(game) and not winner:
        take_input_from_player(player2, game)

    if winner:
        playing = False

print("The winner is player {}!\n".format(winner))
예제 #6
0
# モデル読み込み
agent.model.load_state_dict(
    torch.load('data/model_15984.pth', map_location=torch.device('cpu')))

# 状態等の準備
env.reset()
state_t_1, reward_t, terminal = env.observe()
legal_hands = env.legal_hands[0]
player_no = 1

# passしたらTrueにし、passでなかったらFalseに戻す
# Trueの時に再びpassが起きたらゲーム終了
pass_flag = False

# board描画
draw_board(state_t_1, screen, 1, stop)
indicate_legal_hands(state_t_1, screen, legal_hands)

pygame.display.update()  # 画面を更新

# ゲームループ
while True:

    # イベント処理
    for event in pygame.event.get():
        if event.type == QUIT:
            sys.exit()

        # 左クリックで石おく
        elif event.type == MOUSEBUTTONDOWN and event.button == 1:
예제 #7
0
def test_draw(board_advanced, board_basic):
    """Test the drawing of static board objects.
    Requires manual viewing
    """
    draw.draw_board(board_advanced, 100, "testmap.png")
    draw.draw_board(board_basic, 56, "testmap2.png")
예제 #8
0
def test_draw_with_clues(game_with_plays):
    """Test the drawing of a board with plays."""
    draw.draw_board(game_with_plays.board, 100, "testclues.png")
예제 #9
0
b.cell_matrix[4][0].is_mine = True
b.mine_left = 7

b.query([0, 2])
gb.update_neighbors([0, 2], b)
b.query([1, 0])
gb.update_neighbors([1, 0], b)
b.query([2, 0])
gb.update_neighbors([2, 0], b)
b.query([3, 0])
gb.update_neighbors([3, 0], b)
b.query([0, 3])
gb.update_neighbors([0, 3], b)
b.query([0, 4])
gb.update_neighbors([0, 4], b)

b.mark([0, 0])
gb.update_neighbors([0, 0], b)
b.mark([0, 1])
gb.update_neighbors([0, 1], b)
b.mark([1, 2])
gb.update_neighbors([1, 2], b)
b.mark([3, 1])
gb.update_neighbors([3, 1], b)
b.mark([4, 0])
gb.update_neighbors([4, 0], b)
print(b.value_matrix)
draw_board(b.value_matrix)
fr = [[0, 2], [0, 3], [0, 4], [1, 0], [2, 0], [3, 0]]
print(gb.improved_guess(fr, b))
예제 #10
0
 def draw(self):
     return draw.draw_board(self)