



ScoreMatchL (lines 3319-3400)
Back to List
Browsing parserm.h
3319 ! ScoreMatchL scores the match list for quality in terms of what the
3320 ! player has vaguely asked for. Points are awarded for conforming with
3321 ! requirements like "my", and so on. Remove from the match list any
3322 ! entries which fail the basic requirements of the descriptors.
3323 ! ----------------------------------------------------------------------------
3324
3325 [ ScoreMatchL context its_owner its_score obj i j threshold met a_s l_s;
3326 ! if (indef_type & OTHER_BIT ~= 0) threshold++;
3327 if (indef_type & MY_BIT ~= 0) threshold++;
3328 if (indef_type & THAT_BIT ~= 0) threshold++;
3329 if (indef_type & LIT_BIT ~= 0) threshold++;
3330 if (indef_type & UNLIT_BIT ~= 0) threshold++;
3331 if (indef_owner ~= nothing) threshold++;
3332
3333 #Ifdef DEBUG;
3334 if (parser_trace >= 4) print " Scoring match list: indef mode ", indef_mode, " type ",
3335 indef_type, ", satisfying ", threshold, " requirements:^";
3336 #Endif; ! DEBUG
3337
3338 a_s = SCORE__NEXTBESTLOC; l_s = SCORE__BESTLOC;
3339 if (context == HELD_TOKEN or MULTIHELD_TOKEN or MULTIEXCEPT_TOKEN) {
3340 a_s = SCORE__BESTLOC; l_s = SCORE__NEXTBESTLOC;
3341 }
3342
3343 for (i=0 : i<number_matched : i++) {
3344 obj = match_list-->i; its_owner = parent(obj); its_score=0; met=0;
3345
3346 ! if (indef_type & OTHER_BIT ~= 0
3347 ! && obj ~= itobj or himobj or herobj) met++;
3348 if (indef_type & MY_BIT ~= 0 && its_owner == actor) met++;
3349 if (indef_type & THAT_BIT ~= 0 && its_owner == actors_location) met++;
3350 if (indef_type & LIT_BIT ~= 0 && obj has light) met++;
3351 if (indef_type & UNLIT_BIT ~= 0 && obj hasnt light) met++;
3352 if (indef_owner ~= 0 && its_owner == indef_owner) met++;
3353
3354 if (met < threshold) {
3355 #Ifdef DEBUG;
3356 if (parser_trace >= 4) print " ", (The) match_list-->i, " (", match_list-->i, ") in ",
3357 (the) its_owner, " is rejected (doesn't match descriptors)^";
3358 #Endif; ! DEBUG
3359 match_list-->i = -1;
3360 }
3361 else {
3362 its_score = 0;
3363 if (obj hasnt concealed) its_score = SCORE__UNCONCEALED;
3364
3365 if (its_owner == actor) its_score = its_score + a_s;
3366 else
3367 if (its_owner == actors_location) its_score = its_score + l_s;
3368 else
3369 if (its_owner ~= compass) its_score = its_score + SCORE__NOTCOMPASS;
3370
3371 its_score = its_score + SCORE__CHOOSEOBJ * ChooseObjects(obj, 2);
3372
3373 if (obj hasnt scenery) its_score = its_score + SCORE__NOTSCENERY;
3374 if (obj ~= actor) its_score = its_score + SCORE__NOTACTOR;
3375
3376 ! A small bonus for having the correct GNA,
3377 ! for sorting out ambiguous articles and the like.
3378
3379 if (indef_cases & (PowersOfTwo_TB-->(GetGNAOfObject(obj))))
3380 its_score = its_score + SCORE__GNA;
3381
3382 match_scores-->i = match_scores-->i + its_score;
3383 #Ifdef DEBUG;
3384 if (parser_trace >= 4) print " ", (The) match_list-->i, " (", match_list-->i,
3385 ") in ", (the) its_owner, " : ", match_scores-->i, " points^";
3386 #Endif; ! DEBUG
3387 }
3388 }
3389
3390 for (i=0 : i<number_matched : i++) {
3391 while (match_list-->i == -1) {
3392 if (i == number_matched-1) { number_matched--; break; }
3393 for (j=i : j<number_matched : j++) {
3394 match_list-->j = match_list-->(j+1);
3395 match_scores-->j = match_scores-->(j+1);
3396 }
3397 number_matched--;
3398 }
3399 }
3400 ];
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.