Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 20:05
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (7th_zorro, AndrewAMD, TedMar), 1,306 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 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 | chip programmers | 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