Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (NewbieZorro, TipmyPip, 1 invisible), 19,045 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Seasons related to the Random Variables #246775
01/17/09 04:10
01/17/09 04:10
Joined: Nov 2008
Posts: 20
D
deyshawn Offline OP
Newbie
deyshawn  Offline OP
Newbie
D

Joined: Nov 2008
Posts: 20
I am making a game where you are the governor of a city, and you have to "manage" its citizens and economy. I currently have variables for "male", "female", "pop" (population), "trade", "births", and "deaths". I want the amounts of males, females, births, and deaths to be random (or partly random and partly based on certain parameters). Does anybody know how I would go about writing the code for this?
______________________________________________________________________________________________________________________

Thankyou for your help with this. I have another question. This game is not turn based, its in realtime. I was thinking of making every 15 minutes a different season, and every four seasons, the year would update. That would make each year an hour in realtime. I am not sure exactly how to do this. I tried using sys_minutes, but that didn't work. I also don't know how to make the random variables update only once a season. Can anyone help me?
-Deyshawn

Last edited by deyshawn; 01/19/09 14:41.
Re: Code that produces random variables [Re: deyshawn] #246785
01/17/09 08:53
01/17/09 08:53
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline
Serious User
croman  Offline
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
function main()
{
...randomize();

var male = 1000 + (random(500) - random(500));
...


maybe something like this?



Ubi bene, ibi Patria.
Re: Code that produces random variables [Re: croman] #246800
01/17/09 10:52
01/17/09 10:52
Joined: Jul 2008
Posts: 170
Germany, near Mainz
Nicotin Offline
Member
Nicotin  Offline
Member

Joined: Jul 2008
Posts: 170
Germany, near Mainz
I would say something like
Code:
var population;
var male;
var female;
var birth;
var death;

funtion random_city()
{
  population = random(1000);//Max Population
  male = random(population);//Get random number of males
  female = population - male; //And the rest are females
  birth = random(population / 2);//Just 2 people can make one child at once
  death = random(population); //get random death
}


And the "not random" part you can do with adding the parameters or sub them like
male = random(population - parameter);

Last edited by Nicotin; 01/17/09 10:55.


Re: Code that produces random variables [Re: Nicotin] #246823
01/17/09 13:46
01/17/09 13:46
Joined: Nov 2008
Posts: 20
D
deyshawn Offline OP
Newbie
deyshawn  Offline OP
Newbie
D

Joined: Nov 2008
Posts: 20
Thankyou, I didn't know that "random" was a command.

Re: Code that produces random variables [Re: croman] #246963
01/18/09 05:39
01/18/09 05:39
Joined: Oct 2008
Posts: 218
Nashua NH
heinekenbottle Offline
Member
heinekenbottle  Offline
Member

Joined: Oct 2008
Posts: 218
Nashua NH
Originally Posted By: cerberi_croman
function main()
{
...randomize();

var male = 1000 + (random(500) - random(500));
...


maybe something like this?


I think randomize() is gone and replaced with random_seed(var seed), where seed = 0 gives a true random number sequence.

Last edited by heinekenbottle; 01/18/09 05:39.

I was once Anonymous_Alcoholic.

Code Breakpoint;

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1