Click here to Skip to main content
15,897,704 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Needed a series of random numbers Pin
Nagy Vilmos8-Sep-11 3:29
professionalNagy Vilmos8-Sep-11 3:29 
GeneralRe: Needed a series of random numbers Pin
Bert Mitton8-Sep-11 3:35
professionalBert Mitton8-Sep-11 3:35 
GeneralRe: Needed a series of random numbers Pin
Matty2225-Sep-11 21:16
Matty2225-Sep-11 21:16 
GeneralRe: Needed a series of random numbers Pin
BobJanova8-Sep-11 4:27
BobJanova8-Sep-11 4:27 
GeneralRe: Needed a series of random numbers Pin
RCoate8-Sep-11 12:24
RCoate8-Sep-11 12:24 
GeneralRe: Needed a series of random numbers Pin
annathor8-Sep-11 22:50
annathor8-Sep-11 22:50 
GeneralRe: Needed a series of random numbers Pin
Allan Thomas10-Sep-11 0:49
Allan Thomas10-Sep-11 0:49 
GeneralRe: Needed a series of random numbers [modified] Pin
CDP180214-Sep-11 3:01
CDP180214-Sep-11 3:01 
Don't be too hard on yourself. Most people never realize what the 'pseudo' in 'pseudo random number generator' is about. Just turn things around and it may even come in handy at times.

Do you remember the old game Elite? The game had about five galaxies with 256 star systems each. Each system had its own coordinates, a description of the planet and inhabitants and individual prices and stocks for all goods. A good old C64 would have to sacrifice a good part of its tiny memory to store all that.

I'm quite sure they did not. For example, you might generate a hashcode from the coordinates of a system. Then you initialize a random number generator with this hash code and use it to randomly generate the parameters of that system. Since the hashcode will always be the same for that system, the result will be the same every time and can be recreated at will. This completely eliminates the need to store any of the static information. Just the things which are variable, like the current stocks, need to be stored.

For a 'small' game I'm working on I have made a star map with 4 billiion universes with up to 4 billion galaxies, each with 4 billion x 4 billion x 4 billion coordinate points. Each coordinate point has a chance to contain a solar system, each with one or more stars of different types, a variable number of planets of many types and the planets may also have moons. Memory or storage costs: The XML configuration files to work out a convincing star system.
"Dark the dark side is. Very dark..." - Yoda
---
"Shut up, Yoda, and just make yourself another toast." - Obi Wan Kenobi



modified on Wednesday, September 14, 2011 9:43 AM

GeneralRe: Needed a series of random numbers Pin
Bert Mitton14-Sep-11 3:07
professionalBert Mitton14-Sep-11 3:07 
GeneralRe: Needed a series of random numbers Pin
CDP180214-Sep-11 3:49
CDP180214-Sep-11 3:49 
GeneralRe: Needed a series of random numbers Pin
Bert Mitton14-Sep-11 4:04
professionalBert Mitton14-Sep-11 4:04 
GeneralMessage Removed Pin
21-Sep-11 7:04
professionalN_tro_P21-Sep-11 7:04 
GeneralRe: Needed a series of random numbers Pin
Bert Mitton22-Sep-11 3:08
professionalBert Mitton22-Sep-11 3:08 
GeneralRe: Needed a series of random numbers Pin
Luis D. Aguilar7-Oct-11 7:49
Luis D. Aguilar7-Oct-11 7:49 
GeneralCommenting code... Pin
Sander Rossel4-Sep-11 20:47
professionalSander Rossel4-Sep-11 20:47 
GeneralRe: Commenting code... Pin
Firo Atrum Ventus4-Sep-11 22:02
Firo Atrum Ventus4-Sep-11 22:02 
GeneralRe: Commenting code... Pin
Allan Thomas5-Sep-11 14:53
Allan Thomas5-Sep-11 14:53 
GeneralRe: Commenting code... Pin
Sander Rossel5-Sep-11 19:56
professionalSander Rossel5-Sep-11 19:56 
GeneralRe: Commenting code... Pin
BobJanova5-Sep-11 23:04
BobJanova5-Sep-11 23:04 
GeneralRe: Commenting code... Pin
tobep9-Sep-11 7:13
tobep9-Sep-11 7:13 
GeneralRe: Commenting code... Pin
Sander Rossel9-Sep-11 7:22
professionalSander Rossel9-Sep-11 7:22 
GeneralRe: Commenting code... PinPopular
RCoate5-Sep-11 18:37
RCoate5-Sep-11 18:37 
GeneralRe: Commenting code... Pin
Sander Rossel5-Sep-11 19:58
professionalSander Rossel5-Sep-11 19:58 
GeneralRe: Commenting code... PinPopular
Rob Grainger6-Sep-11 0:32
Rob Grainger6-Sep-11 0:32 
GeneralRe: Commenting code... Pin
Firo Atrum Ventus6-Sep-11 14:35
Firo Atrum Ventus6-Sep-11 14:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.