Inform - Support - Source

Back to List

Inventory
Complete

Backward
Forward

Plain
Coloured
Gaudy

This code
in plain text

Browsing parserm.h

BestGuess (lines 2683-2712)

2683  !  BestGuess makes the best guess it can out of the match list, assuming that
2684  !  everything in the match list is textually as good as everything else;
2685  !  however it ignores items marked as -1, and so marks anything it chooses.
2686  !  It returns -1 if there are no possible choices.
2687  ! ----------------------------------------------------------------------------
2688   
2689  [ BestGuess  earliest its_score best i;
2690   
2691    earliest=0; best=-1;
2692    for (i=0:i<number_matched:i++)
2693    {   if (match_list-->i >= 0)
2694        {   its_score=match_scores-->i;
2695            if (its_score>best) { best=its_score; earliest=i; }
2696        }
2697    }
2698  #ifdef DEBUG;
2699    if (parser_trace>=4)
2700    {   if (best<0)
2701            print "   Best guess ran out of choices^";
2702        else
2703            print "   Best guess ", (the) match_list-->earliest,
2704                  " (", match_list-->earliest, ")^";
2705    }
2706  #endif;
2707    if (best<0) return -1;
2708    i=match_list-->earliest;
2709    match_list-->earliest=-1;
2710    bestguess_score = best;
2711    return i;
2712  ];


Last updated 27 February 2004. This site is no longer supported; information may be out of date.
Maintained as a historical archive by the Interactive Fiction Technology Foundation. Copyright 1993-2018 IFTF, CC-BY-SA unless otherwise noted.
This page was originally managed by Graham Nelson (graham@gnelson.demon.co.uk) assisted by C Knight.