~piotr-machura/sweep-ai

08977605c382bf7e93bf1a56f9b10efde6ec8be0 — Piotr Machura 2 years ago a45396e
Create cache directory if it does not exist
2 files changed, 4 insertions(+), 8 deletions(-)

M sweep_ai/ai.py
M sweep_ai/window.py
M sweep_ai/ai.py => sweep_ai/ai.py +1 -0
@@ 157,6 157,7 @@ class Player:
                        axis=0,
                    )
                    state.click(*state.cheat())
            x_loc.parent.mkdir(parents=True, exist_ok=True)
            np.save(x_loc, x_train)
            np.save(y_loc, y_train)


M sweep_ai/window.py => sweep_ai/window.py +3 -8
@@ 1,7 1,7 @@
"""Window handling module."""
import sys
from threading import Thread
from pathlib import Path
from threading import Thread
from typing import Optional, Tuple

import pygame


@@ 12,6 12,7 @@ from .logic import State

# pylint: disable=invalid-name


class Game:
    """Game class."""
    DIFFICULTY = {


@@ 172,7 173,6 @@ class Game:
        self.player = Player(self.size, self.difficulty)
        self.reset()


    def set_size(self, *args):
        """Set a new board size."""
        self.size = args[1]


@@ 185,6 185,7 @@ class Game:

    def get_hint(self):
        """Highlight the position suggested by the AI player."""

        def hint_cb():
            if not self.player.trained:
                if not self.train_thread.is_alive():


@@ 303,9 304,3 @@ class Game:
                else:
                    self.handle_click(event)
            self.timer.tick(10)


def main():
    """Main gameplay entry point."""
    game = Game()
    game.loop()