Puzzle class for the Mystery Master Logic Puzzle Solver. Note: A puzzle module returns the puzzle object - it does not inherit from this class!

Michael Benson

2021-08-31

Constructors

  • Creates the Puzzle object.

    Parameters

    • name: string

      Name.

    • title: string

      Title.

    • rank: number

      Rank: 1 (easy) to 5 (genius).

    • blurb: string

      Blurb.

    • author: string = ""

      Author (may be blank).

    • source: string = ""

      Source (may be blank).

    • enabled: boolean = true

      Enabled (true or false).

    Returns Puzzle

Properties

answer: number[][] = null
asString: () => string = toString
author: string = ""
blurb: string = null
enabled: boolean = true
facts: Fact[] = []
links: Link[] = []
name: string = null
nounTypes: NounType[] = []
numNouns: number = 0
rank: number = 0
rules: Rule[] = []
source: string = ""
title: string = null
valid: boolean = false
verbs: Verb[] = ...

Methods

  • Creates and appends fact to array of facts.

    Parameters

    • clueNum: string

      Clue number(s).

    • nounA: Noun | Noun[]

      Noun(s) A of fact.

    • verb: Verb

      Verb of fact.

    • link: Link

      Link of fact.

    • nounB: Noun | Noun[] = null

      Noun(s) B of fact, or null.

    • name: string = null

      Name of fact, or null.

    • initEnabled: boolean = true

      Initially enable/disable fact.

    Returns void

    Fact.

  • Creates and appends fact(s) to array of facts.

    Parameters

    • clueNum: string

      Clue number(s).

    • nouns: Noun[]

      Array of nouns to create fact(s).

    • verb: Verb

      Verb of fact(s).

    • link: Link

      Link of fact(s).

    • name: string = null

      Name of fact(s), or null.

    • initEnabled: boolean = true

      Initially enable/disable fact(s).

    Returns void

  • Creates and appends fact(s) to array of facts.

    Parameters

    • clueNum: string

      Clue number(s).

    • nounType1: NounType

      Noun type 1.

    • nounType2: NounType

      Noun type 2.

    • flag: boolean

      Flag if first character of noun 2's name [not] match character.

    • name: string = null

      Name of fact(s), or null.

    • initEnabled: boolean = true

      Initially enable/disable fact(s).

    Returns void

  • Creates and appends new fact(s) to array of facts.

    Parameters

    • clueNum: string

      Clue number(s).

    • nouns: Noun[]

      Noun(s) to create fact(s).

    • link: Link

      Link of fact(s).

    • name: string = null

      Name of fact(s), or null.

    • initEnabled: boolean = true

      Initially enable/disable fact(s).

    Returns void

  • Creates and appends fact(s) to array of facts.

    Parameters

    • clueNum: string

      Clue number(s).

    • nounA: NounType | Noun[]

      Noun type or array of nouns to create fact(s).

    • verb: Verb

      Verb of fact(s).

    • link: Link

      Link of fact(s).

    • nounB: NounType | Noun[]

      Noun type or array of nouns to create fact(s).

    • name: string = null

      Name of fact(s), or null.

    • initEnabled: boolean = true

      Initially enable/disable fact(s).

    Returns void

  • Creates and appends fact(s) to array of facts.

    Parameters

    • clueNum: string

      Clue number(s).

    • noun1: Noun

      Noun 1 of fact(s).

    • nounType2: NounType

      Noun type 2 of fact(s).

    • flag: boolean

      Flag if first character of noun 2's name [not] match character.

    • ch: string

      Character to test.

    • name: string = null

      Name of fact(s), or null.

    • initEnabled: boolean = true

      Initially enable/disable fact(s).

    Returns void

  • Creates and appends link to array of links.

    Parameters

    • name: string

      Name of link.

    • nounType: NounType

      Noun type of link.

    • getVerb: LinkFunction = null

      Function that returns verb based on relationship between two nouns.

    Returns Link

    Link.

  • Creates and appends noun type to array of noun types.
    Note: When first noun type is created, the "with" link is created.

    Parameters

    • name: string

      Name of noun type.

    Returns NounType

    Noun Type.

  • Creates and appends rule to array of rules.

    Parameters

    • clueNum: string

      Clue number(s).

    • name: string

      Name of rule.

    • nouns: Noun[] = []

      Nouns referenced by rule.

    • initEnabled: boolean = true

      Initially enable/disable rule.

    Returns Rule

    Rule.

  • Returns noun given its one-based number of noun type, and itself.

    Parameters

    • typeNum: number

      One-based number of noun type.

    • num: number

      One-based number of noun.

    Returns Noun

    Noun.

  • Returns Noun Type given its one-based number.

    Parameters

    • num: number

      One-based number of noun type.

    Returns NounType

    NounType.

  • Return verb given its zero-based number.

    Parameters

    • num: number

      Zero-based number.

    Returns Verb

    Verb.

  • Determines if solution is correct. Called by addMark.

    Returns boolean

    True if solution is correct (or answer is null), otherwise false.

  • Resets the puzzle. Called by solver.reset.

    Returns void

  • Returns "proper English" for fact. Puzzle module should override this method.

    Parameters

    • noun1: Noun

      Noun 1 of fact.

    • verb: Verb

      Verb of fact.

    • link: Link

      Link of fact.

    • noun2: Noun

      Noun 2 of fact.

    Returns string

    Name of fact.

  • Returns string

  • Validates puzzle and sets valid flag accordingly.

    Returns number

    Status -1=fail, 0=okay.