Original Parser

version 1 by Ron Newcomb

  • Home page
  • Beginning
  • Previous
  • Next

  • Chapter - SingleBestGuess

    [|SingleBestGuess| returns the highest-scoring object in the match list
    if it is the clear winner, or returns $-1$ if there is no clear winner.]

    To decide which object is the single best guess (this is SingleBestGuess):
        let the best object be the used-up object;
        let the best score so far be -1000;
        repeat through the match score list of size the number of objects in the match list:
            if the number element is the best score so far, now the best object is the used-up object;
            if the number element > the best score so far:
                now the best score so far is the number element;
                now the best object is the match list element;
        decide on the best object.

    [ SingleBestGuess earliest its_score best i;
    earliest = -1; best = -1000;
    for (i=0 : i<number_matched : i++) {
    its_score = match_scores-->i;
    if (its_score == best) earliest = -1;
    if (its_score > best) { best = its_score; earliest = match_list-->i; }
    return earliest;