Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/19/24 18:45
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), 837 guests, and 2 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
AUM 27 ai code - value limiting #251369
02/12/09 19:17
02/12/09 19:17
Joined: May 2008
Posts: 331
Lithuania, Vilnius
Jaxas Offline OP
Senior Member
Jaxas  Offline OP
Senior Member

Joined: May 2008
Posts: 331
Lithuania, Vilnius
Hi, i have a question, i wondering what sequent line do:

index %= 49; // limit the "index" value

Whether it's equal to:

if(index == 49)index = 0;

?

I want to understand what %= realy does smile


The smaller the bug, the harder it is to kill.
_________________________________________
Forklift DEMO (3dgs)
Re: AUM 27 ai code - value limiting [Re: Jaxas] #251387
02/12/09 20:26
02/12/09 20:26
Joined: Jan 2009
Posts: 76
V
V_Software Offline
Junior Member
V_Software  Offline
Junior Member
V

Joined: Jan 2009
Posts: 76
the % operator limits the value ( in this case index) to a maximum of 49, so that its impossible to go 50,51 etc.

something similar would be:
if(index > 100) { index = 0; )

but this is bad because it doesn't consider the actual index value, it just sets it to 0.

instead index %= 49 is just an abbreviation for:
index = index % 49;

and the % means just this:
remainder of index / 49
so with % Acknex returns an integer remainder of 2 numbers

Re: AUM 27 ai code - value limiting [Re: Jaxas] #251389
02/12/09 20:37
02/12/09 20:37
Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Cowabanga Offline
Expert
Cowabanga  Offline
Expert

Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
It mean the limit of the variable.

Re: AUM 27 ai code - value limiting [Re: Jaxas] #251448
02/13/09 07:15
02/13/09 07:15
Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
George Offline

Expert
George  Offline

Expert

Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
The modulo (%) operator finds the remainder of the division of a number by another. As an example, 7 % 3 = 1, 8 % 4 = 0 and so on.
index %= 49 makes sure that index can't exceed 48; it will be set to 0, 1, 2, ..., 47, 48, 0, 1, 2... as index is incremented.

Re: AUM 27 ai code - value limiting [Re: George] #251479
02/13/09 09:49
02/13/09 09:49
Joined: May 2008
Posts: 331
Lithuania, Vilnius
Jaxas Offline OP
Senior Member
Jaxas  Offline OP
Senior Member

Joined: May 2008
Posts: 331
Lithuania, Vilnius
I get it. I count first 3 values and get that circle laugh i just think now, why i don't count it before, cause i know what is modulo... laugh but thanks for reply wink


The smaller the bug, the harder it is to kill.
_________________________________________
Forklift DEMO (3dgs)

Moderated by  George 

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