Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Random Number / Game Issue

Borat Kungler
Registered User
Join date: 13 Apr 2007
Posts: 33
04-16-2008 11:21
OK this is driving me nuts so I hope it makes sense! I am helping somebody develop a game and while the actual scripting isn't a problem the mathematical logic is because it just confuses me... here is the problem...

I have a 5x5 grid with numbers from 1 - 80 generated randomly. Not a problem.

Now this is where it gets me... when I generate random numbers to 'match' the numbers in the grid I was originally just generating random numbers in the same way but quickly realised that the chances of getting enough numbers to match the top grid to win a game in one way or another was extremely slim, I think the most I have had so far is 3 numbers.

So I guess my question is how do the other games do it? I mean you HAVE to be able to win a game so is there something going on inside the games to ensure the numbers generated are within range of the numbers on the grid? Does that make any sense at all?!!

Any help will be really appreciated!
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
04-16-2008 11:41
What do you mean by "match"? Are you trying to get the the same set of numbers, but in a different sequence/layout on the grid (so it's like a memory/tile matching game)? If that's what you want, you could:

* Generate a set of 25 random numbers in your range (you've already figured this out)
* Put those numbers in a list
* Call llListRandomize (or whatever it's called) to generate a new sequence of those same numbers

If that's not what you're looking for, maybe you should explain the point of the game a little more, and explain what exactly you mean by 'matching' two sets of random numbers.
Borat Kungler
Registered User
Join date: 13 Apr 2007
Posts: 33
04-16-2008 11:47
Thanks for your reply Ziggy, let me explain it a little better, its kind of the same way Zyngo does it although it is not **another** one of the 1 million zyngo clones that are all over the place.

So the new numbers that are being generated are random numbers each round etc etc, so when I say match i meant if there is a 2 in the grid and one of the numbers generated one round was a 2 then bingo you have a match.
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
04-16-2008 12:53
You have 25 numbers randomly selected from the numbers 1 though 80 ...and you want just those 25 numbers to go 'forwards' to be selected in a new and random order?

So, take the 25 selected numbers, put them in a list and, as Ziggy suggested, llListRandomize ...then pick them off in the order they randomly sit in the list. Every one will be a 'match'.

What are we missing? :p
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
04-16-2008 13:05
Um... I don't get out much, so I have no idea what Zyngo is :) But it *sounds* like you're trying to generate the same set of numbers, in a different sequence? Or you want *some* overlap between the numbers, but not full overlap?
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
04-16-2008 14:50
CODE
list numbers;
list twenty_five;

default{
state_entry(){
integer a = 1;
while(a < 81){
numbers += a;
a++;
}
numbers = llListRandomize(numbers, 1);
twenty_five = llList2List(numbers, 0, 24);
}
touch_start(integer total_number){
twenty_five = llListRandomize(twenty_five, 1);
llOwnerSay((string)llList2List(twenty_five, 0, 0));
}
}

This would give you your list of 80 numbers. When touched, it is going to randomize that list and then return the 1st 25 numbers to another list. Everytime you touch it, it is going to randomize just that same list of 25 numbers and return 1 number from it. If you reset the script, then it would now be a different list of 25 numbers.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum