clone

fifteen puzzle games for the terminal, with daily puzzles, weekly ladders and xp, built on bubble tea

feat/elo-difficulty
puzzletea / games / sudokurgb / gamemode.go
gamemode.go 2.4K
1package sudokurgb23import (4 _ "embed"5 "math/rand/v2"67 "github.com/FelineStateMachine/puzzletea/difficulty"8 "github.com/FelineStateMachine/puzzletea/game"9 "github.com/FelineStateMachine/puzzletea/gameentry"10 "github.com/FelineStateMachine/puzzletea/puzzle"11)1213//go:embed help.md14var HelpContent string1516type SudokuRGBMode struct {17 game.BaseMode18 ProvidedCount int19}2021var (22 _ game.Mode = SudokuRGBMode{}23 _ game.Spawner = SudokuRGBMode{}24 _ game.SeededSpawner = SudokuRGBMode{}25 _ game.EloSpawner = SudokuRGBMode{}26)2728func NewMode(title, description string, providedCount int) SudokuRGBMode {29 return SudokuRGBMode{30 BaseMode: game.NewBaseMode(title, description),31 ProvidedCount: providedCount,32 }33}3435func (s SudokuRGBMode) Spawn() (game.Gamer, error) {36 return New(s, GenerateProvidedCells(s))37}3839func (s SudokuRGBMode) SpawnSeeded(rng *rand.Rand) (game.Gamer, error) {40 return New(s, GenerateProvidedCellsSeeded(s, rng))41}4243var Modes = []game.Mode{44 NewMode("Beginner", "60 clues. Gentle intro to RGB quota logic.", 60),45 NewMode("Easy", "54 clues. Early rows and boxes resolve quickly.", 54),46 NewMode("Medium", "48 clues. Mixed row, column, and box pressure.", 48),47 NewMode("Hard", "42 clues. More ambiguous houses and cross-checking.", 42),48 NewMode("Expert", "36 clues. Sparse givens require deeper scanning.", 36),49 NewMode("Diabolical", "30 clues. Tightest clue budget in the launch set.", 30),50}5152var ModeDefinitions = sudokuRGBModeDefinitions(Modes)5354func sudokuRGBModeDefinitions(modes []game.Mode) []puzzle.ModeDef {55 defs := gameentry.BuildModeDefs(modes)56 presets := []difficulty.Elo{0, 600, 1200, 1800, 2400, 3000}57 for i := range defs {58 if i >= len(presets) {59 break60 }61 elo := presets[i]62 defs[i].PresetElo = &elo63 }64 return defs65}6667var Definition = puzzle.NewDefinition(puzzle.DefinitionSpec{68 Name: "Sudoku RGB",69 Description: "Fill the board with RGB symbols so each row, column, and 3x3 box contains {1,1,1,2,2,2,3,3,3}. [1,2,3] maps to [▲,■,●]. Inspired by Sudoku Ripeto.",70 Aliases: []string{"rgb sudoku", "ripeto", "sudoku ripeto"},71 Modes: ModeDefinitions,72 DailyModeIDs: puzzle.SelectModeIDsByIndex(ModeDefinitions, 1, 2),73})7475var Entry = gameentry.NewEntry(gameentry.EntrySpec{76 Definition: Definition,77 Help: HelpContent,78 Import: game.AdaptImport(ImportModel),79 Modes: Modes,80 Print: PDFPrintAdapter,81})