Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-18-2003, 03:36 AM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
_indexof2

Make a second version of all the _indexof functions such that they are CaSE seNsItIVE.
__________________


Help me keep scripting
Reply With Quote
  #2  
Old 09-18-2003, 09:00 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Hmm. I'm sure it has many uses, but I can't seem to think of any...
__________________
Reply With Quote
  #3  
Old 09-18-2003, 06:38 PM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
Well, the base 64 system Stefan created to deal with storing tiles is case sensitive.
__________________


Help me keep scripting
Reply With Quote
  #4  
Old 09-19-2003, 04:30 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally posted by TribulationStaff
Well, the base 64 system Stefan created to deal with storing tiles is case sensitive.
So?
__________________
Reply With Quote
  #5  
Old 09-19-2003, 05:02 AM
Goboom Goboom is offline
Pixel Monkey
Goboom's Avatar
Join Date: Dec 2001
Location: Michigan
Posts: 1,702
Goboom is on a distinguished road
Send a message via ICQ to Goboom Send a message via AIM to Goboom Send a message via MSN to Goboom Send a message via Yahoo to Goboom
Quote:
Originally posted by Kaimetsu
Hmm. I'm sure it has many uses, but I can't seem to think of any...
The only thing I can think of is maybe a password system thing or some sort of tile editor type deal, may be wrong but hey I think outside the box.
__________________
Reply With Quote
  #6  
Old 09-19-2003, 06:15 AM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
Quote:
Originally posted by Kaimetsu


So?
So Jagen asked me to script the conversion for him, and the most efficient way I could think of included indexof to calculate the values of the letters.
__________________


Help me keep scripting
Reply With Quote
  #7  
Old 09-19-2003, 06:42 AM
-Ramirez- -Ramirez- is offline
Registered User
Join Date: Jun 2002
Location: USA, Ohio
Posts: 729
-Ramirez- has a spectacular aura about-Ramirez- has a spectacular aura about
Quote:
Originally posted by Kaimetsu
Hmm. I'm sure it has many uses, but I can't seem to think of any...
It could be quite useful for the upcoming 3.1 that has editboxes and things.
__________________
Kat
Reply With Quote
  #8  
Old 09-19-2003, 07:08 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally posted by TribulationStaff
So Jagen asked me to script the conversion for him, and the most efficient way I could think of included indexof to calculate the values of the letters.
That's the most efficient way you could think of? Shame on you.
__________________
Reply With Quote
  #9  
Old 09-19-2003, 08:01 AM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
I am positive indexof is a far cry more efficient that a ton of ifs trying to figure out the decimal value of the letter.
__________________


Help me keep scripting
Reply With Quote
  #10  
Old 09-19-2003, 08:13 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally posted by TribulationStaff
I am positive indexof is a far cry more efficient that a ton of ifs trying to figure out the decimal value of the letter.
You wouldn't need 'a ton' if you coded it correctly.
__________________
Reply With Quote
  #11  
Old 09-20-2003, 06:37 AM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
Still, far better 1 line as opposed to 64 virtually identical if clauses

I can create a string, call it this.values, and arrange all the characters such that their position in the string is their decimal value. However, for this to work right, indexof needs to differentiate between G and g.

Since I don't have access to v3 engine, I can't do a switch statement, which would still be quite a bit longer. So, I am stuck with
NPC Code:

if (strequals(A,#e(blah)))
{
this.decimal+=blah;
}


over and over again
__________________


Help me keep scripting
Reply With Quote
  #12  
Old 09-20-2003, 06:47 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally posted by TribulationStaff
Still, far better 1 line as opposed to 64 virtually identical if clauses
I already said you wouldn't need many. Three, perhaps? Maybe four.

Quote:
I can create a string, call it this.values, and arrange all the characters such that their position in the string is their decimal value. However, for this to work right, indexof needs to differentiate between G and g.
Yes, or you could use an efficient method.
__________________
Reply With Quote
  #13  
Old 09-21-2003, 03:17 AM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
Would you care to explain how three to four ifs could allow me to convert one of 64 characters into their decimal equivalents?

Secondly, how is it at all inefficient to condense those ifs into a single indexof?
__________________


Help me keep scripting
Reply With Quote
  #14  
Old 09-21-2003, 03:36 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally posted by TribulationStaff
Would you care to explain how three to four ifs could allow me to convert one of 64 characters into their decimal equivalents?
You'd obviously need a little more code as well; the if-statements would merely divide the characters into ranges. After that, it would be a simple matter of arithmatic.

Quote:
Secondly, how is it at all inefficient to condense those ifs into a single indexof?
Please tell me you're not one of those people who thinks that shortness of script == efficiency.
__________________
Reply With Quote
  #15  
Old 09-21-2003, 03:45 AM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
So, you admit, you just aren't adding three ifs, you are adding other things. And these "ranges" how would you define them?

As for the length of the script, no, I think it is a lot more efficient to say "where is it located?" than several "is it this? No? Well is it that?"

indexof may start to be a less efficient piece of code when used 10000 times; but, from what I have seen of differences in efficiency at this level of iteration, I doubt that it's going to be a problem.
__________________


Help me keep scripting
Reply With Quote
  #16  
Old 09-21-2003, 03:55 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally posted by TribulationStaff
So, you admit, you just aren't adding three ifs, you are adding other things.
It's not an 'admission'. Obviously it would require more than three ifs; if there's no code inside the structures then what would be the point? The difference is that the code inside would be simple and efficient.

Quote:
And these "ranges" how would you define them?
Primary two: A-Z and a-z

Quote:
As for the length of the script, no, I think it is a lot more efficient to say "where is it located?" than several "is it this? No? Well is it that?"
Then you don't really understand scripting yet. Searching a string for a value is the act of repeatedly checking values.

Quote:
indexof may start to be a less efficient piece of code when used 10000 times; but, from what I have seen of differences in efficiency at this level of iteration, I doubt that it's going to be a problem.
1) Efficiency isn't based on scale. Your approach is less efficient, even if the difference between singular executions is only a couple of nanoseconds.
2) When used 10,000 times, huh? Tell me, what are you going to do with this base64 stuff? Could it be that you intend to iterate through 4096 tile specifications?
__________________
Reply With Quote
  #17  
Old 09-21-2003, 04:23 AM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
Quote:
Primary two: A-Z and a-z
And how will you tell if something is in these ranges without something that is case sensitive?

Quote:
2) When used 10,000 times, huh? Tell me, what are you going to do with this base64 stuff? Could it be that you intend to iterate through 4096 tile specifications?
Well, let me put it this way. Let us say that each time I use it, a nanosecond or three elapses. That is 1E-9 seconds. 1E4 times that nanosecond is still less than a second. Not bad for a only seldom, in computer time, used bit of code.
__________________


Help me keep scripting
Reply With Quote
  #18  
Old 09-21-2003, 04:28 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally posted by TribulationStaff
And how will you tell if something is in these ranges without something that is case sensitive?
Hint: Every letter has an ASCII value

Quote:
Well, let me put it this way. Let us say that each time I use it, a nanosecond or three elapses. That is 1E-9 seconds. 1E4 times that nanosecond is still less than a second. Not bad for a only seldom, in computer time, used bit of code.
*shrugs*

If you want to try to justify bad code then be my guest. Perhaps you don't realise the greater consequences.
__________________
Reply With Quote
  #19  
Old 09-21-2003, 04:39 AM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
Quote:
Hint: Every letter has an ASCII value
Isn't that exactly what indexof would use? Except for the fact that, as is, indexof uses either the toupper or tolower of the characters to ignore case.

It really sounds as if you want to do something very similar to what I am doing except in pieces rather than just in one step.
__________________


Help me keep scripting
Reply With Quote
  #20  
Old 09-21-2003, 05:01 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally posted by TribulationStaff
Isn't that exactly what indexof would use?
Yep. But there's more than one way to use something.

Quote:
It really sounds as if you want to do something very similar to what I am doing except in pieces rather than just in one step.
Either because you don't understand what indexof does or you can't see what I'm suggesting.

Indexof examines each character of the source string, looking for a match between it and the argument you provide. One by one. Like 64 little ifs.

That's not what I'm suggesting.

Once you've divided the string into ranges, you can do all the numerical manipulation with a couple of elements of arithmatic.
__________________
Reply With Quote
  #21  
Old 09-21-2003, 05:21 AM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
Quote:
Once you've divided the string into ranges, you can do all the numerical manipulation with a couple of elements of arithmatic.
I'm not seing how you are going from letters to arithmatic. You'd still need some sort of conversion.
__________________


Help me keep scripting
Reply With Quote
  #22  
Old 09-21-2003, 05:22 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally posted by TribulationStaff
I'm not seing how you are going from letters to arithmatic. You'd still need some sort of conversion.
To a computer, letters are just numbers.
__________________
Reply With Quote
  #23  
Old 09-21-2003, 05:38 AM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
Ah. I see ASCII value. Hrm.

Yeah you could do it that way.

Doesn't seem very versatile. My way, to change the system, you just change the string. Your way, you'd have to rearrange all the ifs. Sure, I'm being hypothetical here, but there it is.
__________________


Help me keep scripting
Reply With Quote
  #24  
Old 09-21-2003, 05:40 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally posted by TribulationStaff
Yeah you could do it that way.

Doesn't seem very versatile. My way, to change the system, you just change the string.
Mm-hmm. You planning on redefining base64 any time soon?
__________________
Reply With Quote
  #25  
Old 09-21-2003, 06:10 AM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
No, but suppose I want to create my own encryption system? It would be a piece of cake to tweak the code I already have.

You might say I am the scripting world's answer to Junkyard Wars (Scrapheap Challenge in UK). I love cannibalizing code.
__________________


Help me keep scripting
Reply With Quote
  #26  
Old 09-21-2003, 07:19 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally posted by TribulationStaff
No, but suppose I want to create my own encryption system? It would be a piece of cake to tweak the code I already have.
That's not a particularly good justification. If you forever cannibalise from the past simply to save yourself effort then:

1) Your scripts will be less efficient as a result.
2) You won't consider all the possible approaches; you'll automatically choose one that involves some previous script.
__________________
Reply With Quote
  #27  
Old 09-21-2003, 07:41 AM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
Clearly I don't cannibalize everything, or I wouldn't need new functions. I just like cannibalizable code. Everything worth coding has multiple uses.
__________________


Help me keep scripting
Reply With Quote
  #28  
Old 09-21-2003, 07:49 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally posted by TribulationStaff
Clearly I don't cannibalize everything, or I wouldn't need new functions. I just like cannibalizable code. Everything worth coding has multiple uses.
Even if that were true, it's antithetical to the practice of coding something more poorly just so that it can be reused.
__________________
Reply With Quote
  #29  
Old 09-21-2003, 07:52 AM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
Wait a second. Are you straw-manning?

In your opinion, more poorly. Yes. In the opinion of the computer science world, sure. In my mind, more versatile is better than more precise. I am willing to sacrifice efficiency on a small scale to make the script more useful
__________________


Help me keep scripting
Reply With Quote
  #30  
Old 09-21-2003, 08:07 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally posted by TribulationStaff
Wait a second. Are you straw-manning?
Not at all. A strawman is an aesthetically-similar-but-different argument or stance. I'm not making any pretense regarding your position on this issue, I'm merely describing it in my own words. To call a practice poor isn't straw-manning, it's just analysing.

Quote:
In your opinion, more poorly. Yes. In the opinion of the computer science world, sure. In my mind, more versatile is better than more precise. I am willing to sacrifice efficiency on a small scale to make the script more useful
As would most computer scientists, but the difference is that your code is much less efficient. You seem to be misinterpreting the main issue here. Coding efficiently isn't merely about making a single routine run 0.01 seconds faster. It's about challenging oneself to find better ways to solve a problem, to analyse his own code from an objective standpoint. If you don't do that then, as has been shown in this thread, you don't consider all the options.

A good coder isn't somebody who uses a hammer and crowbar to wedge his old code into somewhere it doesn't fit. A good coder designs each solution to fit a single problem, and draws on old creations only when they match the design he crafts beforehand.
__________________
Reply With Quote
  #31  
Old 09-21-2003, 07:02 PM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
Lol. This is why I am a mathematician instead of a computer scientist. But you have to admit, I don't do too badly for only taking one class.

On the other hand, I wouldn't exactly call it hammering a square peg into a round hole. It's more like I like to use clay pegs.

Let me give you an example. I coded a window display routine for SA. This code allowed Soul to make the window any size he wanted, within reason. After finishing that, I realised that the script had other potential. I converted it from an image tiler to a tile tiler. In the matter of about two minutes I had created a whole new use for the same script.
__________________


Help me keep scripting
Reply With Quote
  #32  
Old 09-22-2003, 05:04 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally posted by TribulationStaff
Lol. This is why I am a mathematician instead of a computer scientist. But you have to admit, I don't do too badly for only taking one class.
Well, programming is all about practice. Any talented programmer teaches himself 90% of what he knows.

Quote:
Let me give you an example. I coded a window display routine for SA. This code allowed Soul to make the window any size he wanted, within reason. After finishing that, I realised that the script had other potential. I converted it from an image tiler to a tile tiler. In the matter of about two minutes I had created a whole new use for the same script.
That's not the same thing. That's taking inspiration from something you've previously made, and turning it into something more. I'm talking about coding using a design implicitly created with the goal of being portable - especially when the code involved is so tiny.
__________________
Reply With Quote
Reply


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 12:37 PM.


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