Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

I7: [at random then nothing]

0 views
Skip to first unread message

jeremy...@gmail.com

unread,
Dec 29, 2009, 12:09:41 AM12/29/09
to
I am working on a complicated bit of text construction. Part of it
involves filling a bit of indexed text using a series of if statements
where, if the text is unfilled one way, it later gets filled another
way. So I'm use a number of lines like - now the marmot text is "[one
of]A[or]B[or][stopping]" - meaning that after the second time this
line is executed, the marmot text remains blank (and then will get
filled in subsequently).

What I would really like to be able to do in a few places is to have
it be random whether A or B is the first printed string. In other
words, something like - now the marmot text "[one of]A[or]B[or]C[at
random then nothing], where after A and B and C are selected in some
random order, it's just "" after that. I can't figure out a way to do
this that isn't enormously kludgy.

Any thoughts?

--Jeremy

Victor Gijsbers

unread,
Dec 29, 2009, 4:08:26 AM12/29/09
to
jeremy...@gmail.com wrote:

> What I would really like to be able to do in a few places is to have
> it be random whether A or B is the first printed string. In other
> words, something like - now the marmot text "[one of]A[or]B[or]C[at
> random then nothing], where after A and B and C are selected in some
> random order, it's just "" after that. I can't figure out a way to do
> this that isn't enormously kludgy.

Does this do what you want?

... say "[one of][bla][or][bla][or][bla][or][stopping]".


To say bla:
say "[one of]neus[or]oor[or]voet[in random order]".


You'd have to create a say-phrase for every such substitution, but that
shouldn't be _too_ much work.


Kind regards,
Victor

Andrew Plotkin

unread,
Dec 29, 2009, 11:33:50 AM12/29/09
to

"[one of]" tags (unlike "[if]" tags) can be nested. So there's nothing
wrong with this:

say "[one of][one of]A[or]B[at random][or][stopping]."

But I assume that's the kludgy way Jeremy was thinking of.

--Z

--
"And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
*

Victor Gijsbers

unread,
Dec 29, 2009, 2:21:31 PM12/29/09
to

But that doesn't do what Jeremy wants, since it will say only A or B,
and not both of them, before stopping.

Regards,
Victor

Lorne

unread,
Dec 30, 2009, 3:40:04 PM12/30/09
to
On 29 Dec, 06:09, "jeremyfre...@gmail.com" <jeremyfre...@gmail.com>
wrote:


If you use this a lot you could make a new ending to the "one of"
phrase (this example is just the "in random order" token modified to
stop after the first permutation - there's probably a better way to do
it!)


The Place is a room.
Instead of waiting, say "You wait[one of] patiently[or] for a while
[or]. Boring[at random then nothing]."

To say at random then nothing -- ending say_one_of with marker
I7_SOO_SHU2: (- {-close-brace} -).

Include (-
[ I7_SOO_SHU2 oldval count sd ct v i j s ssd scope cc base;
base = count+1;
v = oldval%base; oldval = oldval/base; ct = oldval%base; sd = oldval/
base;
if (count > 32) return I7_SOO_PAR(oldval, count);
if (v && ct==0) return -1;
if (count <= 1) v = count;
else {
cc = base*base;
scope = MAX_POSITIVE_NUMBER/cc - cc - base;
if (scope%2==0) scope--;
if (scope<0) scope = -scope;
if (sd == 0) { sd = random(scope); ct=0; }
for (i=0:i<count:i++) I7_SOO_SHUF->i = i;
ssd = sd;
for (i=0:i<count-1:i++) {
j = (sd)%(count-i)+i; sd = (sd*31973)+17; if (sd<0) sd=-sd;
s = I7_SOO_SHUF->j; I7_SOO_SHUF->j = I7_SOO_SHUF->i; I7_SOO_SHUF->i
= s;
}
v = (I7_SOO_SHUF->ct)+1;
ct++; if (ct >= count) { ct = 0; ssd = 0; }
}
return v + ct*base + ssd*base*base;
];
-).

Test me with "z/z/z/z".

0 new messages