Secret scoring system with multiple separate scores

Hey All–

I have never messed with any type of scoring, but I want to keep several scores that will be hidden from the player. Like so:

Every time the player does something ridiculous, their Ridiculous Score is incremented.
Every time the player does something malicious, their Malicious Score is incremented.

And I want to do this for about 6 different scores. So:

RidiculousScore is a number that varies. RidiculousScore is initially 0.
MaliciousScore is a number that varies. MaliciousScore is initially 0.

Carry out chicken dancing:
	Say "You dance like a chicken.";
	increment RidiculousScore.

etc, etc.

Then I want to have different endings based on which score is the highest. I can’t get the syntax right for making all types of scores fit under one category, like “GameScore is a kind of value. RidiculousScore is a Gamescore.” With the idea being that at the end I can have “If MaliciousScore is greater than every other GameScore: MaliciousEnd.”

Or something like that. I can’t find a good example of something like this in the docs, and all my attempts to corral the various scores have failed.

Can someone point me to the right place in the docs? I don’t think I can keep all these separate scores with the built-in scoring system, and I’ve been searching for some time without finding a good example.

4 Likes

Probably easiest to do this as a table? Here’s a skeletal example that hopefully demonstrates how it could work (I’m sure there are lots of ways to improve it):

ScoreName is a kind of value.  The ScoreNames are Ridiculous, Malicious, Kindly, Selfish, Boring, and Abstruse.

Table of GameScores
ScoreName	score
Ridiculous	1
Malicious	3
Kindly	2
Selfish	7
Boring	5
Abstruse	99

Instead of jumping:
	Increment the score corresponding to a ScoreName of Ridiculous in the Table of GameScores.
	
Instead of looking, showme the contents of the Table of GameScores.

Instead of sleeping:
	Sort the Table of GameScores in reverse score order;
	Say "Your highest score was [ScoreName in row 1 of Table of GameScores]."
4 Likes

The Wizard says, “Your behavior is so difficult to classify that I’m just going to turn you into a rock so I don’t have to deal with you anymore.” His wand sizzles and… ZOT! You have become a rock. No more abstruse behavior from you.

** You have become an inanimate object. **

7 Likes

Inform really likes values to be attached to objects. So that’s what I’d do here.

A game score is a kind of object.
A game score has a number called the value.
Abstruseness is a game score.

After considering the narrative:
    increase the value of abstruseness by 5;
    continue the action.

Definition: a game score is high if its value is 5 or greater.
When play ends:
    let the winner be the highest game score;
    [...]

We don’t actually need “high” in and of itself—but defining it this way automatically defines “higher” and “highest” as well, and those are what we do want!

3 Likes

OK. What if 2 or more scores are equal at the end? I’d like to give the player one extra task in that case, and add another point to break the tie. I can’t even begin to think of how to phrase that.

Inform tells me that you can’t call it “value”, so you’ll need to find another name for it, but apart from that:

Definition: a frob is high if its result is 2 or more.
Definition: a frob is supreme if there are no frobs that are higher than it.

Now you can check “the number of supreme frobs” to detect a tie.

1 Like

well, carrying over context from your previous scoring question, does a tracking a single score per category replace the previous concept of tracking success or failure at each of a series of trials?

Is it always succeeding at an action (this is synonymous with reaching the carry out stage) per se that will increment a score, or might other things in the game do so?

Can a given action be both malicious and ridiculous, or will any given action have at most one score-category?

Will an action name alone be sufficient to determine its category, i.e., the action in the abstract independent of anything about what the noun or second noun or anything might be, e.g., jumping action, unlocking it with action, attacking action?

If not, how varied will the criteria be, and will there be lots per score category, or just 1, or just a small number, say 1-3 per?

WI 7.8: Rules applying to more than one action and WI 7.15: Kinds of Action describe two different ways to lump different actions together. The multiple-action case has an important restriction that if you specify an object in any of the actions, then all of the actions you’re lumping together must take one or two objects (and I’m not sure how the syntax works out if you specify two objects or if you can).

So one approach would be to say that a series of actions are a given kind of action (no relation to ‘kind’ as it’s used anywhere else in Inform):

[ "action" isn't part of the syntax; "ridiculous action" is an arbitrary label ]
chicken dancing is a ridiculous action. 

First after a ridiculous action:
  increment RidiculousScore;
  continue the action;

(last carry out might be more desirable to be really sure some other After rule didn’t sneak in and stop the action… but you can only define Before, Instead, or After rules for kinds of action because for each action name there’s an individual Check, Carry Out, and Report rulebook.)

But my exact approach would vary based on the answers to the questions I posed.

The other idea is on pause. This is separate.

Yes. Do certain things, and you will get a score for it, although you will not know that.

No. Certain scores are tied to certain actions. Maybe chicken dancing COULD be done maliciously, but you will only get a point in the ridiculous column.

Everywhere that I want a particular score to be implemented, I’ve checked the action with incrementing for only that score category. So just attacking something would not get you a point anywhere, but attacking the sleeping baby would earn you a malicious point.

I have it all coded to points for various actions exactly where I want them-- I just need it to cohere into a score at the end so I can attach endings to them and have them fire.

Well, after some tweaking, that appears to work just fine. Thanks!

I’m going to mess around with the other suggestions, too, but since I optimistically coded nearly an entire game based off “increment XScore”, this idea was easy to plug into the existing code. I do need to run some tests on it to make sure it’s actually working all the time.

1 Like

OK, still no idea how to check for a tie. Ideally, after sorting the Table so that the highest score is in row 1, I could do something like

if the score corresponding to row 1 in the Table of GameScores is higher than the score corresponding to row 2 in the table of GameScores:
	game keeps going;
otherwise:
	Do something to break the tie, then game keeps going.

But I can’t find a single example of language like this-- or any examples that compare numbers in a table at all-- in chapter 16.

I think this is the syntax:

	If the score in row 1 of Table of GameScores is the score in row 2 of Table of GameScores:
		Say "Tie!";
	Otherwise:
		Say "Winner!";

(“Corresponding to” is I think what you use when you’re doing pattern matching – like, the score corresponding to Ridiculous or whatever; since you’re manually telling Inform which row to look at by number here, though, that doesn’t apply).

1 Like

Aaannd another followup question:

How to increment the score of a particular row when you don’t know what the name of that row is? The player does the tie-breaking thing, and then if I want to increment the score in row 1, how to phrase that? About 15 variations on

increment the score in row 1 in the Table of GameChoices

haven’t worked.

1 Like

Try:

Increment the score in row 1 of Table of GameScores;

Gotta love natural language programming in Inform!

1 Like

Splutter. Incrementing when corresponding uses “in”? And this uses “of”? Right-o. Okeydoke.

OK, I’m going to muck around with all this and see if it actually all works. Thanks AGAIN.

Yep, it’s “corresponding to a [column] of [value] in”, and “row [number] of”. Gotta love it.

I think they just didn’t want to say “of” twice in the first one.

1 Like

Actually, there’s a totally logical, intuitive explanation for the difference in syntax that makes the right phrasing easy to remember! All you have to do is –

LOOK! Behind you! A three-headed monkey!

[flees]

1 Like

An improvement waiting for you in 10.1 is that one can now reliably use either ‘in’ or ‘from’ before table names or lists and it’ll work. The places that already allowed ‘of’ still allow ‘of’ but ‘of’ wasn’t added to any phrases.

(I suggested this and submitted the patch – there was little to it. Yay, open source.)

3 Likes