DTPM with nouns reversed

Some simple code testing consulting/looking up:

Lab is a room. 

The player carries the dictionary. Understand "book" as dictionary.

The Encyclopedia of Secrets is in the Lab. Understand "book" as Encyclopedia of Secrets.

Instead of consulting the Encyclopedia of Secrets about "bill":
	say "Bill is the master of the universe!";
	
Does the player mean consulting the Encyclopedia of Secrets about something:
	It is very likely.

You’ll notice the two synonymous commands act differently:

>consult book about bill
(the Encyclopedia of Secrets about)
Bill is the master of the universe!

>look up bill in book
(the dictionary)
You discover nothing of interest in the dictionary

Why is this? Is there a way to get around this? It would really be nice to have the two phrasings parse the same.

1 Like

Also, look bill up in book.

1 Like

Try doing the DTPM rule like this.

Does the player mean:
if the current action is consulting begin;
if the noun is The Encyclopedia of Secrets, it is very likely;
if the second noun is The Encyclopedia of Secrets, it is very likely;
end if.

Seems that is doesn’t play nicely with topics. However, as it’s just a rule like the ones you get in the standard rulebooks, you can just put the conditions in if statements instead.

Hope this helps.

Weird. It works, but such a solution won’t work in all cases, such as when the types of the nouns are identical, but the preferred values not symmetrical.

The format is quite adjustable so you could also do this.

Does the player mean:
if the current action is consulting begin;
if the noun is The Encyclopedia of Secrets or the second noun is The Encyclopedia of Secrets, it is very likely;
end if.

or maybe something a little more complex for particular cases.

Hope his helps.

I have good news (for you) and bad news (maybe).

The bug you’re seeing is in routine ScoreDABCombo(). The logic that it uses to decide how to assign its arguments to noun and second looks at action_reversed but does not take into account the corresponding inpN values.

The good news is that this fix corrects your problem and should be safe in general (but has not been tested to prove that out).

[ ScoreDabCombo a b  result;
	@push action; @push act_requester; @push noun; @push second;
	action = action_to_be;
	act_requester = player;	! <--- ???
	if (action_reversed && inp1 == 0 && inp2 == 0) { noun = b; second = a; } ! MODIFIED 
	else { noun = a; second = b; }
	result = CheckDPMR();
	@pull second; @pull noun; @pull act_requester; @pull action;
	#ifdef COBJ_DEBUG;
	print "[", (the) a, " / ", (the) b, " => ", result, "]^";
	#endif;
	return result;
];

The bad news is that I happened across an even bigger headscratcher while tracing the issue. Here’s related routine CheckDPMR(), with one line (commented out) added:

[ CheckDPMR result sinp1 sinp2 rv;
	sinp1 = inp1; sinp2 = inp2; inp1 = noun; inp2 = second;
	rv = FollowRulebook( (+does the player mean rules+) );
	inp1 = sinp1; inp2 = sinp2;
	!print (name) noun; ! <-- BOTH TEST COMMANDS IF THIS LINE UNCOMMENTED
	if ((rv) && RulebookSucceeded()) {
		result = ResultOfRule();
		if (result == (+ it is very likely outcome +) ) return 4;
		if (result == (+ it is likely outcome +) ) return 3;
		if (result == (+ it is possible outcome +) ) return 2;
		if (result == (+ it is unlikely outcome +) ) return 1;
		if (result == (+ it is very unlikely outcome +) ) return 0;
	}
	return 2;
];

For reasons that I don’t understand, uncommenting that line will cause both of your test commands to choose the dictionary, even when the fix is in place. I would dearly like to understand why that is. (@Zed? @drpeterbatesuk? @Draconis?) Note that it does not have to be (name) noun that is printed – the same happens for (name) player.

EDIT: Oh, wait – I get it. The printing the name activity is wiping out the rulebook result checked later.

3 Likes

Nicely done! However it doesn’t quite work in all cases.

"Test"

Include (-

[ ScoreDabCombo a b  result;
	@push action; @push act_requester; @push noun; @push second;
	action = action_to_be;
	act_requester = player;	! <--- ???
	print "^";
	print (name) parser_results-->INP1_PRES,"^";
	print (name) parser_results-->INP2_PRES,"^";
	print (name) inp1,"^";
	print (name) inp2,"^";
	print (name) a,"^";
	print (name) b,"^";
	if (action_reversed && inp1 == 0 && inp2 == 0) { noun = b; second = a; } ! MODIFIED
	else { noun = a; second = b; }
	result = CheckDPMR();
	@pull second; @pull noun; @pull act_requester; @pull action;
	!#ifdef COBJ_DEBUG;
	print "[", (the) a, " / ", (the) b, " => ", result, "]^";
	!#endif;
	return result;
];

-) replacing "ScoreDabCombo".

Chucking it to is an action applying to two things. Understand "Chuck [something] to [someone]" as chucking it to. Understand "Chuck [someone] [something]" as chucking it to (with nouns reversed).

Report chucking it to: say "Here!".

Lab is a room.

The player carries the dictionary. Understand "book" as dictionary. Bill is a person in the lab.

The Encyclopedia of Secrets is in the Lab. Understand "book" as Encyclopedia of Secrets.

Instead of consulting the Encyclopedia of Secrets about "bill": say "Bill is the master of the universe!";
	
Does the player mean consulting the Encyclopedia of Secrets about a topic: It is very likely.
	
Does the player mean chucking the Encyclopedia of Secrets to someone: It is very likely.

Test me with "trace 0 / chuck book to bill / chuck bill book / consult book about bill / look up bill in book / trace 0".

The DTPM fails on the second “chuck” command. Also, I noticed that “inp1” and “inp2” are technically undefined a parser level as they are properly assigned in “GENERATE_ACTION_R”. The current values at this point are actually left over from the last command! (Took me ages to figure that one out!)

Aside: “inp1” and “inp2” are 0 when they represent a multiple object and 1 when they represent a non object value (ie. number, topic etc).

I believe this should work in all cases.

"Test"

Include (-

[ ScoreDabCombo a b  result;
	@push action; @push act_requester; @push noun; @push second;
	action = action_to_be;
	act_requester = player;
	if (action_reversed && a > 0 && b > 0) { noun = b; second = a; } ! A is not nothing and B is not nothing.
	else { noun = a; second = b; }
	result = CheckDPMR();
	@pull second; @pull noun; @pull act_requester; @pull action;
	#ifdef COBJ_DEBUG;
	print "[", (the) a, " / ", (the) b, " => ", result, "]^";
	#endif;
	return result;
];

-) replacing "ScoreDabCombo".

Chucking it to is an action applying to two things. Understand "Chuck [something] to [someone]" as chucking it to. Understand "Chuck [someone] [something]" as chucking it to (with nouns reversed).

Report chucking it to: say "Here!".

Lab is a room.

The player carries the dictionary. Understand "book" as dictionary. Bill is a person in the lab.

The Encyclopedia of Secrets is in the Lab. Understand "book" as Encyclopedia of Secrets.

Instead of consulting the Encyclopedia of Secrets about "bill": say "Bill is the master of the universe!";
	
Does the player mean consulting the Encyclopedia of Secrets about a topic: It is very likely.
	
Does the player mean chucking the Encyclopedia of Secrets to someone: It is very likely.

Test me with "trace 0 / chuck book to bill / chuck bill book / consult book about bill / look up bill in book / trace 0".

Checking that a and b are not zero should suffice to make sure that they’re both objects.

Hope this helps.

3 Likes

Touché! (@rileypb: Looks like you should give the solution back to climbingstars.)

1 Like

Honestly, I only really wanted to understand your solution and how inp1 and inp2 came into play. I’d say it was a joint effort! :slight_smile:

Incidentally, that “act_requester = player” line kinda looks like bug fix, so that DTPM rules can be used for “try (NPC) doing something” actions (the only time when act_requester is not the player).