Options
All
  • Public
  • Public/Protected
  • All
Menu

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

copyright

mysterymaster.com. All rights reserved.

author

Michael Benson

version

2021-08-31

Hierarchy

  • Puzzle

Index

Constructors

constructor

  • new Puzzle(name: string, title: string, rank: number, blurb: string, author?: string, source?: string, enabled?: boolean): Puzzle
  • 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

answer: number[][] = null

asString

asString: () => string = ...

Type declaration

    • (): string
    • Returns string

author

author: string = ""

blurb

blurb: string = null

enabled

enabled: boolean = true

facts

facts: Fact[] = []

links

links: Link[] = []

name

name: string = null

nounTypes

nounTypes: NounType[] = []

numNouns

numNouns: number = 0

rank

rank: number = 0

rules

rules: Rule[] = []

source

source: string = ""

title

title: string = null

valid

valid: boolean = false

verbs

verbs: Verb[] = ...

Methods

addFact

  • addFact(clueNum: string, nounA: Noun | Noun[], verb: Verb, link: Link, nounB?: Noun | Noun[], name?: string, initEnabled?: boolean): void
  • 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.

Private addFacts1

  • addFacts1(clueNum: string, nouns: Noun[], verb: Verb, link: Link, name?: string, initEnabled?: boolean): void
  • 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

Private addFacts2

  • addFacts2(clueNum: string, nouns1: Noun[], verb: Verb, link: Link, nouns2: Noun[], name?: string, initEnabled?: boolean): void
  • Creates and appends fact(s) to array of facts. Overload: nounA and nounB can each be one noun or a list of nouns.

    Parameters

    • clueNum: string

      Clue number(s).

    • nouns1: Noun[]
    • verb: Verb

      Verb of fact(s).

    • link: Link

      Link of fact(s).

    • nouns2: Noun[]
    • name: string = null

      Name of fact(s), or null.

    • initEnabled: boolean = true

      Initially enable/disable fact(s).

    Returns void

addFactsInSequence

  • addFactsInSequence(clueNum: string, nouns: Noun[], verb: Verb, link: Link, name?: string, initEnabled?: boolean): void
  • 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

addFactsIsNotFirstChar

  • addFactsIsNotFirstChar(clueNum: string, nounType1: NounType, nounType2: NounType, flag: boolean, name?: string, initEnabled?: boolean): 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

addFactsNotConsecutive

  • addFactsNotConsecutive(clueNum: string, nouns: Noun[], link: Link, name?: string, initEnabled?: boolean): 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

addFactsOneToOne

  • 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

addFactsStartsWith

  • addFactsStartsWith(clueNum: string, noun1: Noun, nounType2: NounType, flag: boolean, ch: string, name?: string, initEnabled?: boolean): 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

addLink

  • 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.

addNounType

  • 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.

Private addOneFact

  • addOneFact(clueNum: string, noun1: Noun, verb: Verb, link: Link, noun2: Noun, name?: string, initEnabled?: boolean): Fact
  • Creates and appends fact to array of facts.

    Parameters

    • clueNum: string

      Clue number(s).

    • noun1: Noun

      Noun 1 of fact.

    • verb: Verb

      Verb of fact.

    • link: Link

      Link of fact.

    • noun2: Noun

      Noun 2 of fact.

    • name: string = null

      Name of fact.

    • initEnabled: boolean = true

      Initally enable/disable fact.

    Returns Fact

    Fact.

addRule

  • addRule(clueNum: string, name: string, nouns?: Noun[], initEnabled?: boolean): Rule
  • 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.

Private getClueNumAsString

  • getClueNumAsString(clueNum: string, name: string): string
  • Returns clue number(s) in parenthesis from clueNum or name. Called by addOneFact, addRule.

    Parameters

    • clueNum: string

      Clue number(s).

    • name: string

      Name of clue.

    Returns string

    Clue number(s) as string.

Private getEncodedAnswer

  • getEncodedAnswer(): void
  • Displays the encoded answer for development only. Called by isAnswer.

    Returns void

getNoun

  • getNoun(typeNum: number, num: number): Noun
  • 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.

getNounType

  • Returns Noun Type given its one-based number.

    Parameters

    • num: number

      One-based number of noun type.

    Returns NounType

    NounType.

getVerb

  • getVerb(num: number): Verb
  • Return verb given its zero-based number.

    Parameters

    • num: number

      Zero-based number.

    Returns Verb

    Verb.

isAnswer

  • isAnswer(): boolean
  • Determines if solution is correct. Called by addMark.

    Returns boolean

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

reset

  • reset(): void
  • Resets the puzzle. Called by solver.reset.

    Returns void

sayFact

  • 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.

toString

  • toString(): string
  • Returns string

validate

  • validate(): number
  • Validates puzzle and sets valid flag accordingly.

    Returns number

    Status -1=fail, 0=okay.

Generated using TypeDoc