Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Closed Thread
 
Thread Tools Search this Thread Display Modes
  #41  
Old 05-25-2006, 02:09 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by jake13jake
if (function() == false)

CASE 1:
function() returns true
true == false
true is not equivalent to false, therefore the statement is false.

CASE 2:
function() returns false
false == false
false is equivalent to false, therefore the statement is true.

Tell me, what's the contrapositive to p->q?

Seriously, take a course in logic or something.
I lied, one more post.

Good job for proving that both are the exact same amount of steps, and the same amount of work required by the applications.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
  #42  
Old 05-25-2006, 06:55 PM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by ApothiX
I lied, one more post.

Good job for proving that both are the exact same amount of steps, and the same amount of work required by the applications.
Uh, no.
function() returns true
that's one step
true is equivalent to true
that's two steps

function returns true
that's one step

When you do
function() returns false
false is equivalent to false
that's two steps too

also
function() returns false
the ! operator negates false to true.
there's two steps

However, you wouldn't know if the ! operator is faster than the == operator in gscript. But for true values there's more steps in comparison by ==true.
  #43  
Old 05-26-2006, 02:18 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by jake13jake
Uh, no.
function() returns true
that's one step
true is equivalent to true
that's two steps

function returns true
that's one step
Actually, both are comparing to true. I now know your theory behind this, and that you're a ***** because of it.

(Last post here, seriously)
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
  #44  
Old 05-26-2006, 02:53 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by jake13jake
if (function() == false)
if (!function())
__________________
Skyld
  #45  
Old 05-26-2006, 03:14 PM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by Skyld
if (!function())
Quote:
Originally Posted by jake13jake
also
function() returns false
the ! operator negates false to true.
there's two steps
moo.

Quote:
Originally Posted by ApothiX
Actually, both are comparing to true. I now know your theory behind this, and that you're a ***** because of it.

(Last post here, seriously)
The computer doesn't compare to true if it has already interpreted true.
  #46  
Old 05-27-2006, 01:56 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Alright well, you're just getting annoying so I will have to present some cold hard facts.

PHP Code:
bool Ret(bool b) {
    return 
b;
}

int main(int argcchar *argv[]) {
    
int a;

    if(
Ret(true)) {
        
10;
    }

    return 
0;

This code (which is C), when compiled (without optimizations) and dissassembled, produces the EXACT same assembly as this code:

PHP Code:
bool Ret(bool b) {
    return 
b;
}

int main(int argcchar *argv[]) {
    
int a;

    if(
Ret(true) == true) {
        
10;
    }

    return 
0;

There is no redundant checking going on. Stop posting here.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
  #47  
Old 05-27-2006, 02:22 AM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Quote:
Originally Posted by ApothiX
This code (which is C),
It is actually C++. C does not have a bool type unless it is C99 and you include stdbool.h or something.

Quote:
when compiled (without optimizations) and dissassembled, produces the EXACT same assembly as this code
Does not!

PHP Code:
ben@oreichalkon ~ $ cat foo.cpp
#include <cstdlib>
#include <cstdio>

bool random_bool() {
        return 
std::rand() % 2;
}

int main() {
        if (
random_bool()
        
#ifdef REDUNDANT_CHECK
          
== true
        
#endif
        
)
                
std::puts("true!");
}
ben@oreichalkon ~ $ gcc -O0 --o foo.s foo.cppgcc -O0 --o foo_.-DREDUNDANT_CHECK foo.cpp
ben
@oreichalkon ~ $ diff foo_.s foo.s                                           41,43c41,42
<       movzbl  %al, %eax
<       cmpl    $1, %eax
<       jne     .L3
---
>       
testb   %al, %al
>       je      .L3 
  #48  
Old 05-27-2006, 02:41 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Loriel
Does not!
Different compilers produce different results. It seems like Visual C was probably optimizing the == true check even when I turned optimizations off. Which is probably what the Graal Engine does aswell.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
  #49  
Old 05-27-2006, 03:13 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by ApothiX
Different compilers produce different results. It seems like Visual C was probably optimizing the == true check even when I turned optimizations off. Which is probably what the Graal Engine does aswell.
Yes, but you don't know whether or not the Graal engine does that, you can only guess. Isn't that what I was initially saying? It's certainly redundant in script, but the compiler may or may not interpret it with a redundancy check. When optimizing, your compiler removes the == true comparison. How kind of it.
  #50  
Old 05-27-2006, 03:19 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by jake13jake
Yes, but you don't know whether or not the Graal engine does that, you can only guess. Isn't that what I was initially saying? It's certainly redundant in script, but the compiler may or may not interpret it with a redundancy check. When optimizing, your compiler removes the == true comparison. How kind of it.
It may be a redundancy in the script for you, but for some people it improves readability. Also, I am quite aware that the Graal Engine does have optimizations done on scripts, which means that both cases would work out to the same thing (exactly what I have been saying all along.)
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
  #51  
Old 05-29-2006, 02:08 PM
Tyrial Tyrial is offline
The Shiznic
Join Date: Dec 2001
Location: Sweden > Stockholm
Posts: 2,411
Tyrial is an unknown quantity at this point
ApothiX:

Listen man, I don't care if it's wrong or right, if it works or not.

IT IS STUPID!


if (onwall() == true) is exactly the same thing as if (true == true).

If that is correct, why don't you continue to do:

if ((((((onwall() == true) == true) == true) == true) == true) == true)

It's the exact same thing.

Silence.
__________________
-Mher Avetian
  #52  
Old 05-29-2006, 02:13 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Tyrial
if (onwall() == true) is exactly the same thing as if (true == true).
Not if onwall() is returning false.
Quote:
Originally Posted by Tyrial
If that is correct, why don't you continue to do:

if ((((((onwall() == true) == true) == true) == true) == true) == true)

It's the exact same thing.
Why the hell would you continue to do that?

That is called wasting time, space and energy. Besides, it is not exactly the same since you are making the engine evaluate the statement six times. I do not think it will fold that down.
__________________
Skyld
  #53  
Old 05-29-2006, 03:56 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
This thread is getting stupid :x
__________________
Follow my work on social media post-Graal:Updated august 2025.
  #54  
Old 05-29-2006, 04:33 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Tyrial
ApothiX:

Listen man, I don't care if it's wrong or right, if it works or not.

IT IS STUPID!


if (onwall() == true) is exactly the same thing as if (true == true).

If that is correct, why don't you continue to do:

if ((((((onwall() == true) == true) == true) == true) == true) == true)

It's the exact same thing.

Silence.
Then stop bumping it, you dip****.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
  #55  
Old 05-29-2006, 11:10 PM
Tyrial Tyrial is offline
The Shiznic
Join Date: Dec 2001
Location: Sweden > Stockholm
Posts: 2,411
Tyrial is an unknown quantity at this point
Quote:
Originally Posted by Skyld
Not if onwall() is returning false.
Yeah well I ment if it's returning true, but you knew that allready didn't you? You just wanted to act all smart. Bravo, you get a cookie.

Quote:
Originally Posted by Skyld
Why the hell would you continue to do that?

That is called wasting time, space and energy.
No ****! That's like exactly what I mean.

If you think that ((((true == true) == true) == true) == true) is a waste, then you must think the same about (onwall() == true) because that is like (true == true).

In other words, he did:
if (true == true) //Waste.
instead of:
if (true) //Not waste.


Quote:
Besides, it is not exactly the same since you are making the engine evaluate the statement six times. I do not think it will fold that down.
So? It's only needed to get a value from the boolean ONCE, after that it's a waste, whether it's twice or more, it's the same crappy code.
__________________
-Mher Avetian
  #56  
Old 05-29-2006, 11:21 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Tyrial
Yeah well I ment if it's returning true, but you knew that allready didn't you? You just wanted to act all smart. Bravo, you get a cookie.



No ****! That's like exactly what I mean.

If you think that ((((true == true) == true) == true) == true) is a waste, then you must think the same about (onwall() == true) because that is like (true == true).

In other words, he did:
if (true == true) //Waste.
instead of:
if (true) //Not waste.




So? It's only needed to get a value from the boolean ONCE, after that it's a waste, whether it's twice or more, it's the same crappy code.
Please tone down when posting in my forum, okay?
__________________
Skyld
  #57  
Old 05-29-2006, 11:34 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Tyrial
In other words, he did:
if (true == true) //Waste.
instead of:
if (true) //Not waste.
You're forgetting three crucial words: IN YOUR OPINION. As I have stated before, some people prefer onwall() == true because it helps them to read it better. Christ. Skyld can you please close this thread because honestly these people are replying without even reading it.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
  #58  
Old 05-30-2006, 12:22 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Topic is causing problems.

Closed.
__________________
Skyld
Closed Thread


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:04 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.