![]() |
Show off your finest piece of code!
Just was thinking about this; did you ever had a function or a piece of code you tihnk it was uber leet? By its simplicity, or by its uniqueness, or its stupidness, or the way its written, etc. Post it here!
Also, if you find some cool comments in ur code, i would like to see them (including the code when possible)... i love it when i see: Code:
// why does this work? Code:
/* Code:
int main() Code:
// Scale this Code:
// * so you are asking yourself why i do == true all the time huh? Code:
// CHECK FOR STEAM; Code:
// set wait time (stand still, looks like bot is thinking hehe) Code:
/* |
Re: Show off your finest piece of code!
Code:
if (code) = yes ; (brain) SWITCH OFF As you can see, there's a reason I dropped computing.9_9 |
Re: Show off your finest piece of code!
I've seen some good ones in the HL SDK and in Quake/Quake 2.
Botman has them documented here -> http://www.planethalflife.com/botman/humor.shtml |
Re: Show off your finest piece of code!
Cube bot, main think function:
Code:
void CBot::Think() Code:
template <class C> class TMultiChoice Code:
TMultiChoice WeaponChoices; Here something new in the cube bot: used when bots have an enemy and still want an item(ammo etc). They will strafe to it but keep aiming(and shooting) at their enemy. Code:
vec v = { m_pTargetEnt->x, m_pTargetEnt->y, Aiming in cube bot(maths obviously not by me :D) Code:
void CBot::AimToVec(const vec &o) Code:
// Prediction: Code:
// return true when done calculating Code:
int blah=0; As usual most code is inspired by PMB, he has some nice ideas *hugs* |
Re: Show off your finest piece of code!
Code:
#include <iostream> |
Re: Show off your finest piece of code!
1 Attachment(s)
@sfx : that code would be pretty small when using shift ops "<<"
to make some temporary conclusion : some people seem to like rows of if statements and other ppls best piece of code is that with very few comments :D and ha, my AStar "Taskmanager" idea has found it's way over pierre to cube bot - nice ! some piece of nice code is attached ... my AStarMachine with a plugininterface for almost everything needed here, fast, reliable, never had to touch that code since optimizing :) another nice thing is my n-dimensional vector class using SSE, that's a mess ... but well, not my finest piece of code :) but percepting entities in joebot xp is : Code:
void CPerceptionBot::perceptEntities(void){ |
Re: Show off your finest piece of code!
Quote:
|
Re: Show off your finest piece of code!
From a c++ book :)
Code:
void send(int* to, int* from, int count) Didn't it know it came from you :P But 'taskmanager'? Its just time sliced :P |
Re: Show off your finest piece of code!
Well im proud of this cos i figured it out my self.
Not that it is some kind of rocket science. But it just works so damn fast that lotsa time i forget i got debug logging on. Winding up enourmous megabitous log files with out lag. Althoug the Win32 is not yet system logging. (but it is almost as fast as the linux method.) It just compose the messages like linux sysloging is doing it. And it doesn't open close file after each log action. Code:
/////////////////////////////////////////////////// In stead of the HPB_Bot log routines. Where LOG_LEVEL could be one of the levels defined by Linux syslog.h. But i derived it to sb_syslog.h to make it shorter LogPrint(); fuctions. and to make it work with Win32. |
Re: Show off your finest piece of code!
about the A* Taskmanager ... I extended this idea a bit and made it more comfortable to work with ... here are the definitions : ( the actual code is nothing special, just some assignments and a simple algorithm for managing which task to execute, such stuff can be looked up in every operating system book )
Code:
class AStarBase; |
Re: Show off your finest piece of code!
Quote:
Its 10MB (zipped), but it contains all you need: Source, gfx, grabber utility, etc. CS2d\CS2d contains the source CS2d\<dir> contains what it should contain (look at the name) ow, and if you look at the source, you will laugh your ass off, seriously. http://realbot.bots-united.com/files/CS2D.ZIP (its up) |
Re: Show off your finest piece of code!
hey , dude that link's broken ...
AH and yes , would you mind if I use the code ? OF course credit will be given |
Re: Show off your finest piece of code!
fixed the link.
sure, no problem (else i would'nt have put it here anyways). |
Re: Show off your finest piece of code!
here`s my 2cents a nice little cpp doubly linked list class
Code:
CLinkedList *pLL = NULL; |
Re: Show off your finest piece of code!
hm, somehow you missed something in your c++ course ;)
remove that pLL variable ... in the methods of that class ( that are the fucntions of a class ) you can access its variables directly. your solution works fine for one instance of that class, but you'll get into trouble once you wanna have more of them PS: deleting isnt permitted in this forums :) just edit it if you like to |
Re: Show off your finest piece of code!
thanks for that aspirin;), i will upload a fixed version at about 10pm GMT
going out now. p.s what names do you guys play cs under mines -=[AK]=- Dubb because i might have been playing with you yesterday. p.p.s could one of the moderators delete the previous code thread. |
Re: Show off your finest piece of code!
I would say my vector class is good, but I am not sure whether it works properly with pointers, so I'll only post part of it.
Code:
class vector3 |
Re: Show off your finest piece of code!
ah and yes stefan , do I need to do extra stuff with Allegro or just install it ?
|
Re: Show off your finest piece of code!
Allegro is a library, you can just compile it and copy it into your MSVC folder
|
Re: Show off your finest piece of code!
I get the Windows Binary version and I do the manual installation then I think its alright since I have copied many lib files into the "LIB" directory :)
|
Re: Show off your finest piece of code!
hey , its quite easy to understand the code , but I se many "STEAM" phrase inside :D Perhaps I could do something :)
[EDIT] Now player can fire , but no bullet appear , no sound :( |
Re: Show off your finest piece of code!
I forgot to show the output of the full program. Here it is:
Quote:
|
Re: Show off your finest piece of code!
just check it for yourself. normalized vectors have the length 1 when using the appropriate norm and addition and mutliplication shouldnt be a problem neither. if you have problems with your code, maybe you should start another thread for itself, or start a general "misc coding questions" thread
|
Re: Show off your finest piece of code!
Some random crap i dug up from one of my webservers :p
PHP Code:
PHP Code:
|
Re: Show off your finest piece of code!
not really a code... but it is the first thing i have ever made in flash and it took awhile to make.....
www.crazymonkeycomputers.com |
All times are GMT +2. The time now is 04:50. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.