(See related changeset on CodePlex)
Puzzle level generation
The objective of the puzzle is to solve a Soduko like grid:
- The grid always has the same number of columns as rows.
- Each row must contain the numbers 1..n, where n is the size of the puzzle.
- Each column must contain the numbers 1..n, where n is the size of the puzzle.
- Each number may only occur once in each column.
- Each number may only occur once in each row.
The level generator works, after advice from Stack Overflow, by generating a grid in the following form:

Basically, the value in each cell (for any value of x in 0..n-1 and any value of y in 0..n-1) is (x + y) % size + 1
To generate random level (source code), rows are swapped randomly and then columns are swapped randomly. As it was mentioned on Stack Overflow, this will generate 216 different puzzles on a 5x5 board. Although there are other combinations, I will let the column and row swapping method be for now, because the implementation is easy.
Puzzle square drawing
The next step was to make the PuzzleSquare class. For now, it's a copy of the other GameEntity objects.
Below is a picture of a 7x7 grid and a 10x10. I doubt anything more than 8-ish will be playable on a phone. There are some imperfections in the margin/padding/width calculations that I'll look at later.


Next, the user must be able to click on square in the puzzle grid and then guess which number it is using buttons in the hud (right). I have never worked with user input in XNA, so that will be a challenge.
After that, I'll write the "hint groups". For example, the game will tell you that the number in (0, 0) equals 7 and that the sum of (0, 0) and (1, 0) is 10. In other words, you know that (1, 0) is 3, because 7+3=10. I haven't decided how to display hint groups yet.
0 comments:
Post a Comment