



BestGuess (lines 3403-3427)
Back to List
Browsing parserm.h
3403 ! BestGuess makes the best guess it can out of the match list, assuming that
3404 ! everything in the match list is textually as good as everything else;
3405 ! however it ignores items marked as -1, and so marks anything it chooses.
3406 ! It returns -1 if there are no possible choices.
3407 ! ----------------------------------------------------------------------------
3408
3409 [ BestGuess earliest its_score best i;
3410 earliest = 0; best = -1;
3411 for (i=0 : i<number_matched : i++) {
3412 if (match_list-->i >= 0) {
3413 its_score = match_scores-->i;
3414 if (its_score > best) { best = its_score; earliest = i; }
3415 }
3416 }
3417 #Ifdef DEBUG;
3418 if (parser_trace >= 4)
3419 if (best < 0) print " Best guess ran out of choices^";
3420 else print " Best guess ", (the) match_list-->earliest, " (", match_list-->earliest, ")^";
3421 #Endif; ! DEBUG
3422 if (best < 0) return -1;
3423 i = match_list-->earliest;
3424 match_list-->earliest = -1;
3425 bestguess_score = best;
3426 return i;
3427 ];
Last updated 27 February 2004. The librarian in charge of this page is Graham Nelson (graham@gnelson.demon.co.uk) assisted by C Knight. Please email any comments, suggestions or corrections to cedenqs@inform-fiction.org.