AND and OR statement...loop with several conditions
stefdelec
Member, PRO Posts: 146
Hi,
I am really struggling with this.
I need to generate 2 pairs of attributes.
attr1=random(-1;1)
attr2=random(-1;1)
attr3=random(-1;1)
attr4=random(-1;1)
attr1 and attr2: I need at least one of them to be different from 0.
attr3 and attr4: I need at least one of them to be different from 0.
AND I need (attr1;attr2) different from (attr3;attr4).
I am using a loop atm:
while all : attr1 = 0 and attr 2= 0 => random both of them.
Any idea?
Thanks,
Stéphane.
Comments
Does this mean attr1 must be different from attr3 and attr2 must be different from attr4, or does it mean that attr1 and attr2 must be different from attr3 and attr3?
i.e.
1,0 / 1,-1 would be okay?
or would it have to be 1,0 / -1,1 or something similar?
In other words, is it the whole pairings that must be different?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
The pairing must be different
1;1 /1;1 not ok
1;1/1;0 ok.
1;1; / 1;-1 ok.
Am I clear?
Wow this was quite an interesting one to solve.
I'm sure there's a simpler way of going about this, but here's what I came up with. There are a lot of conditions that need to be met when generating the numbers.
Looking forward to seeing how someone cleverer does it in a more simple way!
I've specifically avoided loops as they tend to run slower than using conditions. It can almost certainly be done more cleanly using loops, but I'd be surprised if it can be done quicker.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Hum thanks a lot!I didn't know rules were faster than loop....!
If someone has another idea?
Are we dealing with decimals here?
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
If something can be done in a single pass, it's almost always better to do it that way. My solution may look a little complicated, but it's really not - just read the rule names and you'll see exactly what it'd doing (if your screen is smaller and they're getting cut off, just copy/paste them into a note or something).
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Nop! No decimal!
Thansk, I ve checked your rules! SOunds good!