• Create Account

## I'm having problems with this script.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

13 replies to this topic

### #1Rain Dog  Members

Posted 26 October 2004 - 10:56 AM

void main()
{
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
IntArray array(2);
IntArrayArray PWToGuild(26)
array[0] = 121; array[1] = 196;PWToGuild[0] = array;
array[0] = -120; array[1] = 193;PWToGuild[1] = array;
array[0] = -120; array[1] = 187;PWToGuild[2] = array;
array[0] = -122; array[1] = 181;PWToGuild[3] = array;
array[0] = -125; array[1] = 176;PWToGuild[4] = array;
array[0] = -128; array[1] = 170;PWToGuild[5] = array;
array[0] = -131; array[1] = 164;PWToGuild[6] = array;
array[0] = -133; array[1] = 159;PWToGuild[7] = array;
array[0] = -135; array[1] = 153;PWToGuild[8] = array;
array[0] = -137; array[1] = 148;PWToGuild[9] = array;
array[0] = -140; array[1] = 142;PWToGuild[10] = array;
array[0] = -142; array[1] = 137;PWToGuild[11] = array;
array[0] = -145; array[1] = 131;PWToGuild[12] = array;
array[0] = -148; array[1] = 126;PWToGuild[13] = array;
array[0] = -151; array[1] = 121;PWToGuild[14] = array;
array[0] = -155; array[1] = 116;PWToGuild[15] = array;
array[0] = -160; array[1] = 112;PWToGuild[16] = array;
array[0] = -165; array[1] = 108;PWToGuild[17] = array;
array[0] = -170; array[1] = 105;PWToGuild[18] = array;
array[0] = -176; array[1] = 102;PWToGuild[19] = array;
array[0] = -181; array[1] = 99; PWToGuild[20] = array;
array[0] = -187; array[1] = 97; PWToGuild[21] = array;
array[0] = -190; array[1] = 92; PWToGuild[22] = array;
array[0] = -191; array[1] = 88; PWToGuild[23] = array;
array[0] = -191; array[1] = 69; PWToGuild[24] = array;
array[0] = -178; array[1] = 70; PWToGuild[25] = array;
return;
}


I have a script that is similar to the one above in every aspect except that it is 900 lines longer, and the build time on it is so long that it never finishes. Lastly, is there a way for me to declare an array of arrays with AS? Hence, an int[] Myarray(5); int&[] MyArrayofArrays(5); [Edited by - Rain Dog on October 26, 2004 5:25:22 PM]

### #2Deyja  Members

Posted 26 October 2004 - 12:09 PM

You could declare an array of registered vectors. :D

I'm afraid the suggestion I gave you in IMs won't help with the build problem. Even if you break the file into multiple sections, it still has to be built all at once.

### #3Andreas Jonsson  Moderators

Posted 26 October 2004 - 01:38 PM

Multidimensional arrays will be supported in a future version, maybe 1.10.0 WIP 6, maybe later. You will be able to declare them as:

int[][] array2D(3); // array of 3 elements of type int[]

An array like this can be initialized as:

for( int n = 0; n < array2D.length(); n++ )
{
int[] array(3);
array2D[n] = array;

// Or possibly
array2D[n] = int[](3);
}

Your function seems to be building paths in some sort of map, right? If I were you I would put this in a file, or possibly a string parsed by a C function, and make an API for loading that file in the script.

I will in the future allow initialization of arrays with an initialization list like

int[] array = {12, 2134, 23, 12, 32};

but that will not be finished in a while yet.

I will look into why your script takes so much time to compile. I think a script of a thousand lines shouldn't take that much time, it is probably a bug that makes it take that long.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

### #4Rain Dog  Members

Posted 26 October 2004 - 02:12 PM

I changed the script to be in this form:

    StringArray PWToGuild(26) ;//face 82    //reverseable   PWToGuild[0] = "121,196";   PWToGuild[1] = "-120,193";   PWToGuild[2] = "-120,187";   PWToGuild[3] = "-122,181";

And that seemed to help a little bit, but the entire script is still not compilable, I let it try to build for a few minutes. As far as PC Memory usage is involved, the process went like this:

200-400mb memory consumption for 30 se3conds
slow drop down to 8mb took about a minute.
slow climb back up to 300mb took 2 minutes.

Then i terminated the program.

Interestingly, using a vector<string> object of type StringArray as in the above example will compile a shorter version of the one i wish to compile in about 1/3rd of the time that it takes to build the same script declared as a string[] array.

### #5Rain Dog  Members

Posted 26 October 2004 - 04:34 PM

I attempted to let the script finish the build process and it did not finish after approximately 20 minutes of execution.

I do not know what the problem is with the slow up, but it occurs during the building of the script.

The build and execution of the following script is on the order of 2 seconds:

void main() {    StringArray MyString;    for(int i = 0; i < 1000000; i++) {        MyString.push_back("Hello" + i);     }}

And suffers no problems.

### #6Andreas Jonsson  Moderators

Posted 27 October 2004 - 02:56 AM

I will investigate this as soon as possible.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

### #7Aggrav8d  Members

Posted 27 October 2004 - 12:29 PM

I suppose the trivial solution as writing everything in a single dimension array was rejected for a good reason? indexing

one[((a<<1)+(b&0x1))]*

two[(a)][(b)]*

may not be fun but it isn't THAT bad.

*(assumes the second array is only 2 units long)

Dan Royer, OwnerMarginally Clever Games

### #8Rain Dog  Members

Posted 27 October 2004 - 01:12 PM

//segment one://///////////////////////////////////////////////    StringArray PWToGuild(26) ;//face 82    //reverseable   PWToGuild[0] = "121,196";   PWToGuild[1] = "-120,193";   PWToGuild[2] = "-120,187";   PWToGuild[3] = "-122,181";

Using the above method or the below method

    string[] PWToGuild(26) ;//face 82    //reverseable   PWToGuild[0] = "121,196";   PWToGuild[1] = "-120,193";   PWToGuild[2] = "-120,187";   PWToGuild[3] = "-122,181";

Still creates an entirely unbuildable script.

The following script builds and executes in around 5 seconds:
void main() {	for(int i = 0; i < 1000; i++) {		StringArray MyString(50);		for(int j = 0; j < 100; j++)			MyString.push_back("Hello" + i);		StringArray MyString1(50);		for(int j = 0; j < 100; j++)			MyString1.push_back("Hello" + i);		StringArray MyString2(50);		for(int j = 0; j < 100; j++)			MyString2.push_back("Hello" + i);	}}

It just appears to be a case of parsing a long script with many commands. Clearly the above script has more declarations and executions than what the script i want to execute has.

My script has a total of 22 variables, in the form of segment one above, with consisiting of approximately 1000 total assignments. Clearly the above script consists of many many many times more instructions than what my script consists of.

UPDATE::

If i put the script in this form:
   StringArray PWToGuild(26) ;//face 82    //reverseable   PWToGuild.push_back("121,196"    );   PWToGuild.push_back("-120,193"   );

The entire 1000 lines of script builds and executes in about 30 seconds. So that at least gives me the option of building once and saving byte code for later user.
PWToGuild.push_back("-120,187" );

[Edited by - Rain Dog on October 27, 2004 8:12:20 PM]

### #9Rain Dog  Members

Posted 02 November 2004 - 10:58 AM

The script in the first post of this thread now executes in its full 1000 line version in about 2.5 seconds, which is entirely liveable.

I used todays release and use the following variable types and got roughly the same results.

int[] array(2);
int[][] BigArray(26);

and

IntArray array(2);
IntArrayArray BigArray(26);

I have also seen some performance increase with using strings to declare the above variables, but the perfomance using strings tajkes around 20 seconds to build the script.

### #10Andreas Jonsson  Moderators

Posted 02 November 2004 - 11:26 AM

That is very good to hear.

However, even with the problem fixed I will put some effort into improving the compile times. There are plenty of places where I know the compiler does some incredibly unefficient stuff, examples such as dynamically allocating temporary buffers call, and doing linear searches with strings are unfortunately quite common in the code. The constant strings can also be greatly improved using hash tables to find duplicates.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

### #11Rain Dog  Members

Posted 03 November 2004 - 07:44 AM

When you have been working on improving the speed and optimizing the engine, have the optimizations and speed improvements been mainly in the execution of the script or have they taken place all around?

### #12Andreas Jonsson  Moderators

Posted 03 November 2004 - 09:28 AM

So far I've basically only worked on optimizing the execution speed, which is obviously the most important part.

I promise that for the next release the compilation speed will be improved as well (I can't promise how much though [wink]).

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

### #13Andreas Jonsson  Moderators

Posted 10 November 2004 - 04:09 AM

I'm pleased to announce that the next WIP will have build times about 10 times shorter than previous versions. This may of course depend on the size of the script, where larger scripts get better improvements.

Your script may take as little as 0.25 seconds to compile now.

This increase in performance was because of one function. asCScriptCode::ConvertPosToRowCol(). I had made an incredibly naïve implementation, that simply took the character position in the script code and counted the number of lines to that position. Now I precalculate the positions of each line, and do a binary search in this list of lines to find the line where the position is located.

I also wanted to take the opportunity to do a little commercial for an excellent profiler tool that I used to help me find this: LTProf. It's very easy to use.

I will make another tests with strings and see how I can improve the performance for them. Though I think I know the solution already: The string constants needs to be stored in a hash tree (or something similar) so that when a string constant is created it doesn't have to compare each and every other string constant to determine if it already exists.

Let me know if there are any other situations where the performance is too low. This way I will be able to optimize those as well.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

### #14Rain Dog  Members

Posted 10 November 2004 - 08:11 AM

this is very exciting for me!!

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.