Thanks to all of you for the replies.
Tragically, I’ve been unexpectedly in an area of dodgy-to-nonexistent wifi all day and am only seeing some of this now. I did wind up with a half-baked solution of my own, and now I’m rethinking what I came up with based on this thread.
Re: efficient to type vs. efficient computationally: while I’d certainly favor a computationally efficient solution if there’s a clear path to one, mainly I was looking for the former (and wanting to be entirely sure I hadn’t missed a built-in provision for this kind of problem.)
After reflecting on the problem for a bit, I based my attempt below on the premise that I might want to actually store and reuse the specific odds of various things happening, tweaking them here and there as various conditions in the game world changed. (It’s also based on the fact that I couldn’t figure out kind-variables whatsoever from the documentation, although I was very interested in coming up with something that world work with any type of value, like Matt W.'s code above does. When I’m more awake I’m going take another pass at puzzling that out since now I’ve got a working example to look at.)
Anyway, keeping in mind that this is very possibly entirely stupid, I basically set up tables that looked like this:
Table 1
Color Odds Index
Red 60 1
Blue 30 2
Green 10 3
And then I wrote a chunk of code to pull odds from tables and pick a thing:
[code]Choice is a number that varies.
oddsend is a number that varies.
To pick from (T - a table name):
Sort T in reverse odds order;
now oddsend is 0;
now choice is a random number between 1 and 100;
repeat through T:
now oddsend is oddsend + odds entry;
if choice <= oddsend:
now choice is Index entry;
stop the action.
[/code]
…and then I went with this ugly chunk of code for messing with the odds given in the table:
To boost odds of (C - a color) by (N - a number):
now x is 0;
repeat through table 1:
if Odds entry > 0:
now x is x + 1;
now x is x - 1;
now x is N divided by x;
repeat through table 1:
if Odds entry > 0:
if Color entry is not C:
now Odds entry is Odds entry - x;
choose row with a Color of C in table 1;
now Odds entry is Odds entry + N
The last bit obviously would need to be repeated for each sort of value I’m randomizing – I thought of saying "To boost odds of (C - a sayable value) but was stumped beyond that. I also didn’t quite get around to the part that would put the boosted odds back into the table, but that’s straightforward, and I still need to look up how you get around Inform’s desire to round when dividing numbers – but in practice I can actually afford be be off by a point or two, I think.
…now I feel slightly foolish for having asked a question about efficiency and then turned up again with something that’s a bit bashed together. Regardless, I appreciate the input. If someone could point me in the direction of an explanation of kind-variables, I’ll probably continue to tinker with something like the above so that changing probabilities can be stored and reused. (My fallback plan is take Matt W’s code from above as-is and run for the border).