Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Please add Modulo to S&S Editor Logic Syntax

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Shadow Empire >> Suggestions and Feedback >> Please add Modulo to S&S Editor Logic Syntax Page: [1]
Login
Message << Older Topic   Newer Topic >>
Please add Modulo to S&S Editor Logic Syntax - 5/11/2021 12:51:26 PM   
No New Messages
zgrssd
Matrix Legion of Merit


 

Posts: 3385
Joined: 6/9/2020
Status: offline
The Modulo Operator (% in C#) is one of those Operations where at first you have no idea "what is it even good for?"
And once you realize, you can not live without it.

Y % X == 0
checks if Y can be divided by X without rest.

The most common example would be to check if a number is even:
Y % 2 == 0


But you can also do some other usefull stuff like "every 20th Turn":
ROUND % 20 == 0


I tried to approxmiate it with simple division, but
3 / 2 == 1
is true. As naturally with Integers, 3/2 rounds down to 1. And 1 == 1
I will have to use a large list of or checks like:
ROUND == 20 | ROUND == 40 | etc.


< Message edited by zgrssd -- 5/11/2021 12:52:52 PM >
Post #: 1
RE: Please add Modulo to S&S Editor Logic Syntax - 5/11/2021 2:46:30 PM   
No New Messages
DeltaV112
Matrix Recruit


 

Posts: 45
Joined: 10/16/2014
Status: offline
Presuming we're using integer division.
X % Y == X - (X / Y * Y)

(in reply to zgrssd)
Post #: 2
RE: Please add Modulo to S&S Editor Logic Syntax - 5/11/2021 4:48:14 PM   
No New Messages
zgrssd
Matrix Legion of Merit


 

Posts: 3385
Joined: 6/9/2020
Status: offline

quote:

ORIGINAL: DeltaV112

Presuming we're using integer division.
X % Y == X - (X / Y * Y)

If the game does any variable pruning, it might just be executed as "X % Y == X - X" Or X % Y == 0.
And I would need to check if it even covers all cases properly mathematically.

Plus either way, it is a pretty huge waste of calculation and excessively verbose code - for something that CPU's have hardware level support for

(in reply to DeltaV112)
Post #: 3
RE: Please add Modulo to S&S Editor Logic Syntax - 5/12/2021 10:19:58 AM   
No New Messages
zgrssd
Matrix Legion of Merit


 

Posts: 3385
Joined: 6/9/2020
Status: offline
I think I can use story+decision logic for something here, that would also allow catching up with any missed events:
$dueInstances$
$triggeredInstances$

# Executed each turn
if($dueInstances$+1 * 20 >= ROUND)
  $dueInstances$ = $dueInstances$+1

# Then in the actuall event:
if($dueInstances$ > $triggeredInstances$)
  # Do the event
  $triggeredInstances$ = $triggeredInstances$ +1

Still I would prefer being able to just use "ROUND % 20 == 0".

< Message edited by zgrssd -- 5/12/2021 10:21:07 AM >

(in reply to zgrssd)
Post #: 4
RE: Please add Modulo to S&S Editor Logic Syntax - 5/14/2021 8:28:21 PM   
No New Messages
DeltaV112
Matrix Recruit


 

Posts: 45
Joined: 10/16/2014
Status: offline
quote:

ORIGINAL: zgrssd
If the game does any variable pruning, it might just be executed as "X % Y == X - X" Or X % Y == 0.
And I would need to check if it even covers all cases properly mathematically.

Plus either way, it is a pretty huge waste of calculation and excessively verbose code - for something that CPU's have hardware level support for

If the game is doing pruning in this case it's a bug, no matter how you slice it divide then multiply by same value is not equivalent to doing nothing. And in performance terms it's irrelevant- your CPU can demolish math like this, and if this somehow does become a performance bottleneck modern CPU's can recognize idioms like this and change the instruction flow(if this were using a non-custom language the compiler would certainly recognize it).

(in reply to zgrssd)
Post #: 5
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Shadow Empire >> Suggestions and Feedback >> Please add Modulo to S&S Editor Logic Syntax Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

1.063