Hello, thanks for visiting GameML, if you are a Game Maker user, this is the site for you, please sign up, or login if you are already a member, or just browse the site! Welcome to GameML!

ATTENTION MEMBERS!!! USERS CAN NOW SIGN UP AGAIN!
Log in

I forgot my password

Search
 
 

Display results as :
 


Rechercher Advanced Search

Site Hits
Free hit counter
These stats started at 0 on July 7th 2009
GameML File Sharing
USERNAME: gamemladmin@gmail.com PASSWORD: gamemlsite Upload Here: http://gameml.iowoi.org/GameML-File-Sharing-h3.htmPlease add only games.
Create A GAMEML BLOG!
Make a Blog on GameML:http://gamemlblogs.wetpaint.com
Keywords


non-duplicate random number generation

View previous topic View next topic Go down

non-duplicate random number generation

Post by GoldenBeastStudios on Thu Sep 10, 2009 11:32 pm

The topic title is a mouthful, but accurate lol. I have a game I'm tinkering with titled Froggo (at least it's called that for now) it involves the play area having random numbers from 1-75 on 24 different tiles. You can play the prototype on yoyo here To get the numbers on the tiles, I put in the tile object creation event:

number=floor(random(74))+1

Using the floor command gets rid of any decimals, but I'm running into a problem with duplicate number (ie number 25 on 6 different tiles). The ideal is to have no duplicate numbers on any of the tiles. I know putting the code in the create event probably isn't the smartest way to go about it, but I'm just not sure how create the desired result. Any pointers?

Regards,

John,
avatar
GoldenBeastStudios
GameML Adventurer
GameML Adventurer

Posts : 117
Points : 30424
GameML Reputation : 2
Join date : 2009-07-09
Age : 34
Location : Austin, Texas

View user profile http://www.goldenbeaststudios.com

Back to top Go down

Re: non-duplicate random number generation

Post by The Dark Ninja on Fri Sep 11, 2009 4:14 pm

can you give more actions for it like if there was something in the draw event
avatar
The Dark Ninja
Super 500 GML
Super 500 GML

Posts : 1495
Points : 33144
GameML Reputation : 7
Join date : 2009-06-16
Location : Earth

View user profile http://www.thedakninja.tastyhamgames.com

Back to top Go down

Re: non-duplicate random number generation

Post by GoldenBeastStudios on Fri Sep 11, 2009 4:25 pm

What I'm missing is a way to determine when there's duplicates, and then take some sort of action to correct it... or something Razz I'm suspecting I need something in the room create code, I just can't quite wrap my mind around what I would need to meet my desired result :p Thanks all the same though! Smile
avatar
GoldenBeastStudios
GameML Adventurer
GameML Adventurer

Posts : 117
Points : 30424
GameML Reputation : 2
Join date : 2009-07-09
Age : 34
Location : Austin, Texas

View user profile http://www.goldenbeaststudios.com

Back to top Go down

Re: non-duplicate random number generation

Post by The Dark Ninja on Fri Sep 11, 2009 4:45 pm

maybe something like this

room code
Code:
global.empty=0

then on your event put it in the step event

Code:
if global.empty=0
{
number=floor(random(74))+1
global.empty=1
}

then try that if that does not work you might have to make different varibles and objects for each square
avatar
The Dark Ninja
Super 500 GML
Super 500 GML

Posts : 1495
Points : 33144
GameML Reputation : 7
Join date : 2009-06-16
Location : Earth

View user profile http://www.thedakninja.tastyhamgames.com

Back to top Go down

Re: non-duplicate random number generation

Post by GoldenBeastStudios on Fri Sep 11, 2009 4:48 pm

lol, we were both thinking along the same lines Razz I think something like this might do it Razz I'm going to try it out Smile
avatar
GoldenBeastStudios
GameML Adventurer
GameML Adventurer

Posts : 117
Points : 30424
GameML Reputation : 2
Join date : 2009-07-09
Age : 34
Location : Austin, Texas

View user profile http://www.goldenbeaststudios.com

Back to top Go down

Re: non-duplicate random number generation

Post by GoldenBeastStudios on Fri Sep 11, 2009 4:50 pm

Hey! were'd my last message go!?! I had a bunch of code writting out similar to what you have, and now it's gone! >:c anyway, I'm going to try it out Smile
avatar
GoldenBeastStudios
GameML Adventurer
GameML Adventurer

Posts : 117
Points : 30424
GameML Reputation : 2
Join date : 2009-07-09
Age : 34
Location : Austin, Texas

View user profile http://www.goldenbeaststudios.com

Back to top Go down

Re: non-duplicate random number generation

Post by The Dark Ninja on Fri Sep 11, 2009 4:51 pm

k
avatar
The Dark Ninja
Super 500 GML
Super 500 GML

Posts : 1495
Points : 33144
GameML Reputation : 7
Join date : 2009-06-16
Location : Earth

View user profile http://www.thedakninja.tastyhamgames.com

Back to top Go down

Re: non-duplicate random number generation

Post by GoldenBeastStudios on Fri Sep 11, 2009 5:16 pm

Ug, it didn't really work out, even if I set up global variables to account for the numbers, I don't know how to make the object "reset" to try again. Even if I could, in theory, it could go on forever until it reaches a untaken number. I'm stumped Sad
avatar
GoldenBeastStudios
GameML Adventurer
GameML Adventurer

Posts : 117
Points : 30424
GameML Reputation : 2
Join date : 2009-07-09
Age : 34
Location : Austin, Texas

View user profile http://www.goldenbeaststudios.com

Back to top Go down

Re: non-duplicate random number generation

Post by The Dark Ninja on Fri Sep 11, 2009 5:24 pm

no i meant like
on the second on

room create
Code:
global.squareone=0
global.squaretwo=0
//ect.

step

on sqaure one

Code:
if global.squareone=0
{
number=floor(random(74))+1
global.empty=1
}

and same for the rest of square accept on square two the varible would be global.squaretwo ect..
avatar
The Dark Ninja
Super 500 GML
Super 500 GML

Posts : 1495
Points : 33144
GameML Reputation : 7
Join date : 2009-06-16
Location : Earth

View user profile http://www.thedakninja.tastyhamgames.com

Back to top Go down

Re: non-duplicate random number generation

Post by GoldenBeastStudios on Fri Sep 11, 2009 7:11 pm

Sorry, I don't get it Razz How would that prevent duplicate numbers? Thank you for helping! I'm not smart lol Razz
avatar
GoldenBeastStudios
GameML Adventurer
GameML Adventurer

Posts : 117
Points : 30424
GameML Reputation : 2
Join date : 2009-07-09
Age : 34
Location : Austin, Texas

View user profile http://www.goldenbeaststudios.com

Back to top Go down

Re: non-duplicate random number generation

Post by fooey on Fri Sep 11, 2009 7:17 pm

... wow...

_________________
we are the champions - my friends
And we'll keep on fighting - till the end -
We are the champions -
We are the champions
No time for losers
'Cause we are the champions - of the world -
avatar
fooey
Moderator
Moderator

Posts : 1422
Points : 31750
GameML Reputation : 1
Join date : 2009-07-10
Age : 22
Location : here

View user profile

Back to top Go down

Re: non-duplicate random number generation

Post by GoldenBeastStudios on Sat Sep 26, 2009 2:10 pm

This topic is still open! i can't figure it out Razz Thanks to all who have replied Smile
avatar
GoldenBeastStudios
GameML Adventurer
GameML Adventurer

Posts : 117
Points : 30424
GameML Reputation : 2
Join date : 2009-07-09
Age : 34
Location : Austin, Texas

View user profile http://www.goldenbeaststudios.com

Back to top Go down

Re: non-duplicate random number generation

Post by The Dark Ninja on Sat Sep 26, 2009 4:31 pm

could you like give me a gmk whith just the blocks with the numbers in it
avatar
The Dark Ninja
Super 500 GML
Super 500 GML

Posts : 1495
Points : 33144
GameML Reputation : 7
Join date : 2009-06-16
Location : Earth

View user profile http://www.thedakninja.tastyhamgames.com

Back to top Go down

Re: non-duplicate random number generation

Post by GoldenBeastStudios on Sat Sep 26, 2009 4:33 pm

I could do a quick mock-up, I'll make it asap Smile thanks!
avatar
GoldenBeastStudios
GameML Adventurer
GameML Adventurer

Posts : 117
Points : 30424
GameML Reputation : 2
Join date : 2009-07-09
Age : 34
Location : Austin, Texas

View user profile http://www.goldenbeaststudios.com

Back to top Go down

Re: non-duplicate random number generation

Post by The Dark Ninja on Sat Sep 26, 2009 4:36 pm

i will probally finnish it on monday if don't get on the computer
avatar
The Dark Ninja
Super 500 GML
Super 500 GML

Posts : 1495
Points : 33144
GameML Reputation : 7
Join date : 2009-06-16
Location : Earth

View user profile http://www.thedakninja.tastyhamgames.com

Back to top Go down

Re: non-duplicate random number generation

Post by GoldenBeastStudios on Sat Sep 26, 2009 4:47 pm

Posted a GMK on our SkyDrive to help clarify the problem, you can find it here:

http://cid-938ebb7f49a5a4e7.skydrive.live.com/self.aspx/tile^_number/tile^_numbers.gmk

(The Skydrive link is acting weird, just copy & paste this link into your browser)

Thanks to all who reply Smile
avatar
GoldenBeastStudios
GameML Adventurer
GameML Adventurer

Posts : 117
Points : 30424
GameML Reputation : 2
Join date : 2009-07-09
Age : 34
Location : Austin, Texas

View user profile http://www.goldenbeaststudios.com

Back to top Go down

Re: non-duplicate random number generation

Post by The Dark Ninja on Sat Sep 26, 2009 5:14 pm

k
avatar
The Dark Ninja
Super 500 GML
Super 500 GML

Posts : 1495
Points : 33144
GameML Reputation : 7
Join date : 2009-06-16
Location : Earth

View user profile http://www.thedakninja.tastyhamgames.com

Back to top Go down

Re: non-duplicate random number generation

Post by -js1210- on Sat Sep 26, 2009 6:26 pm

Well you could just do the really hard thing to do and make like 50 individual tiles. And then if the number of two(or more) tiles is the same all the tiles get new numbers.
avatar
-js1210-
Super 500 GML
Super 500 GML

Posts : 1298
Points : 32732
GameML Reputation : 27
Join date : 2009-06-02
Age : 22
Location : United States

View user profile http://www.yoyogames.com/members/js1210

Back to top Go down

Re: non-duplicate random number generation

Post by GoldenBeastStudios on Sat Sep 26, 2009 6:50 pm

One thing I'm trying to avoid is having the numbers change after the object is created (although if I can't figure out a way to do that, I guess I'll have to live with it Razz) That idea isn't bad though, I'll have to keep kicking around that idea Razz I didn't know this would be so hard Razz

Thanks for your help!

John,
avatar
GoldenBeastStudios
GameML Adventurer
GameML Adventurer

Posts : 117
Points : 30424
GameML Reputation : 2
Join date : 2009-07-09
Age : 34
Location : Austin, Texas

View user profile http://www.goldenbeaststudios.com

Back to top Go down

Re: non-duplicate random number generation

Post by -js1210- on Sat Sep 26, 2009 7:05 pm

-js1210- wrote:Well you could just do the really hard thing to do and make like 50 individual tiles. And then if the number of two(or more) tiles is the same all the tiles get new numbers.

Just to let you know I meant only the tiles that have the same numbers.
avatar
-js1210-
Super 500 GML
Super 500 GML

Posts : 1298
Points : 32732
GameML Reputation : 27
Join date : 2009-06-02
Age : 22
Location : United States

View user profile http://www.yoyogames.com/members/js1210

Back to top Go down

Re: non-duplicate random number generation

Post by GoldenBeastStudios on Sun Sep 27, 2009 6:53 pm

Fixed the problem using a ds_list! Thanks for helping everyone! Smile
avatar
GoldenBeastStudios
GameML Adventurer
GameML Adventurer

Posts : 117
Points : 30424
GameML Reputation : 2
Join date : 2009-07-09
Age : 34
Location : Austin, Texas

View user profile http://www.goldenbeaststudios.com

Back to top Go down

Re: non-duplicate random number generation

Post by The Dark Ninja on Mon Sep 28, 2009 8:27 pm

your welcome
avatar
The Dark Ninja
Super 500 GML
Super 500 GML

Posts : 1495
Points : 33144
GameML Reputation : 7
Join date : 2009-06-16
Location : Earth

View user profile http://www.thedakninja.tastyhamgames.com

Back to top Go down

Re: non-duplicate random number generation

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum