- commit
- 582a09d735231bf966e72b40378405d54cf6cabb
- parent
- a61c52e9d9bc914ca1c941bb5bda081bca2a07d1
- author
- Dami <dami.etoile@gmail.com>
| M | nonogram/ | 9 | +++++++-- |
@@ -13,8 +13,9 @@ func GenerateRandomTomography(mode NonogramMode) Hints {
1313 maxDim := max(mode.Width, mode.Height)1414 timeout := time.Duration(maxDim) * time.Second1515 16- for range maxAttempts {17- s := generateRandomState(mode.Height, mode.Width, mode.Density)16+ for attempt := range maxAttempts {17+ density := lerp(mode.Density, 0.5, float64(attempt)*0.02)18+ s := generateRandomState(mode.Height, mode.Width, density)1819 g := newGrid(s)1920 hints := generateTomography(g)2021 if !isValidPuzzle(hints, mode.Height, mode.Width) {@@ -30,6 +31,10 @@ func GenerateRandomTomography(mode NonogramMode) Hints {
3031 return Hints{}3132 }3233 34+func lerp(a, b, t float64) float64 {35+ return a + (b-a)*t36+}37+3338 func generateRandomState(h, w int, density float64) state {3439 if h <= 0 || w <= 0 {3540 return ""