• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Rain Dog

I'm having problems with this script.

13 posts in this topic

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]
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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


0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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)
0

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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?
0

Share this post


Link to post
Share on other sites
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]).

0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0