ScoreMatchL (lines 2592-2680)
Back to List
Browsing parserm.h
2592 ! ScoreMatchL scores the match list for quality in terms of what the
2593 ! player has vaguely asked for. Points are awarded for conforming with
2594 ! requirements like "my", and so on. Remove from the match list any
2595 ! entries which fail the basic requirements of the descriptors.
2596 ! ----------------------------------------------------------------------------
2597
2598 [ ScoreMatchL context its_owner its_score obj i j threshold met a_s l_s;
2599
2600 ! if (indef_type & OTHER_BIT ~= 0) threshold++;
2601 if (indef_type & MY_BIT ~= 0) threshold++;
2602 if (indef_type & THAT_BIT ~= 0) threshold++;
2603 if (indef_type & LIT_BIT ~= 0) threshold++;
2604 if (indef_type & UNLIT_BIT ~= 0) threshold++;
2605 if (indef_owner ~= nothing) threshold++;
2606
2607 #ifdef DEBUG;
2608 if (parser_trace>=4) print " Scoring match list: indef mode ", indef_mode,
2609 " type ", indef_type,
2610 ", satisfying ", threshold, " requirements:^";
2611 #endif;
2612
2613 a_s = SCORE__NEXTBESTLOC; l_s = SCORE__BESTLOC;
2614 if (context == HELD_TOKEN or MULTIHELD_TOKEN or MULTIEXCEPT_TOKEN) {
2615 a_s = SCORE__BESTLOC; l_s = SCORE__NEXTBESTLOC;
2616 }
2617
2618 for (i=0: i<number_matched: i++) {
2619 obj = match_list-->i; its_owner = parent(obj); its_score=0;
2620
2621 ! if (indef_type & OTHER_BIT ~=0
2622 ! && obj~=itobj or himobj or herobj) met++;
2623 if (indef_type & MY_BIT ~=0 && its_owner==actor) met++;
2624 if (indef_type & THAT_BIT ~=0 && its_owner==actors_location) met++;
2625 if (indef_type & LIT_BIT ~=0 && obj has light) met++;
2626 if (indef_type & UNLIT_BIT ~=0 && obj hasnt light) met++;
2627 if (indef_owner~=0 && its_owner == indef_owner) met++;
2628
2629 if (met < threshold)
2630 {
2631 #ifdef DEBUG;
2632 if (parser_trace >= 4)
2633 print " ", (The) match_list-->i,
2634 " (", match_list-->i, ") in ", (the) its_owner,
2635 " is rejected (doesn't match descriptors)^";
2636 #endif;
2637 match_list-->i=-1;
2638 }
2639 else
2640 { its_score = 0;
2641 if (obj hasnt concealed) its_score = SCORE__UNCONCEALED;
2642
2643 if (its_owner==actor) its_score = its_score + a_s;
2644 else
2645 if (its_owner==actors_location) its_score = its_score + l_s;
2646 else
2647 if (its_owner~=compass) its_score = its_score + SCORE__NOTCOMPASS;
2648
2649 its_score = its_score + SCORE__CHOOSEOBJ * ChooseObjects(obj, 2);
2650
2651 if (obj hasnt scenery) its_score = its_score + SCORE__NOTSCENERY;
2652 if (obj ~= actor) its_score = its_score + SCORE__NOTACTOR;
2653
2654 ! A small bonus for having the correct GNA,
2655 ! for sorting out ambiguous articles and the like.
2656
2657 if (indef_cases & (PowersOfTwo_TB-->(GetGNAOfObject(obj))))
2658 its_score = its_score + SCORE__GNA;
2659
2660 match_scores-->i = match_scores-->i + its_score;
2661 #ifdef DEBUG;
2662 if (parser_trace >= 4)
2663 print " ", (The) match_list-->i,
2664 " (", match_list-->i, ") in ", (the) its_owner,
2665 " : ", match_scores-->i, " points^";
2666 #endif;
2667 }
2668 }
2669
2670 for (i=0:i<number_matched:i++)
2671 { while (match_list-->i == -1)
2672 { if (i == number_matched-1) { number_matched--; break; }
2673 for (j=i:j<number_matched:j++)
2674 { match_list-->j = match_list-->(j+1);
2675 match_scores-->j = match_scores-->(j+1);
2676 }
2677 number_matched--;
2678 }
2679 }
2680 ];
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.