I'm having problems with this script.

Started by
12 comments, last by Rain Dog 19 years, 5 months ago

void main()
{
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    //NavigationlControl[PWToGuild]
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    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]
Advertisement
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.
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

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.
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.
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

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))]*

instead of

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
//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]
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.
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

This topic is closed to new replies.

Advertisement