Disambiguate a number

Have you tried extending the technique we discussed here for topics to numbers? Numbers are not objects after all.

asking for number extension
(understand $Words as $Action)
	(implicit action is $Implicit)
	(if) (implicit action wants number) (then)		%% added for number
		*(understand $Words as number $O)			%% coverage
	(if) (implicit action wants topic) (then)		%% added for topic
		*(understand $Words as topic $O)			%% coverage
	(elseif) (implicit action wants direction) (then)
		*(understand $Words as direction $O)
	(else)
		%% We don't know the correct policy, so fall back on 'non-all'.
		*(understand $Words as non-all object $O)
	(endif)
	(recover implicit action $Implicit $O into $Action)

%% added for number coverage
(interface (asking for number in $<Action))
(asking for number in $Action)
	(now) (implicit action is $Action)
	(now) (implicit action wants number)
	(now) ~(implicit action wants direction)
	(now) ~(implicit action wants topic)		%% added for topic coverage
	(tick) (stop)

%% added for topic coverage
(interface (asking for topic in $<Action))
(asking for topic in $Action)
	(now) (implicit action is $Action)
	(now) (implicit action wants topic)
	(now) ~(implicit action wants number)		%% added for number coverage
	(now) ~(implicit action wants direction)
	(tick) (stop)

(asking for object in $Action)
	(now) (implicit action is $Action)
	(now) ~(implicit action wants number)		%% added for number coverage
	(now) ~(implicit action wants direction)
	(now) ~(implicit action wants topic)		%% added for topic coverage
	(tick) (stop)

(asking for direction in $Action)
	(now) (implicit action is $Action)
	(now) (implicit action wants direction)
	(now) ~(implicit action wants number)		%% added for number coverage
	(now) ~(implicit action wants topic)		%% added for topic coverage
	(tick) (stop)

(try-complex $ComplexAction) (just)				%% added (just) for override
	(if) ~(action $ComplexAction preserves the question) (then)
		(now) ~(implicit action is $)
		(now) ~(implicit action wants number)	%% added for number coverage
		(now) ~(implicit action wants direction)
		(now) ~(implicit action wants topic)	%% added for topic coverage
	(endif)
	(if) ~(allowed action $ComplexAction) (then)
		(report disallowed action $ComplexAction)
		(tick) (stop)
	(elseif) ([] is one of $ComplexAction) (then)
		You're not aware of any such thing!
		(tick) (stop)
	(else)
		(strip decorations from $ComplexAction into $MultiAction)
		%% Now we have something like:
		%% [put [#marble1 #marble2 #marblefloor] #in #bowl]
		(if)
			*($Obj is one of $MultiAction)
			{
				(nonempty $Obj)
			(or)
				(object $Obj)
				~(direction $Obj)
				~(relation $Obj)
				~(room $Obj)
			}
		(then)
			(notice player's $Obj)
		(endif)
		(if) *($List is one of $MultiAction) (nonempty $List) (then)
			(exhaust) {
				*(regroup stripped action $MultiAction of
					$MultiAction into $Regrouped $Multi)
				%% Assuming the marbles are fungible, now we
				%% are backtracking over:
				%% [put [#marble1 #marble2] #in #bowl]
				%% [put #marblefloor #in #bowl]
				(if)
					~(empty $Multi)
				(then)
					%% If at least two multi-actions are
					%% implied, describe each step.
					(line)
					(if) (library links enabled) (then)
						(link) (The full $Multi)
					(else)
						(The full $Multi)
					(endif)
					:
				(endif)
				(try regrouped $Regrouped)
			}
		(else)
			%% Optimize the common case.
			(try regrouped $MultiAction)
		(endif)
	(endif)

And changing the query in your code from

(asking for object in [turn $Obj right to []])

to

(asking for number in [turn $Obj right to []])
1 Like