I have a class named Board
that acts as a superclass.
It is basically a randomly generated Sudoku Board with 81 numbers placing correctly on it by the rules.
Then I defined a subclass named normalSudoku
where it will be initialized with a parameter "difficulties"(a string) where it will decide how many empty entries will appear on the Sudoku.
When I created an instance of normalSudoku and try to print it out to see if it works, the following error pops out:
TypeError: module.__init__() takes at most 2 arguments (3 given)
I am not sure what I did wrong and I am a bit confused about the use of self
and object initialization in python.
My Board
Class:
class Board(object):
def __init__(self):
self.sudoku = self.__create__()
def __create__(self):
#generateion of board goes here
#it will return a 9x9 2d-list
My normalSudoku
Class:
import Board
import random
class normalSudoku(Board):
def __init__(self,difficulties):
Board.Board.__init__(self)
self.Create_Empty_Entries(self,difficulties)
def Create_Empty_Entries(self, difficulties):
numbers = list(range(0,9))
if difficulties == "Easy":
for x in range(25):
a = random.choice(numbers)
b = random.choice(numbers)
self.sudoku[a][b] = None
elif difficulties == "Medium":
for x in range(35):
a = random.choice(numbers)
b = random.choice(numbers)
self.sudoku[a][b] = None
elif difficulties == "Hard":
for x in range(45):
a = random.choice(numbers)
b = random.choice(numbers)
self.sudoku[a][b] = None
elif difficulties == "Expert":
for x in range(65):
a = random.choice(numbers)
b = random.choice(numbers)
self.sudoku[a][b] = None
else:
print("The Level of Difficulty you chose does not exist.")