When is a pushing action a switching on action and vice versa

Hello again (Gosh, I hope you don’t kick me out of the club),

I am awarding points using a table keyed on current action and returning the point value to award.

In my example, I “Understand push/flip/toggle as pushing” and then capture pushing with a “instead of pushing a switched off switch, try switching on the noun”.

My expectation is that push/flip/toggle would execute the action as a switching on action and award the points. i.e. push is the same as witch on.

In my example, if you “push switch1”, the current action is “pushing switch1”. It then goes ahead with the try and the action becomes “switching on switch1” and it is my expectation that the actual executed action of “Switch on switch1” would award points. but it doesn’t,

“push switch1” awards points but “switch on switch1” doesn’t. similarly, “switch on switch2” awards points but “push switch2” does not.

How can i make the two equal actions for the purpose of awarding points? Otherwise, It will award points for one but not the other.

Thanks in advance,
d.

use scoring.
the maximum score is 15.

The lab is a room.

A switch is a kind of device. A switch can be switched on or switched off. A switch is usually switched off.
Switch1 is a switch in the lab. The description is "this is switch1.".
Switch2 is a switch in the lab. The description is "this is switch2.".
understand "toggle [a switch]" as pushing.
understand "flip [a switch]" as pushing.

Instead of pushing a switched off switch (this is the redirect push to switch on rule):
	try switching on the noun.

Instead of pushing a switched on switch (this is the redirect push to switch off rule):
	try switching off the noun.
	
every turn:
	repeat through Table of Valuable Actions:
		if the current action is the relevant action entry:
			increase the score by the point value entry;
			continue the action.
	
Table of Valuable Actions
relevant action	point value
pushing switch1	5
switching on switch2	10

test me with "actions / switch on switch1 / switch off switch1 / push switch1 / push switch2 / push switch2 / switch on switch2"
2 Likes

Looking things up just now, I see that in 12.20 of the manual, is kind of advising not to refer to the current action in every turn rules :slight_smile: (under the phrase ‘The other way to produce a useful action is:’)

That said, doing so doesn’t make the game crash or anything.

I haven’t thought deeply before about when ‘the current action’ actually becomes another action during a turn, if it can. But the problem for your demo is that those two instead rules don’t actually change what ‘the current action’ is. In their case, the current action value remains something like ‘pushing (blah)’ even though the game’s now trying the switching action. Then the test of the current action value at the every turn stage for ‘switching on (blah)’, for instance, can’t match.

You can see this yourself by adding a line to the beginning of your existing every turn rule that says aloud what the current action is at that moment, then running your ‘test me’. e.g.

every turn:
	say "The current action is: [the current action].";

In the ‘Bosch’ example in the manual (same page already pointed to), it uses the table approach you’re using in general but uses the phrasing ‘After doing something’ instead of an every turn rule. That said, making that change alone to your demo changes nothing about the outcomes. I tested it.

I don’t know how to make the current action value change mid-turn in a way that can be tested successfully as the new value while it’s still relevant. It might be easy and I just don’t know, but someone else will have to chime in on this.

I came up with my own approach to the problem which creates a ‘score’ phrase you use whenever you want to award points, and a table you populate with point values and names of achievements. I see various similar tables demonstrated in the tables part of the manual (e.g. 16.14 Another scoring example). Try those, or mine, and find a way you like. Here’s my version just showing that the switch 1 achievement only fires once, though we keep fiddling with the switch, and with multiple verbs, too:

Summary
use scoring.
the maximum score is 15.

The lab is a room.

A switch is a kind of device. A switch can be switched on or switched off. A switch is usually switched off.
Switch1 is a switch in the lab. The description is "this is switch1.".
Switch2 is a switch in the lab. The description is "this is switch2.".
understand "toggle [a switch]" as pushing.
understand "flip [a switch]" as pushing.

Instead of pushing a switched off switch (this is the redirect push to switch on rule):
	try switching on the noun.

Instead of pushing a switched on switch (this is the redirect push to switch off rule):
	try switching off the noun.
	
Carry out switching on switch1:
	score "switch 1 activated";

To score (T - text):
	if T is an achievement listed in the Table of Worthy Achievements:
		increase score by point value entry;
		blank out the whole row;[stops this achievement being awarded more than once]
	
Table of Worthy Achievements
achievement	point value
"switch 1 activated"	5

test me with "push switch2/toggle switch1/switch off switch1/flip switch1".

-Wade

I just tried this and it seemed to give the correct behaviour. Interacting with switch 1 never gives any points (because the valuable action is pushing the switch, which is replaced with switching on by the ‘instead’ rule); switching on switch 2 gives 10 points whether you use the verb PUSH or SWITCH ON.

TEST ME ends up with a total score of 15 points with the original code, 20 if you replace ‘every turn’ with ‘after doing something’.

The gotcha you need to be aware of with ‘after doing something’: it will only score actions which succeed. Anything you handle with an Instead rule will never be able to score points this way.

Hm, maybe I forgot to recompile after pasting.

Yeah. I suppose it’s for reasons like this my inclination towards the whole problem is not to test for specific actions succeeding. As the current action value has shown, they’re too, uh, specific.

I like to let all the actions flow to a single most relevant action (in this case, actually switching on switch 1) and apply the score increase there, not worrying about how that action was ultimately reached.

-Wade

The current action is not reliable during every turn rules processing (something that zarf pointed out to me). This is because it is possible for multiple actions to be processed in the same “game cycle,” i.e. between command prompts, but the action processing rules happen at a different point than the every turn rules. Both happen within the context of the turn sequence rules (see the “The top level” part of the Rules/Standards screen in the Index).

You should be aware of the >ACTIONS debugging command, which will show you which actions are being processed and in which order, as well as whether those actions are considered to have succeeded or failed. With that output enabled, you should see that the sequence of events is:

  1. begin processing pushing switch1
  2. begin processing switching on switch1
  3. finish processing switching on switch1, ending in success
  4. finish processing pushing switch1, ending in failure

The current action will be whatever is the last action when action processing is exited, e.g. pushing switch1 in this case.

A separate action processing cycle is started for each action. As jwalrus notes, the after rules are part of action processing and will be reached for each action considered a success.

By far the more reliable approach is to examine the world state with an every turn rule, e.g.

Every turn when switch1 is switched on:

With this approach, it doesn’t matter what action resulted in the world state that yields a score.

The difficulty with this approach in your case is that it’s not possible to put conditions in tables. However, you have two options:

  • You can put a rule in the table which succeeds if points should be awarded and fails if they should not, and every turn test each rule to decide whether to award points.
  • You can sneakily insert your condition into a text, as recently demonstrated by Draconis, and every turn test each rule to decide whether to award points.

The second option is less hassle. Here’s an example:

A switch is a kind of device. Understand "switch" as a switch.

Instead of pushing a switched on switch (called toggle):
	try switching off toggle.

Instead of pushing a switched off switch (called toggle):
	try switching on toggle.


switch1 is a switch in Place. "A large switch is here, currently switched [if switched on]on[otherwise]off[end if]."

Use scoring.

[Add as many rows as you like to this table.]
Table of Scored Circumstances
criteria	award	flag
"[if switch1 is switched on]Y[otherwise]N[end if]"	10	false

Every turn (this is the award points rule):
	repeat through Table of Scored Circumstances:
		unless the flag entry is true:
			if the criteria entry is "Y":
				increase the score by award entry;
				now flag entry is true.
2 Likes

I love the solution of including a sneaky condition in the table. It is working for me and simplifies some trouble I was having with scoring in general (work arounds for when i couldn’t get the proper action coded.

thank you!

If you want a list of conditions that are checked at the end of every turn and possibly cause consequences, that’s exactly what scenes are.

2 Likes

The root question seemed to be about how to handle scoring, preferably in a way that is organized in a table.

Are you suggesting something along the lines of…?

Switch Points Awarded is a scene. Switch Points Awarded begins when switch1 is switched on.

When Switch Points Awarded begins: increase the score by 10.
1 Like

Yeah, that’s what I meant.

I’m not saying it’s the tidiest way to do it. But the table-and-conditions approach mentioned above is essentially reinventing scenes.

1 Like

i’ve used scenes to provide a passive “scene” for the player. but I don’t understand how this works. would the scene last for the entire game?

or would there be a scene be for each set of points awarded.

or would there be a scene that starts when one condition is true and then the next scene begins when those first points are awarded?

Sorry to be obtuse.

You can have any number of scenes going at a time. So you can have one for each scoring event, structured exactly as Zarf suggested, and they won’t affect anything else or do anything other than award points.

1 Like

(reading both this and the other thread)

If you like the Bosch example and wish to preserve it (I think that’s how these two conversations started), you can create some actions that are only used for updating the score table. For instance:

activating the odd device is an action applying to nothing. [this is a unique action that can be used to update the score]

instead of pushing switch1:
	try switching on switch1;
	try activating the odd device;

In that case, the “relevant action” entry in the Table of Valuable Actions would be “activating the odd device”.

A revision of your example:

use scoring.
the maximum score is 15.

The lab is a room.

A switch is a kind of device. A switch can be switched on or switched off. A switch is usually switched off.
Switch1 is a switch in the lab. The description is "this is switch1.".
Switch2 is a switch in the lab. The description is "this is switch2.".
understand "toggle [a switch]" as pushing.
understand "flip [a switch]" as pushing.

activating the odd device is an action applying to nothing. [this is a unique action that can be used to update the score]

instead of pushing switch1:
	try switching on switch1;
	try activating the odd device;
	
activating the curious contraption is an action applying to nothing. [this is a unique action that can be used to update the score]
	
instead of pushing switch2:
	try switching on switch2;
	try activating the curious contraption;

After doing something:
	repeat through Table of Valuable Actions:
		if the current action is the relevant action entry and turn stamp entry is less than 0:
			now the turn stamp entry is the turn count;
			increase the score by the point value entry;
	continue the action.

	
Table of Valuable Actions
relevant action	turn stamp	point value
activating the odd device	-1	5
activating the curious contraption	-1	10

test me with "actions / push switch1 / push switch2 /"
2 Likes

That’s what I was thinking too - I know you can group actions as a “kind of action”.

Kissing Mr Carr is unmaidenly behaviour.
Doing something to the painting is unmaidenly behaviour.

Instead of unmaidenly behaviour in the Inn, say “How unmaidenly!”

Then trigger the scoring based on the kind of behavior instead of an individual action? (Me just spitballing, that may not actually work.)

1 Like