Gamestudio Links
Zorro Links
Newest Posts
Z9 getting Error 058
by k_ivan. 04/20/26 15:57
Stooq now requires an API key
by jcl. 04/13/26 09:42
Strange "Alien" Skull created with >Knubber<
by NeoDumont. 04/10/26 18:58
400 free seamless texture pack downl. here !
by NeoDumont. 04/08/26 19:55
ZorroGPT
by TipmyPip. 04/08/26 17:08
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (Quad), 4,666 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
juergenwue, VladMak, Geir, ondrej, mredit
19208 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 | 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