Secret scoring system with multiple separate scores

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. **

8 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

Necro-ing my own thread! Yes, still messing with this. Finally got my game idea on track.

Another question about breaking a tie in a situation where I have 6 scores. For instance: Number of Murders Committed, Puppies Adopted, Old Ladies Mugged, Volunteer Hours, Butterflies Smashed, and Charitable Dollars Donated.

Let’s say that the tie for high score is between Number of Murders and Number of Volunteer Hours, and I want to give the player a chance to do another murder or volunteer more hours to break the tie. So I want something like:

To endgame:
	sort the table of EthicsScores in reverse score order;
	If the score in row 1 of Table of EthicsScores is the score in row 2 of Table of EthicsScores:
		if the scorename of row 1 of the Table of EthicsScores corresponds to a scorename of Murders Committed :
			if the scorename of row 2 of the Table of EthicsScores corresponds to a scorename of Hours Volunteered:
				say "Kill someone or volunteer?";
			etc;

.
But the syntax there (the corresponds part) is incorrect. How can I write this correctly? Obviously I want to give the player a choice between only the scores that are tied, so I need to be able to give choices based on only those 2 things.

** Edit: Accidentally quoted Mike at first. Don’t know why that happened. Sorry for tagging you without cause, Mike!

1 Like

I in fact was a little confused by this, thanks for the clarifying update!

I’m weaker on tables than I really should be, so I’m not immediately remembering the proper syntax, but it does seem to me that hand-writing each possible combination is a lot of annoying grunt-work. Could you just add a column to the table with what you want to come up in case of a tie, and then have the say line be something like “[tiephrase of row 1 in sentence case] or [tiephrase of row 2]?” Might be simpler all told, especially if a three-way tie is possible…

1 Like

I mean, I have to write each one out no matter where they’re organized, and it’s hard for me to think in Tables. For some reason, I can read nested ifs much more easily.

I looked up “in sentence case” because I had no idea what it means, and now I do. But I’m extra-unsure of how any of this would work in a table when I have to call out 2 specific scores.

This is possible, but it sounds like a major headache. I don’t believe I’ll ever show the player their score-- just the ending their score gives them (eg: “You’ve committed so many murders that you finally left DNA at a scene and are arrested” or “You are honored as Volunteer of the year”), so it seems OK to cheat by just picking the top 2 rows and breaking that tie.

** Oh, and the accidental tag was because I copied some code you wrote earlier and that got selected for a reply, too. I did wonder why a reply box opened all by itself.

1 Like

I think the idea is to look up each part of the call-out separately? So the “tiephrase” of Murders Committed would be “kill someone” and the tiephrase of Hours Volunteered would be “volunteer” and then you can just stick “or” in the middle?

But that breaks down if you want a truly custom phrase for each pair of scores.

2 Likes