![]() |
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; |
All times are GMT +2. The time now is 02:27. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.