Intelligent Hinting

version 5 by Aaron Reed

  • Home page
  • Beginning
  • Previous
  • Next



  • Section - Task Completion

    [Just before reading a command (to avoid "last every turn" issues), check all rules that we've defined to see if any tasks should change to complete or incomplete. If this affects the saved endeavor, which is used to keep track of what we're working on, adjust it as necessary. ]

    The list of cached-solved tasks is a list of things that varies.

    To update the task status cache:
        repeat with item running through tasks:
            if item is reversible and item is solved and item is incomplete:
                let tmpitem be item;
                while tmpitem is not Winning-The-Game and tmpitem is listed in list of cached-solved tasks:
                    if puzzle-testing changes or puzzle-testing all:
                        say "(task [tmpitem] is now unsolved)";
                        if the number of incomplete tasks in requiree of tmpitem is 1, say "(hence [requiree of tmpitem] now unsolved)";
                    remove tmpitem from list of cached-solved tasks;
                    now tmpitem is requiree of tmpitem;
            otherwise if item is unsolved and item is complete:
                let tmpitem be item;
                while tmpitem is not Winning-The-Game and tmpitem is not listed in list of cached-solved tasks:
                    if puzzle-testing changes or puzzle-testing all:
                        say "(task [tmpitem] is now solved)";
                        if requiree of tmpitem is solved, say "(hence [requiree of tmpitem] now solved)";
                    add tmpitem to list of cached-solved tasks, if absent;
                    let myctr be 0;
                    repeat with reqs running through things required by requiree of tmpitem:
                        if reqs is unsolved, increase myctr by 1;
                    if myctr is 0, now tmpitem is requiree of tmpitem;
    [ say "**l: [list of cached-solved tasks]**";]
        while saved endeavor is not nothing:
            if saved endeavor is Winning-The-Game:
                now saved endeavor is nothing;
                break;
            if saved endeavor is unsolved:
    [ say "(**it seems [saved endeavor] is unsolved: ";]
    [ repeat with item running through things required by saved endeavor:
                    if item is a task, say "[item]: [if item is complete]complete[end if]/[if item is incomplete]incomplete[end if]/[if item is solved]solved[end if]/[if item is unsolved]unsolved[end if])";
                    otherwise say "[item] (not a task)";]
                break;
            now saved endeavor is requiree of saved endeavor;
    [ say "(**now saved endeavor is [saved endeavor]**)";]
            if saved endeavor is unsolved:
                break;
        repeat with item running through list of cached-solved tasks:
            if item is a task and the action-position of item is not 0, now action-position of item is 0.

    [It may not seem at first glance that it is strictly necessary to do this each turn, as opposed to each turn when a suggestion is requested; but since irreversible tasks might be true for only a single turn, and due to complexities involving the parsing of command-sequences, we always need to do this.]

    Before reading a command (this is the keep task completion up to date rule):
        update the task status cache.

    Definition: a task is incomplete if it is not complete. [Each task defines its own criteria for being "complete," but we can define a global negation. ]