Clone numbering

Non-platform specific questions.

Clone numbering

Postby digiot » Wed Feb 18, 2015 6:04 pm

Hi !

There are 2 questions I have about actor-clones and their numbering system :

1) Is their any limit, e.g. 256 ( actor.0 - actor.255 ), how many clones of
an actor you can have ?

2) When you have destroyed some of the clones, there are gaps in the clones list.
Afaik, GE only expands the list, always using the last clone +1 in the "CreateActor"
function.
Is there a way, to use destroyed clones ( getclone-output -1 and "" ) in the list
for newly created clones ?
Imagine, when you have shot clones, which you are destroying and creating all the
time, GE has sooner or later to deal with large clone numbers.
Idk, if this can become a real performance issue ?
Or maybe, this is not the right way, to handle shots ?
My idea for an alternative way is, just to position the finished shots out of the
view, and marking them as "free for use".


Cheers !
User avatar
digiot
 
Posts: 211
Joined: Sat Mar 17, 2012 2:29 pm
Score: 7 Give a positive score

Re: Clone numbering

Postby skydereign » Thu Feb 19, 2015 5:52 am

digiot wrote:1) Is their any limit, e.g. 256 ( actor.0 - actor.255 ), how many clones of
an actor you can have ?

The cloneindex variable is a long so 2147483647 I believe.

digiot wrote:2) When you have destroyed some of the clones, there are gaps in the clones list.
Afaik, GE only expands the list, always using the last clone +1 in the "CreateActor"
function.
Is there a way, to use destroyed clones ( getclone-output -1 and "" ) in the list
for newly created clones ?
Imagine, when you have shot clones, which you are destroying and creating all the
time, GE has sooner or later to deal with large clone numbers.
Idk, if this can become a real performance issue ?
Or maybe, this is not the right way, to handle shots ?
My idea for an alternative way is, just to position the finished shots out of the
view, and marking them as "free for use".

gE creates clones by taking the index of the clone with the highest index and increasing it by 1. That means that you can get lower cloneindexed numbers, but you have to delete the higher indexed clones first. Allowing gE to create clones with the free indexes has been something I've considered adding, but I do like the fact that any Create Actor event will guarantee that that is the highest indexed clone, which is helpful for a bunch of things.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Clone numbering

Postby digiot » Fri Feb 20, 2015 2:06 pm

skydereign wrote:The cloneindex variable is a long so 2147483647 I believe.

Ok, that should be enough for a while...
skydereign wrote:gE creates clones by taking the index of the clone with the highest index
and increasing it by 1. That means that you can get lower cloneindexed numbers,
but you have to delete the higher indexed clones first. Allowing gE to create
clones with the free indexes has been something I've considered adding, but I do
like the fact that any Create Actor event will guarantee that that is the highest
indexed clone, which is helpful for a bunch of things.

So, limiting the amount of clones is recommended ?
Or is the ressource hogging for reading large lists insignificant ?
Idk, how the computing of large types is carried out.
But only using 8-bit (0-255) should gain some speed, traversing the index ?


Cheers !
User avatar
digiot
 
Posts: 211
Joined: Sat Mar 17, 2012 2:29 pm
Score: 7 Give a positive score

Re: Clone numbering

Postby Hares » Fri Feb 20, 2015 5:58 pm

digiot wrote:Imagine, when you have shot clones, which you are destroying and creating all the
time, GE has sooner or later to deal with large clone numbers.

If you are using a lot of shot actors, maybe it is better to use an object pool pattern.
http://en.wikipedia.org/wiki/Object_pool_pattern

This allows you to reduce the number of clones and to reduce the number of create actor events.
User avatar
Hares
 
Posts: 105
Joined: Fri Dec 20, 2013 8:39 pm
Location: Belgium
Score: 14 Give a positive score

Re: Clone numbering

Postby digiot » Fri Feb 20, 2015 6:07 pm

@Hares :
That's exactly what I've meant with my "alternative way", never heard about
"object pool pattern" before, now I've learned something new, +1 !


Cheers !
User avatar
digiot
 
Posts: 211
Joined: Sat Mar 17, 2012 2:29 pm
Score: 7 Give a positive score

Re: Clone numbering

Postby bat78 » Thu Jul 30, 2015 12:47 pm

You can encounter the limit of any variable.

To determine the LENGTH of a variable, create a text actor and in Create Actor add this code:

Code: Select all
sprintf(text, "2 (^%i) = ? - 1", sizeof(cloneindex) * 8);

Execute/Test the game, get a calculator and calculate what is given.
Game-Editor std function sprintf will not allow printing int/uint64s. (on windows that I know).

To calculate the RANGE, simply do this
Code: Select all
sprintf(text, "(2 (^%i)) / 2 = -?  to (2 (^%i)) / 2 = +? - 1", sizeof(cloneindex) * 8, sizeof(cloneindex) * 8);
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: Clone numbering

Postby digiot » Thu Jul 30, 2015 9:16 pm

@ bat78 : Thanks, but that is not what I wanted to know.

Since the clonenumber is an integer, it will take 4 bytes in memory.

For any calculation with it, the cpu takes one byte after the other, interpreting
it according to the Endian-mode in use.

But what will happen here, if really only the lowest byte has some value, the other
3 bytes not being in use, i.e. if the clonenumber in this case is limited up to 255 ?

Can the cpu perform a kind of shorter/faster calculation with 8-bit values, than with
larger ones ?

That's, what I'm curious about !


Cheers !
User avatar
digiot
 
Posts: 211
Joined: Sat Mar 17, 2012 2:29 pm
Score: 7 Give a positive score

Re: Clone numbering

Postby bat78 » Thu Jul 30, 2015 9:47 pm

I saw different things in your OP.

First of all, int is not always necessarily to be 4 bytes. It is:
1. Compiler Specific
2. System architecture specific
While this compiler puts them in 4 bytes, on some 8 or 16 bit systems, it may be 2 bytes.

Second, everything is in BITS, not in bytes.. compilers never account something byte by byte.

Also no, there are no performance differences, the compiler is smart enough to optimize it (and 4 byte value will be parsed in 32 bits despite the value it represents)
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: Clone numbering

Postby digiot » Thu Jul 30, 2015 10:03 pm

bat78 wrote:First of all, int is not always necessarily to be 4 bytes. It is:
1. Compiler Specific
2. System architecture specific
While this compiler puts them in 4 bytes, on some 8 or 16 bit systems, it may be 2 bytes.

Yes, I know. But I don't believe, GE is running on any such system anywhere.
bat78 wrote:Also no, there are no performance differences, the compiler is smart enough to optimize it (and 4 byte value will be parsed in 32 bits despite the value it represents)

That's, what I wanted to know ! So the compiler is setting the rules, ok.
+1

Cheers !
User avatar
digiot
 
Posts: 211
Joined: Sat Mar 17, 2012 2:29 pm
Score: 7 Give a positive score

Re: Clone numbering

Postby bat78 » Thu Jul 30, 2015 10:11 pm

Yeah and gE uses an interpreter, but compiler however this is another topic.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: Clone numbering

Postby digiot » Thu Jul 30, 2015 11:12 pm

GE is using an interpreter ? That's totally new for me.

Ok, exactly asked: How does GE internally handle integer calculations,
when the values are only 8 bit large ?
Is GE also so "smart", to use the full bandwith of 32 bits for 8 bit calculations ?
User avatar
digiot
 
Posts: 211
Joined: Sat Mar 17, 2012 2:29 pm
Score: 7 Give a positive score

Re: Clone numbering

Postby bat78 » Fri Jul 31, 2015 6:08 am

Yes, gE's Script Editor is based on EiC, which stands for "Extensible, Interactive C-interpreter". It is a complete and clean ANSI-C Interpreter.

How does "gE" handle integer calculations - too broad to answer
but just like any other C-interpreter does, it parses one statement at a time.

char is 1 byte (8 bits). Since char is signed by default it has a range of negative to positive value and it's MSB is 64
while unsigned char (aka "byte") stores in the range of 0 - 255 so the MSB is 128
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: Clone numbering

Postby songramislam12 » Tue Aug 25, 2015 4:29 pm

Very nice post. it is very helpful for me.
songramislam12
 
Posts: 2
Joined: Fri Aug 21, 2015 2:26 am
Location: Dhaka, Bangladesh
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron