I am learning a bit about constraint solving using back tracking.

Back tracking is a general algorithm to solve problems where you have partial information about the solution. The algorithm I am using is deterministic and guaranteed to find a solution (if any).

quickbacktrack is a generic library that lets you debug and customize the search for solution.

Examples:

- Sudoku
- Knapsack
- 8 Queens

What I like about this method is the similarity to game level design. One could start with a rough design and use constraint solving to generate additional details. Then you could hand tune the result to your taste.

There is no need to tell specifically where to put things. Instead you can program the constraints such that a tree can not be closer to a building than 4 m, but you still want at least 200 trees in the area.

One problem can be the time required to find a solution. I made the search for next position customizable with the hope that there is an efficient heuristic for a typical game level.