Documentation
¶
Overview ¶
Package hashiwokakero implements the bridge-connecting puzzle game.
Index ¶
- Variables
- func New(mode HashiMode, puzzle Puzzle) game.Gamer
- type Bridge
- type HashiMode
- type Island
- type KeyMap
- type Model
- func (m Model) GetDebugInfo() string
- func (m Model) GetFullHelp() [][]key.Binding
- func (m Model) GetSave() ([]byte, error)
- func (m Model) Init() tea.Cmd
- func (m Model) IsSolved() bool
- func (m Model) Reset() game.Gamer
- func (m Model) SetTitle(t string) game.Gamer
- func (m Model) Update(msg tea.Msg) (game.Gamer, tea.Cmd)
- func (m Model) View() string
- type Puzzle
- func (p *Puzzle) BridgeCount(islandID int) int
- func (p *Puzzle) CellContent(x, y int) cellInfo
- func (p *Puzzle) FindAdjacentIsland(fromID, dx, dy int) *Island
- func (p *Puzzle) FindIslandAt(x, y int) *Island
- func (p *Puzzle) FindIslandByID(id int) *Island
- func (p *Puzzle) GetBridge(id1, id2 int) *Bridge
- func (p *Puzzle) IsConnected() bool
- func (p *Puzzle) IsSolved() bool
- func (p *Puzzle) SetBridge(id1, id2, count int)
- func (p *Puzzle) WouldCross(id1, id2 int) bool
- type Save
Constants ¶
This section is empty.
Variables ¶
var DefaultKeyMap = KeyMap{ CursorKeyMap: game.DefaultCursorKeyMap, Select: key.NewBinding( key.WithKeys("enter", "space"), key.WithHelp("enter/space", "Select/Deselect"), ), }
var Definition = puzzle.NewDefinition(puzzle.DefinitionSpec{ Name: "Hashiwokakero", Description: "Connect the islands with bridges.", Aliases: []string{"hashi", "bridges"}, Modes: ModeDefinitions, DailyModeIDs: puzzle.SelectModeIDsByIndex(ModeDefinitions, 3, 1), })
var Entry = gameentry.NewEntry(gameentry.EntrySpec{ Definition: Definition, Help: HelpContent, Import: game.AdaptImport(ImportModel), Modes: Modes, Print: PDFPrintAdapter, })
var HelpContent string
var ModeDefinitions = gameentry.BuildModeDefs(Modes)
var Modes = []game.Mode{ NewMode("Easy 7x7", "7x7 grid with 8-10 islands.", 7, 7, 8, 10), NewMode("Medium 7x7", "7x7 grid with 12-15 islands.", 7, 7, 12, 15), NewMode("Hard 7x7", "7x7 grid with 17-20 islands.", 7, 7, 17, 20), NewMode("Easy 9x9", "9x9 grid with 12-16 islands.", 9, 9, 12, 16), NewMode("Medium 9x9", "9x9 grid with 20-24 islands.", 9, 9, 20, 24), NewMode("Hard 9x9", "9x9 grid with 28-32 islands.", 9, 9, 28, 32), NewMode("Easy 11x11", "11x11 grid with 18-24 islands.", 11, 11, 18, 24), NewMode("Medium 11x11", "11x11 grid with 30-36 islands.", 11, 11, 30, 36), NewMode("Hard 11x11", "11x11 grid with 42-48 islands.", 11, 11, 42, 48), NewMode("Easy 13x13", "13x13 grid with 25-34 islands.", 13, 13, 25, 34), NewMode("Medium 13x13", "13x13 grid with 42-51 islands.", 13, 13, 42, 51), NewMode("Hard 13x13", "13x13 grid with 59-68 islands.", 13, 13, 59, 68), }
var PDFPrintAdapter = printAdapter{}
Functions ¶
Types ¶
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
func ImportModel ¶
func (Model) GetDebugInfo ¶
func (Model) GetFullHelp ¶
type Puzzle ¶
type Puzzle struct {
Width, Height int
Islands []Island
Bridges []Bridge
// contains filtered or unexported fields
}
Puzzle holds the full game state.
func GeneratePuzzle ¶
GeneratePuzzle creates a solvable hashiwokakero puzzle for the given mode.
func GeneratePuzzleSeeded ¶ added in v1.3.0
func (*Puzzle) BridgeCount ¶
BridgeCount returns the total number of bridges connected to an island.
func (*Puzzle) CellContent ¶
CellContent returns what occupies the given grid cell, using a lazily-built cache.
func (*Puzzle) FindAdjacentIsland ¶
FindAdjacentIsland casts a ray from the island at fromID in direction (dx,dy) and returns the first island hit, or nil. dx/dy must be (0,1),(0,-1),(1,0),(-1,0). Stops if a perpendicular bridge crosses the path.
func (*Puzzle) FindIslandAt ¶
FindIslandAt returns the island at (x,y), or nil.
func (*Puzzle) FindIslandByID ¶
FindIslandByID returns the island with the given ID, or nil.
func (*Puzzle) IsConnected ¶
IsConnected checks if all islands form a single connected component via bridges.
func (*Puzzle) SetBridge ¶
SetBridge sets or removes the bridge between two islands. count=0 removes the bridge. count must be 0, 1, or 2.
func (*Puzzle) WouldCross ¶
WouldCross checks if adding a bridge between id1 and id2 would cross any existing bridge.
