Documentation
¶
Overview ¶
Package learn holds the interactive tutorial: an ordered set of lessons, each a sequence of steps that pairs a position on the board with a short piece of prose, and where useful with a task the learner answers by choosing a hole.
The package renders nothing and reads no input. A step hands the UI a position, a set of holes worth marking, and a checker that turns the learner's chosen hole into feedback.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Rules ¶
Rules returns the ruleset every lesson position assumes. Two of its settings are load-bearing rather than incidental: linking is deliberate, because one lesson teaches declining a link, and a player's own links block, because another teaches that they do. A caller must build the tutorial's game from this and not from the ruleset of whatever game the player was last in.
Types ¶
type Lesson ¶
Lesson is one topic, taught as a sequence of steps.
type Step ¶
type Step struct {
// Text is the prose shown to the learner. It carries no line breaks, so the
// UI may wrap it at any width.
Text string
// Setup is played onto a fresh game before the step, in game notation.
Setup []string
// Highlight marks holes the UI should call out.
Highlight []game.Point
// Task, when non-nil, requires the learner to make a move before
// continuing.
Task *Task
}
Step is one screen of the tutorial.
type Task ¶
type Task struct {
Prompt string
// Answer is one hole that satisfies the task, so the UI can show the
// learner an answer once they have struggled. Where several moves are
// right, it is the one the prose talks about.
Answer game.Point
// Accept reports whether the learner's move satisfies the step, and returns
// the feedback to show either way.
//
// It is given the position the step set up, with the learner's side to
// move, and the hole the learner chose, including holes the learner is not
// allowed to use: the two mistakes beginners actually make, reaching into
// the opponent's border line and reaching for a corner, are illegal moves,
// and a learner who is silently stopped from making them is never told why.
// So the UI must pass the raw choice through rather than filtering it, and
// play it onto the board only when Accept returns true. Accept never
// modifies the game it is given.
Accept func(g *game.Game, played game.Point) (ok bool, feedback string)
}
Task is a move the learner has to find.