Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Procedural generation, random number generations & more...

Author
Message
Kakise
AGK Tool Maker
7
Years of Service
User Offline
Joined: 25th May 2016
Location: Paris
Posted: 18th Feb 2017 15:20
Heya everyone !
First post on this forum !

So... ok, I want to make a rogue-like rpg 2D game with procedurally generated levels and I'd like to know if any of you ever wondered how to make an algortihm for procedural generation. I'm pretty good at mathematics so I'm not afraid of anything
I don't want to have poorly generated world & levels like in No Man's Sky so please don't talk about Gauss here (nah jk :3). I wondered how you guys do to generate random numbers?

In Unix based system it would be really realy easy, basically just read /dev/random but what about windows? I don't want to use the default built-in random number generators as I don't feel like it would be sufficient for what I want my game to be :/

Any advice/experiences on how to make a roguelike is apreciated

Thank you for reading <3
Kakise
AGK Tool Maker
7
Years of Service
User Offline
Joined: 25th May 2016
Location: Paris
Posted: 18th Feb 2017 15:22
Is my post here?
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 18th Feb 2017 17:35 Edited at: 18th Feb 2017 17:39
I'm not a pro, but
There are several ways procedural dungeons can be arranged.
Some people generate the various rooms first, then connect them via passageways.
Some people just dug in the passageways, and build the room along the passageway.

To create random numbers, just use this function



Here's some example of an algorithm
http://www.gamasutra.com/blogs/AAdonaac/20150903/252889/Procedural_Dungeon_Generation_Algorithm.php
PSY
Developer
7
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 18th Feb 2017 17:36
Hey and welcome to the forum

Yes your post is here, newcomers get some sort of post-delay due to 'security' reasons

The build-in random generator is more than sufficient for your needs ^^
It's not about the RNG algorithm, it's about your implementation how to 'design' random rooms / dungeons.

Here's a super-easy dungoen-building algorithm to give you a nudge in the right direction:
http://www.roguebasin.com/index.php?title=Dungeon-Building_Algorithm

Here's a link that you may want to investigate: The PCG Wiki is a central knowledge-base for everything related to Procedural Content Generation, as well as a detailed directory of games using Procedural Content Generation.
http://pcg.wikidot.com/


Cheers,
PSY




PSY LABS Games
Coders don't die, they just gosub without return
Kakise
AGK Tool Maker
7
Years of Service
User Offline
Joined: 25th May 2016
Location: Paris
Posted: 18th Feb 2017 19:13
Quote: "Yes your post is here, newcomers get some sort of post-delay due to 'security' reasons "

Oh didn't knew it, thanks

Quote: "Some people generate the various rooms first, then connect them via passageways.
Some people just dug in the passageways, and build the room along the passageway."

Does it make some kind of differance?

Quote: "The build-in random generator is more than sufficient for your needs ^^
It's not about the RNG algorithm, it's about your implementation how to 'design' random rooms / dungeons."

Oh okay, I didn't knew that ^^, I thought that the number gen algorith was as important as the implementations :/

Quote: "Here's a super-easy dungoen-building algorithm to give you a nudge in the right direction:
http://www.roguebasin.com/index.php?title=Dungeon-Building_Algorithm

Here's a link that you may want to investigate: The PCG Wiki is a central knowledge-base for everything related to Procedural Content Generation, as well as a detailed directory of games using Procedural Content Generation.
http://pcg.wikidot.com/"

Quote: "
Here's some example of an algorithm
http://www.gamasutra.com/blogs/AAdonaac/20150903/252889/Procedural_Dungeon_Generation_Algorithm.php"


Thank you, I'll read those tonight
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 18th Feb 2017 22:54
One other thing to point out. Procedural generation is not the same as randomly generated content.
Procedurally generated content is controlled and predictable (although it could be too complicated to mentally process).
Randomly generated content is exactly what it says on the tin.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 21st Feb 2017 13:34 Edited at: 21st Feb 2017 14:48
Quote: "Randomly generated content is exactly what it says on the tin."
However, due to the way the random functions are built, you CAN control the seed of the random sequence, where the sequence will always be the same given the same seed. For example, if you put: SetRandomSeed(1) at the top of your code, then your "random" levels can be the same every time. With careful planning, the random function can successfully be used in a legitimate method of building procedural content.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Feb 2017 14:40
Quote: "example, if you put: Randomize(1) at the top of your code, then your "random" levels can be the same every time."

On the same machine that is, right? Your PC and mine would generate different content using the same seed wouldn't it? Or is it just a matter of RNG implementation in the language?

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 21st Feb 2017 14:47
Let's test it. Sorry, the command is SetRandomSeed (not randomize - I'll edit the post above). Try the following on your machine:


I get the following sequence:
42
236
335
269
938
725
479
359
963
233
706
146
50
596
730
260
996
711
828
205
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 21st Feb 2017 15:32
I get the same result here.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Ranietz
AGK Gold Backer
19
Years of Service
User Offline
Joined: 2nd Sep 2004
Location: Norway
Posted: 21st Feb 2017 18:46
I also get the same results.
A while ago I did a similar test with my PC vs Android phone and they too gave the same results.
I also think its been confirmed by one of the TGC developers at some time.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 21st Feb 2017 20:24 Edited at: 21st Feb 2017 22:27
It should be the same, because the random number algorithm used is the same. The only problem with relying on random for procedural content is that if the random algorithm were to change during an update (which it shouldn't do, but might when a bug is being fixed for example) then your levels will change. Probably best to use your own algorithms. Mod and FMOD are good for creating pseudo random numbers.


... thought I'd have a play around and create a pseudo random function. Ended up making a funky little scribble demo with it! Here it is (note: function myrand requires a global variable called myseed (integer)):

Attachments

Login to view attachments
PSY
Developer
7
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 21st Feb 2017 22:13
There are 2 methods to produce random numbers:
A true random number generator and a pseudorandom number generator (which is deterministic).

The PNG will always produce the same numbers when fed with the same seed.
That's very useful for games, as you can easily produce identical levels, worlds and other stuff by using the same seed.

A good example is WORMS. If you want to share a really awesome level you just found or created with your friends, you only need to give them the seed you used.

Here's a wiki article which explains the basics:
https://en.wikipedia.org/wiki/Pseudorandom_number_generator


Cheers,
PSY
PSY LABS Games
Coders don't die, they just gosub without return
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Feb 2017 15:13
Good info to know

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Login to post a reply

Server time is: 2024-04-19 01:31:51
Your offset time is: 2024-04-19 01:31:51