Gamestudio Links
Zorro Links
Newest Posts
Lapsa's very own thread
by Lapsa. 06/08/26 22:41
Stooq now requires an API key
by VHX. 06/08/26 20:14
ZorroGPT
by TipmyPip. 06/06/26 12:36
Zorro 3.01 recoded MMI function issue
by TipmyPip. 06/04/26 05:44
SGT_FW
by Aku_Aku. 05/31/26 11:05
Issues resuming trades on Demo account
by Martin_HH. 05/22/26 13:31
XTB
by pr0logic. 05/18/26 12:27
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (AndrewAMD), 2,372 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Seraphinang, Koti, curry, DeepxKalsi, Samed
19219 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 8 1 2 3 4 5 6 7 8
Re: Aum 104 [Re: darkinferno] #392205
01/20/12 08:00
01/20/12 08:00
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
Quad Online
Senior Expert
Quad  Online
Senior Expert

Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
Thanks George!

I totally agree with rules Christian suggested.


3333333333
Re: Aum 104 [Re: Rackscha] #392207
01/20/12 08:35
01/20/12 08:35
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Rakscha,

both of your examples are considered to be one Logical Source Lines of Code (LSLOC), which was the measure back then in the previous lines of code contest in 2007.

Quote:
What counts for a line?


This is from Wikipedia: "Logical SLOC attempts to measure the number of executable 'statements', but their specific definitions are tied to specific computer languages (one simple logical SLOC measure for C-like programming languages is the number of statement-terminating ***semicolons***).", see here.

So, if you have 200 or less semicolons, it is OK. That is why there is KB-limitation as well.

I had very much fun back then, I made a7titude; but it seems to me that most people, who liked it, had problems with the sourcecode (click here) for one particular reason:

1) function nesting - instead of writing several lines of functions you can pack them together to "abuse" their return values as argument in the next, enclosing function.

For example, the following code makes the my entity look to the you entity, while turning around the z-axis; this is pretty easy:

Code:
VECTOR v;
vec_diff(&v, you->x, my->x);
vec_to_angle(my->pan, &v);
my->roll = 0;



This can be reduced in 3 steps into one logical line of code, with the very exact same functionality:

A) Instead of using the static vector in vec_diff, you could replace it with a temporary one:

Code:
VECTOR* v = vec_diff(vector(0,0,0), you->x, my->x);
vec_to_angle(my->pan, v);
my->roll = 0;



B) vec_diff returns the modified vector, which is the VECTOR* pointer as was inserted as first argument (the vector(0,0,0) statement); so we could just insert the whole vec_diff statement into vec_to_angle:

Code:
vec_to_angle(my->pan, vec_diff(vector(0,0,0), you->x, my->x));
my->roll = 0;



C) vec_to_angle doesn't either return a VECTOR* or an ANGLE* pointer, but a var, which contains the length of the vector. Since we are assigning a value to my->roll, we can abuse this value and multiply it with 0, to make sure that the roll of the my entity becomes zero:

Code:
my->roll = vec_to_angle(my->pan, vec_diff(vector(0,0,0), you->x, my->x)) * 0;



2) After I made sure that I fulfil the lines of code restriction, I had trouble with the filesize. So, the other trick I used was using macro replacements: often used instructions were replaced through short macros.

Imagine your code has lots of wait(1); statements, lets say 50. The string "wait(1)" (without the semicolon) has 7 characters (=7 Bytes), x 50 occurences you have 350 characters -- this makes 350 Bytes for the "wait(1)" strings in your textfile (not including the semicolons!). Now, if you use the following macro at the beginning of your code:

Code:
#define XX wait(1)



and replace all strings "wait(1)" with "XX", you now have 2 Bytes x 50 occurences = 100 Bytes, plus 18 Bytes from the macro definition, a total of 118 Bytes, which is ~34% of the code you used before; you saved a total of 232 Bytes.

You may think "why should I do this?" - well, first of all, this is fun smile second, if you left the filesize limit, it helps you especially when you are using one or two functions regularily (other candidates are the vec_ functions, c_move and the like. In some cases certain pattern became visible to me and I even made macros to merge two other macros. The full macro list I used in a7titude is this one:

Code:
#define MENU "mainmenu.wmb"
#define A7 while
#define WT wait
#define VS vec_set
#define VG vector
#define K skill
#define J my
#define VI VISIBLE
#define CM camera
#define Z if
#define ID skill1
#define VV VECTOR
#define RE return
#define SP snd_play
#define MM mouse_map
#define NL NULL
#define VD void
#define X )))
#define Q {}
#define SW s(WT(1))
#define JK J.K
#define JI J.ID
#define JV JK[99]/100
#define K1 JK[1]
#define SS screen_size
#define VL vec_length
#define EA ent_animate
#define CL clamp
#define LA eLd.alpha
#define BC bmap_create



My favorite one is of course "A7" wink I also had in earlier source versions

Code:
#define jcl wait



but this was too long ^^ As you can see I also noticed that I have sometimes lots of closing brackets, so I did things like

Code:
#define X )))



to save code again. All together it resulted in the following: this is the code for the player entity, that little round thing that you move around on the plates:

Code:
VD actPlayer(){
   A7((pzNr!=JI)&&(s(WT(s(set(J,256*sv(VS(J.x,vs(-10000)X)))))Q
   A7((s(WT(s(pl=J)X&&((pzNr==JI)&&(s(reset(J,256)X)Q
   Z(!(s(pl=NL*s(ent_remove(J)X)Q}



Creepy, isn't it? And the interesting thing is, that my player function doesn't even have semicolons ^^

But in the end I fulfilled both requirements and made a complete game; it was so much fun smile I am considering to take a shot on this contest again, maybe I will do a small component-type thing, which doesn't need this, or I am making a game again, which will need these tricks again ^^ so, lets see if I find the time; other than that I am curious what you will guys make in the end!

Last edited by HeelX; 01/20/12 08:40.
Re: Aum 104 [Re: HeelX] #392211
01/20/12 10:34
01/20/12 10:34
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
so is it a Lite-C to Chinese, or to Egyptian hieroglyph contest?


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: Aum 104 [Re: sivan] #392214
01/20/12 11:28
01/20/12 11:28
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Originally Posted By: sivan
so is it a Lite-C to Chinese, or to Egyptian hieroglyph contest?


No, you can waive those cheats and simply code something; I just showed some of mine to break the rules without breaking the rules smile

Re: Aum 104 [Re: HeelX] #392215
01/20/12 11:34
01/20/12 11:34
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
but did you do this manually or did you write an automatic obfuscator? hm... writing such an obfuscator would be quite an interesting task.

Re: Aum 104 [Re: ventilator] #392217
01/20/12 11:47
01/20/12 11:47
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
I did it by hand until I matched the limits. Yes, today I would write an application, that would list statistics for existing n-gram distributions for n between 3 and 8 or so. So, that it is an semi-automatic process in the end, because you have to take also care for existing macros and syntax errors.

Last edited by HeelX; 01/20/12 11:48.
Re: Aum 104 [Re: HeelX] #392220
01/20/12 12:36
01/20/12 12:36
Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
George Offline OP

Expert
George  Offline OP

Expert

Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
I like Christian's rules a lot! Let's use them as guidelines, but we can't force the people to go by them. Actually, we could reject the entries that don't obey them, but we'd lose many precious contributions. I can't even remember how many times I've recreated the submission entries which were breaking the contest rules because the archives were created in a non-zip format, were including installers, and so on.

Re: Aum 104 [Re: George] #392257
01/20/12 19:04
01/20/12 19:04
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Great grin I'm already working on something nice. Thanks for the tips, hints and guiderules HeelX!


Click and join the 3dgs irc community!
Room: #3dgs
Re: Aum 104 [Re: Joozey] #392261
01/20/12 19:49
01/20/12 19:49
Joined: Apr 2008
Posts: 2,488
ratchet Offline
Expert
ratchet  Offline
Expert

Joined: Apr 2008
Posts: 2,488
Thanks George for this great magazine !

The menu of RPG template is simple and well done with simple colors and patterns, very inspiring laugh



Last edited by ratchet; 01/20/12 19:49.
Re: Aum 104 [Re: sivan] #392265
01/20/12 20:30
01/20/12 20:30
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
So its a code golf contest or what?


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Page 3 of 8 1 2 3 4 5 6 7 8

Moderated by  George 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1