PEP8 check, mostly
parent
2e60bf39ef
commit
0c28898b8c
|
@ -3,3 +3,4 @@ demos/
|
||||||
.idea/
|
.idea/
|
||||||
*/__pycache__/*
|
*/__pycache__/*
|
||||||
*.pyc
|
*.pyc
|
||||||
|
*/highscore.txt
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
# TODO: Rewrite this to use array instead?
|
|
||||||
"""
|
"""
|
||||||
Module to solve any Sudoku Board
|
Module to solve any Sudoku Board
|
||||||
Credits for Solver : http://norvig.com/sudoku.html
|
Credits for Solver : http://norvig.com/sudoku.html
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def cross(array1, array2):
|
def cross(array1, array2):
|
||||||
"""Cross product of elements in A and elements in B."""
|
"""Cross product of elements in A and elements in B."""
|
||||||
return [a+b for a in array1 for b in array2]
|
return [a+b for a in array1 for b in array2]
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import os
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from . import Sudoku_Generator as sdk_gen
|
from . import Sudoku_Generator as SdkGen
|
||||||
|
|
||||||
EMPTY = 0
|
EMPTY = 0
|
||||||
VALID = 1
|
VALID = 1
|
||||||
|
@ -131,7 +130,7 @@ class SudokuSystem:
|
||||||
|
|
||||||
def generate_random_board(self, difficulty):
|
def generate_random_board(self, difficulty):
|
||||||
self.clear_grid()
|
self.clear_grid()
|
||||||
self.number_grid[:] = sdk_gen.generate_sudoku_puzzle(difficulty)
|
self.number_grid[:] = SdkGen.generate_sudoku_puzzle(difficulty)
|
||||||
row, col = np.where(self.number_grid == 0)
|
row, col = np.where(self.number_grid == 0)
|
||||||
|
|
||||||
for r, c in zip(row, col):
|
for r, c in zip(row, col):
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
def bound_value(lower, val, higher):
|
def bound_value(lower, val, higher):
|
||||||
return min(max(val, lower), higher)
|
return min(max(val, lower), higher)
|
||||||
|
|
||||||
|
|
||||||
def print_rect_info(rect):
|
def print_rect_info(rect):
|
||||||
print(rect.x(), rect.y(), rect.width(), rect.height())
|
print(rect.x(), rect.y(), rect.width(), rect.height())
|
||||||
|
|
|
@ -14,6 +14,7 @@ def generate_highscore_file(file):
|
||||||
if not i == 4:
|
if not i == 4:
|
||||||
f.write('\n---\n')
|
f.write('\n---\n')
|
||||||
|
|
||||||
|
|
||||||
def read_highscore_file(file):
|
def read_highscore_file(file):
|
||||||
with open(file, 'r') as f:
|
with open(file, 'r') as f:
|
||||||
file_data = f.read()
|
file_data = f.read()
|
||||||
|
@ -62,4 +63,4 @@ if __name__ == "__main__":
|
||||||
#score = read_highscore_file("./highscore.txt")
|
#score = read_highscore_file("./highscore.txt")
|
||||||
#replace_placing(score, DIFFICULTIES[2], 'abcv', 12345)
|
#replace_placing(score, DIFFICULTIES[2], 'abcv', 12345)
|
||||||
#write_highscore_file("./new_highscore.txt", score)
|
#write_highscore_file("./new_highscore.txt", score)
|
||||||
generate_highscore_file("./highscore.txt")
|
generate_highscore_file("./highscore.txt")
|
||||||
|
|
|
@ -15,7 +15,7 @@ from general import extras
|
||||||
RANDOMCHAR = "~!@#$%^&*()_+`-=[]\{}|;:'<>,./?\""
|
RANDOMCHAR = "~!@#$%^&*()_+`-=[]\{}|;:'<>,./?\""
|
||||||
|
|
||||||
|
|
||||||
class animBox(QGraphicsObject):
|
class AnimBox(QGraphicsObject):
|
||||||
# Prepare the signal
|
# Prepare the signal
|
||||||
hoverEnter = pyqtSignal()
|
hoverEnter = pyqtSignal()
|
||||||
hoverExit = pyqtSignal()
|
hoverExit = pyqtSignal()
|
||||||
|
|
|
@ -158,7 +158,7 @@ class DifficultyMenu(QGraphicsWidget):
|
||||||
self.width = self.btn_width
|
self.width = self.btn_width
|
||||||
|
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
btn = buttons.animBox(0, (self.btn_height + 10) * i,
|
btn = buttons.AnimBox(0, (self.btn_height + 10) * i,
|
||||||
self.btn_width, self.btn_height, DIFFICULTIES[i], parent=self)
|
self.btn_width, self.btn_height, DIFFICULTIES[i], parent=self)
|
||||||
btn.buttonClicked.connect(self.clicked_on)
|
btn.buttonClicked.connect(self.clicked_on)
|
||||||
self.diff_buttons.append(btn)
|
self.diff_buttons.append(btn)
|
||||||
|
@ -199,7 +199,6 @@ class HighScoreDisplayer(QGraphicsObject):
|
||||||
self.scoreboard_widget.setVisible(False)
|
self.scoreboard_widget.setVisible(False)
|
||||||
|
|
||||||
self.setAcceptHoverEvents(True)
|
self.setAcceptHoverEvents(True)
|
||||||
#self.show_board(True)
|
|
||||||
self.selected = False
|
self.selected = False
|
||||||
|
|
||||||
def set_disabled(self, state):
|
def set_disabled(self, state):
|
||||||
|
|
|
@ -221,6 +221,7 @@ class SudokuGrid(BaseSudokuItem):
|
||||||
|
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
|
|
||||||
class NumberRing(BaseSudokuItem):
|
class NumberRing(BaseSudokuItem):
|
||||||
# TODO: Add functions to animated the ring appearing
|
# TODO: Add functions to animated the ring appearing
|
||||||
# TODO: Adjust the positioning of each element
|
# TODO: Adjust the positioning of each element
|
||||||
|
@ -239,7 +240,7 @@ class NumberRing(BaseSudokuItem):
|
||||||
cell_string = 'X'
|
cell_string = 'X'
|
||||||
else:
|
else:
|
||||||
cell_string = str(i)
|
cell_string = str(i)
|
||||||
btn = buttons.animBox(0, 0, self.cell_width,
|
btn = buttons.AnimBox(0, 0, self.cell_width,
|
||||||
self.cell_height, cell_string, parent=self)
|
self.cell_height, cell_string, parent=self)
|
||||||
self.cell_buttons.append(btn)
|
self.cell_buttons.append(btn)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue