Solver class for the Mystery Master Logic Puzzle Solver.

Michael Benson

2021-08-31

Implements

Constructors

Properties

callback: Function = null

Callback called by Viewer.doResume. MUST set callback in each method!

grids: Mark[][][] = []
marks: Mark[] = []
maxGrids: number = 0
maxMarks: number = 0
maxPairs: number = 0
numFactHits: number = 0
numFacts: number = 0
numGoodMarks: number = 0
numGuesses: number = 0
numMarks: number = 0
numPairs: number = 0
numRuleHits: number = 0
numRules: number = 0
numSolutions: number = 0
okTriggers: boolean = true
puzzle: Puzzle = null
quitFlag: boolean = false
stats: Stats = ...
workFlag: boolean = false
MAX_LAWS: number = 5
MAX_LEVELS: number = 4

Methods

  • Submits potential mark. Note: If potential mark contradicts existing mark, either: (1) quit if potential mark is not assumption, or (2) undo last assumption.

    Parameters

    • levelNum: number

      Level number

    • levelSub: string

      Level character.

    • markType: MarkType

      Mark type.

    • refNum: number

      Reference number.

    • refSub: string

      Reference character.

    • noun1: Noun

      Noun 1.

    • verb: Verb

      Verb.

    • noun2: Noun

      Noun 2.

    • reason: string

      Reason for mark.

    • facts: Fact[] = []

      Facts referenced.

    • refMark: Mark = null

      Mark referenced.

    • offFacts: Fact[] = []

      Facts disabled by potential mark.

    Returns number

    status -1=Error, 0=Exists, 1=Entered.

  • Submits potential mark triggered by given rule invoked on given mark.

    Parameters

    • mark: Mark

      Mark referenced.

    • rule: Rule

      Rule referenced.

    • refSub: string

      Reference character.

    • noun1: Noun

      Noun 1.

    • verb: Verb

      Verb.

    • noun2: Noun

      Noun 2.

    • reason: string

      Reason for mark.

    Returns number

    status -1 = Error, 0 = Mark not entered, 1 = Mark entered.

  • Returns string

  • Determines if noun 1 can be related to slot 2, otherwise false. Called by Lawyer.

    Parameters

    • noun1: Noun

      Noun 1.

    • link: Link

      Link.

    • slot2: Noun

      Slot 2.

    • i: number

      Position 1 = First, 2 = Second.

    Returns boolean

    True if noun 1 can be related to slot 2, otherwise false.

  • Determines if noun 1 can be with noun 2.

    Parameters

    Returns boolean

    True if noun 1 can be with noun 2, otherwise false.

  • Stops solving the puzzle. Called by Finder.doNextLevel, Finder.doAssumptions.

    Returns void

  • Starts solving puzzle with sanity check. Called by viewer.doSolve.

    Returns void

  • Returns first noun of noun type 3 that noun 1 and noun 2 can be with, otherwise null.

    Parameters

    Returns Noun

    Noun of noun type 3, or null.

  • Returns mark in grid given by two nouns. Called by Lawyer.

    Parameters

    Returns Mark

    Mark.

  • Determines verb of mark given by two nouns, or possible verb if mark is null.

    Parameters

    Returns Verb

    Verb of mark given by two nouns, or possible verb if mark is null.

  • Returns list of nouns of noun type 2 that may be with noun 1.

    Parameters

    Returns Noun[]

    Array of nouns, which may be empty.

  • Determines if mark already exists.

    Parameters

    Returns boolean

    True if mark already exists, otherwise false.

  • Determines if noun 1 is/maybe related to noun 2.
    Called by "New Self Improvement Committee".

    Parameters

    Returns boolean

    True if noun 1 is/maybe related to noun 2, otherwise false.

  • Resets the solver. Called by viewer.reset, setPuzzle.

    Returns void

  • Parameters

    Returns void

  • Parameters

    • msg: string
    • mark: Mark

    Returns void

  • Parameters

    • num: number
    • sub: string
    • callback: Function

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Sets the puzzle. Called by viewer.setPuzzle.

    Parameters

    Returns void

  • Returns string

  • Removes marks back to and including the last mark entered by Finder.
    Called by finder.doAssumptions, callback from removeMark.

    Returns void

  • Removes marks back to and including the last mark entered by User.
    Called when User clicks the Undo button on the Grids form.

    Returns void

  • Updates variables affected by Setup form. Called by viewer.updateOption.

    Parameters

    • key: string

      Key.

    • val: boolean

      Value.

    Returns void