dimanche 22 novembre 2015

python sudoku like game

i have to creat a sudoku like game in a 4x4 field, but i dont know how to start. The rules are the same:

1.in a row numbers 1 to 4
2.in a column numbers 1 to 4
3.number is only one time avaible in row and column
4.generate a game automatically

i started with a list and tried the shuffle, but i dont know how to check the columns and rows for a comination that fits the rules

# create a matrix 4x4
s = list([[ 1, 2, 3, 4],
          [ 1, 2, 3, 4],
          [ 1, 2, 3, 4],
          [ 1, 2, 3, 4]])

# set random position
random.shuffle(s[0])
random.shuffle(s[1])
random.shuffle(s[2])
random.shuffle(s[3])

the field does not have to be filled with numbers, because the player has to put numbers later. Later the game has to provide numbers on the sides that point to the "4" in the 4x4 field.




Aucun commentaire:

Enregistrer un commentaire