0

I am developing sudoku game using javascript but numbers are in matrix so same game with same number will be generate again and again so how to generate random numbers in matrix each time i play game.

below i have mentioned code in this var sudoku matrix how to generate random numbers actually i have placed static numbers so i want each time page refresh new numbers should come ?so how to do this using js.

var Sudoku = {
  //-------------------------------GAME DATA---------------------------------
  matrix:[  [[7],[2],[],[9],[4],[5],[],[3],[]],
    [[],[3],[9],[2],[],[6],[],[],[4]],
    [[1],[5],[],[7],[3],[8],[6],[9],[2]],
    [[6],[4],[7],[1],[],[3],[],[2],[]],
    [[9],[8],[2],[6],[5],[7],[4],[1],[3]],
    [[3],[],[5],[4],[9],[2],[7],[],[6]],
    [[4],[9],[3],[],[6],[1],[],[5],[7]],
    [[5],[7],[],[3],[2],[],[8],[6],[9]],
    [[],[],[8],[5],[7],[9],[3],[4],[]]
  ],
}
SLePort
  • 15,211
  • 3
  • 34
  • 44
Anonymous
  • 1,074
  • 3
  • 13
  • 37
  • "Random numbers" won't be okay, you will generate a ton of unsolvable games. – Nico Haase Jun 28 '18 at 07:54
  • I dont think plain random numbers would work for a sudoku, since the value of other cells should not conflict on a per horizontal/vertical line. So you have to consider the existing values for a given cell's lanes before generating the random number for that cell – MKougiouris Jun 28 '18 at 07:55

0 Answers0