AI re-devlopment thread
-
- Elite
- Posts: 8014
- Joined: Fri Sep 05, 2003 4:03 am
- Location: Montreal
- Contact:
Re: AI re-devlopment thread
@Safemode: I agree, but I cannot involve myself with VS campaigns; my plate is full; don't even know how I'm going to fit AI work between art integration and graphics; but at least I have some ideas what to do in ai; --none for campaigns.
@Klauss: Well put.
So, where are these state machines, in the code, presently?
@Klauss: Well put.
So, where are these state machines, in the code, presently?
Latest version of Cinemut Opaque
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
-
- Elite
- Posts: 7243
- Joined: Mon Apr 18, 2005 2:40 pm
- Location: LS87, Buenos Aires, República Argentina
Re: AI re-devlopment thread
The file I linked, aggressive.h/cpp, handles evaluating those state machines, and some of the the hardcoded actions. There's also fire.h/cpp, comm_ai.h/cpp, and a few other classes that make up the inherited behavior of aggressive.h/cpp.chuck_starchaser wrote: @Klauss: Well put.
So, where are these state machines, in the code, presently?
The state machines are weirdly described (weirdly = I never could make full sense of them) in xml files in the data folders (data/ai IIRC). There's one per "role", which is kind of a personality - turrets have one personality, fighters another, etc, etc.
-
- Elite
- Posts: 8014
- Joined: Fri Sep 05, 2003 4:03 am
- Location: Montreal
- Contact:
Re: AI re-devlopment thread
Damn, I.m still in bed using this borrowed laptop; forgot I don't have the code here.
I'll have a look soon.
Wait, I could try and find it in the http svn...
I'll have a look soon.
Wait, I could try and find it in the http svn...
Latest version of Cinemut Opaque
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
-
- Elite
- Posts: 8014
- Joined: Fri Sep 05, 2003 4:03 am
- Location: Montreal
- Contact:
Re: AI re-devlopment thread
Got it.chuck_starchaser wrote:Damn, I.m still in bed using this borrowed laptop; forgot I don't have the code here.
I'll have a look soon.
Wait, I could try and find it in the http svn...
First thing I see...
Code: Select all
static float game_speed = XMLSupport::parse_float (vs_config->getVariable ("physics","game_speed","1"));
static float game_accel = XMLSupport::parse_float (vs_config->getVariable ("physics","game_accel","1"));
Latest version of Cinemut Opaque
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
-
- Elite
- Posts: 7243
- Joined: Mon Apr 18, 2005 2:40 pm
- Location: LS87, Buenos Aires, República Argentina
Re: AI re-devlopment thread
Can't argue with that.chuck_starchaser wrote:I'm so sick of this game speed crap polluting code everywhere I suggest we get rid of it, --root it out completely. Game difficulty should ONLY affect friend vs foe AI; --NOTHING ELSE. And game speed should always be the exact speed at which physics are exactly right; --NONE OTHER.Code: Select all
static float game_speed = XMLSupport::parse_float (vs_config->getVariable ("physics","game_speed","1")); static float game_accel = XMLSupport::parse_float (vs_config->getVariable ("physics","game_accel","1"));
EDIT: except a global speed setting could be useful for cutscenes, whenever cutscenes are implemented. But that should be implemented differently IMO
-
- Elite
- Posts: 8014
- Joined: Fri Sep 05, 2003 4:03 am
- Location: Montreal
- Contact:
Re: AI re-devlopment thread
Cut-scenes as in movies? Those should be stop/resume-able with space-bar. I hate when there's text to read, sometimes in games, and not enough time to read it.
Well, I visually browsed through all the code in aggressive.cpp, line by line, for no reason I can think of except perhaps an electrifying sense of disbelief, perhaps a morbid fascination with horror. This is the worst code I'd ever seen, heard of, or imagined.
Well, I visually browsed through all the code in aggressive.cpp, line by line, for no reason I can think of except perhaps an electrifying sense of disbelief, perhaps a morbid fascination with horror. This is the worst code I'd ever seen, heard of, or imagined.
Latest version of Cinemut Opaque
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
-
- Elite
- Posts: 1567
- Joined: Tue Jan 26, 2010 2:03 am
Re: AI re-devlopment thread
Well, when your help (wingman(men)) such as those in PU keep colliding for no reason or keep shooting at whatever you target even if its friendly what did you expect??
I think the biggest thing we need is to make sure that when fighting the AI is that it keeps a minimum distance away from the player unless it hits a ram state. I'm tired of the AI flying in circles around me at a range of 100-200m no matter what class ship I use (in either game)
However the AI gets revamped, do we want to continue to allow people to mod the base behavoir or rules? Back when I modded Warzone 2100 (its now open source btw) we did a lot of work creating new AI scripts. The game engine used a c like scripting language to run the AI. We created a defensive turtle AI, highly aggressive rush AI as well as several other I can't remember.. I think one of them favored one tactic (artillery bombardments) over frontal assaults with tracked vehicles. Each unit also tracked its kills and got a bit stronger each rank (targeting, accuracy, ?). This last bit was part of the game itself so I may have to dig through the source to find it.
A good AI including gov, group (fleet/squad), and individual or just a plain leader/pilor model can be done w/o increasing cpu workload. Its all dependent on how well the AI code is written and optimized.
One last point that needs to be brought up though... your pilot AI does *NOT* have to work nearly as hard as the combat AI. All of us seem to lump the pilot with combat, but how often are we IN combat with the AI. The combat AI has to do a lot more work overall than a simple fly to point a jump to point b. The combat AI has to tally when to fight when to evade or when to flee. During all this if you are flying straight at the enemy how long do I attack before I try and evade? At what range do I attack? How damaged am I and what do I do if my shields/armor are below n%. Do I run or fight to the death? How close am I to my target? My squadmates? Asteroids? If I am about to collide with target n which direction is free of other units? What are my engagement rules?
If the games current combat AI is in decent working shape we can clean it up and maybe optimize it a little and go from there. If we rewrite the AI from scratch.. well, It would be nice if we could give each unit its own thread, preferably at the unit level and not the AI level. For multi-threading I have no clue what would work best since this game is devoid of threads.
I think the biggest thing we need is to make sure that when fighting the AI is that it keeps a minimum distance away from the player unless it hits a ram state. I'm tired of the AI flying in circles around me at a range of 100-200m no matter what class ship I use (in either game)
However the AI gets revamped, do we want to continue to allow people to mod the base behavoir or rules? Back when I modded Warzone 2100 (its now open source btw) we did a lot of work creating new AI scripts. The game engine used a c like scripting language to run the AI. We created a defensive turtle AI, highly aggressive rush AI as well as several other I can't remember.. I think one of them favored one tactic (artillery bombardments) over frontal assaults with tracked vehicles. Each unit also tracked its kills and got a bit stronger each rank (targeting, accuracy, ?). This last bit was part of the game itself so I may have to dig through the source to find it.
A good AI including gov, group (fleet/squad), and individual or just a plain leader/pilor model can be done w/o increasing cpu workload. Its all dependent on how well the AI code is written and optimized.
One last point that needs to be brought up though... your pilot AI does *NOT* have to work nearly as hard as the combat AI. All of us seem to lump the pilot with combat, but how often are we IN combat with the AI. The combat AI has to do a lot more work overall than a simple fly to point a jump to point b. The combat AI has to tally when to fight when to evade or when to flee. During all this if you are flying straight at the enemy how long do I attack before I try and evade? At what range do I attack? How damaged am I and what do I do if my shields/armor are below n%. Do I run or fight to the death? How close am I to my target? My squadmates? Asteroids? If I am about to collide with target n which direction is free of other units? What are my engagement rules?
If the games current combat AI is in decent working shape we can clean it up and maybe optimize it a little and go from there. If we rewrite the AI from scratch.. well, It would be nice if we could give each unit its own thread, preferably at the unit level and not the AI level. For multi-threading I have no clue what would work best since this game is devoid of threads.
Because of YOU Arbiter, MY kids? can't get enough gas. OR NIPPLE! How does that mkae you feeeel? ~ Halo
-
- Developer
- Posts: 2150
- Joined: Mon Apr 23, 2007 1:17 am
- Location: Pennsylvania
- Contact:
Re: AI re-devlopment thread
There are a few things wrong with aggressive.cpp, but the most horrible code i've ever seen? nah.
It's got horrible formatting. This is certainly due to tons of different authors over the course of 10 years. Easily fixed.
It's got way too many objects and non-class functions mixed in. This is easily fixed by splitting the file up into component parts.
It uses direct Config variable accesses, rather than the options class. Another easy fix.
Once the above is done, then it would be time to look at optimizing code. (assuming nobody is ready to do a complete rewrite ..which i doubt someone is). First on the list of optimizations is removing any sort of loops that we can, or severely limit their iterations. Eg. things like random nav where we are looping through from 1 to max_rand attempting to find some random object to move towards, we instead can just do something simpler. Just have a unit that has no particular place to goto to move towards the 3rd significant unit in the list and go from there next time it wants a random dest.
Other things that would speed things up is the unit list. I'm fairly certain that the way we find something like "the next planet or base" is we iterate through a single list of all units in the system and ask if it's significant or not. At a minor expense of ram, we could lower the overhead of searching for a significant unit or regular unit by maintaining two lists and having the appropriate function iterate the correct one. It would be a transparent change as far as python is concerned. so each system would have 2 lists, and we would have the master Universe list containing everything.
Then we have other stuff like the block starting on line 801. That kind of stuff in AI routines make my vision go red and all sound is deafened by a soundtrack that is only ever played during murderous bezerker fueled rampages.
It's got horrible formatting. This is certainly due to tons of different authors over the course of 10 years. Easily fixed.
It's got way too many objects and non-class functions mixed in. This is easily fixed by splitting the file up into component parts.
It uses direct Config variable accesses, rather than the options class. Another easy fix.
Once the above is done, then it would be time to look at optimizing code. (assuming nobody is ready to do a complete rewrite ..which i doubt someone is). First on the list of optimizations is removing any sort of loops that we can, or severely limit their iterations. Eg. things like random nav where we are looping through from 1 to max_rand attempting to find some random object to move towards, we instead can just do something simpler. Just have a unit that has no particular place to goto to move towards the 3rd significant unit in the list and go from there next time it wants a random dest.
Other things that would speed things up is the unit list. I'm fairly certain that the way we find something like "the next planet or base" is we iterate through a single list of all units in the system and ask if it's significant or not. At a minor expense of ram, we could lower the overhead of searching for a significant unit or regular unit by maintaining two lists and having the appropriate function iterate the correct one. It would be a transparent change as far as python is concerned. so each system would have 2 lists, and we would have the master Universe list containing everything.
Then we have other stuff like the block starting on line 801. That kind of stuff in AI routines make my vision go red and all sound is deafened by a soundtrack that is only ever played during murderous bezerker fueled rampages.
Ed Sweetman endorses this message.
-
- Elite
- Posts: 8014
- Joined: Fri Sep 05, 2003 4:03 am
- Location: Montreal
- Contact:
Re: AI re-devlopment thread
If you could do the above, specially splitting up stuff, it would be wonderful. I AM willing to completely rewrite the AI, but out of infinite choices, I'd rather make choices that allow something like the present results; but for that I need to have a rough idea what's it doing, or trying to do; but I can't read such gargantuan routines. Misnaming is a problem too, starting with the file-name being aggressive, but containing such non-aggressive stuff as cargo wingmen parking in front to be tractored in, and not ending with mystifying stuff such as "int whichlist=1;//friendly"...???!!??!?!!!safemode wrote:There are a few things wrong with aggressive.cpp, but the most horrible code i've ever seen? nah.
It's got horrible formatting. This is certainly due to tons of different authors over the course of 10 years. Easily fixed.
It's got way too many objects and non-class functions mixed in. This is easily fixed by splitting the file up into component parts.
It uses direct Config variable accesses, rather than the options class. Another easy fix.
I am; but a) I'll need help understanding the current code, and b) I'll need help with integration of the new ai system, since everything else is so messy too.Once the above is done, then it would be time to look at optimizing code. (assuming nobody is ready to do a complete rewrite ..which i doubt someone is).
@storm:
Whether or not ai modding is on the table I don't know, but since you mention, I'll make sure I design the system for easy modding, if only because that will force better code structuring.
Latest version of Cinemut Opaque
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
-
- Elite
- Posts: 7243
- Joined: Mon Apr 18, 2005 2:40 pm
- Location: LS87, Buenos Aires, República Argentina
Re: AI re-devlopment thread
I happen to agree with chuck.safemode wrote:There are a few things wrong with aggressive.cpp, but the most horrible code i've ever seen? nah.
Proof of horribleness is that I tried several times within the last few years to understand how every piece of it fits together... and failed every time.
And not, I'm not incompetent at trying to figure out other people's code, I've successfully done it with the rest of VS. It's just the interactions among a gazillion pieces in all AI code are so complex and undocumented that it's too much for me.
-
- Elite
- Posts: 8014
- Joined: Fri Sep 05, 2003 4:03 am
- Location: Montreal
- Contact:
Re: AI re-devlopment thread
Well, I most certainly am; but this file is ridiculous; and I wasn't even able to find the two state machines you mentioned.klauss wrote:I happen to agree with chuck.safemode wrote:There are a few things wrong with aggressive.cpp, but the most horrible code i've ever seen? nah.
Proof of horribleness is that I tried several times within the last few years to understand how every piece of it fits together... and failed every time.
And not, I'm not incompetent at trying to figure out other people's code...
Latest version of Cinemut Opaque
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
-
- Elite
- Posts: 1567
- Joined: Tue Jan 26, 2010 2:03 am
Re: AI re-devlopment thread
Actually I think AI modding is currently in use. At least to a certain degree. AI tweaking might be a better way to call it though.. its in http://vegastrike.sourceforge.net/forum ... 21&t=14701 this thread. This section of the AI seems to be how each ship classes role is defined (a guess since I havent viewed any of the AI code yet)chuck_starchaser wrote:@storm:
Whether or not ai modding is on the table I don't know, but since you mention, I'll make sure I design the system for easy modding, if only because that will force better code structuring.
I will have more a little later, quick post better taking lil one out to the park.
Because of YOU Arbiter, MY kids? can't get enough gas. OR NIPPLE! How does that mkae you feeeel? ~ Halo
-
- Elite
- Posts: 8014
- Joined: Fri Sep 05, 2003 4:03 am
- Location: Montreal
- Contact:
Re: AI re-devlopment thread
How about this? A tiny, state-less state machine class:
Code: Select all
template< class state, class visitor >
class stateless_state_machine
{
std::string name;
std::unordered_map< string sname, state const * > state_index;
public:
explicit stateless_state_machine( std::string name ) : name(name)
{
file smfile = open_file_for_reading(name);
state temp;
while(1)
{
if( !temp=read_next_state<state>(smfile) ) break;
state pstate = new state(temp);
state_index.add( temp.get_name(), pstate );
}
update_linkage();
}
void operator()( visitor & v, std::string sname ){ operator()( v, state_index.find(sname).second() ); }
void operator()( visitor & v, state * ps )
{
(*ps)(v);
}
};
Latest version of Cinemut Opaque
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
-
- Developer
- Posts: 2150
- Joined: Mon Apr 23, 2007 1:17 am
- Location: Pennsylvania
- Contact:
Re: AI re-devlopment thread
Well, i think first we should work small here. I'm gonna try and make some time this weekend (crazy noreaster snow storm up here in NE US). So i'll split aggressive.cpp up into separate files based on class structure and commit this to my branch only. Since this will certainly break building on win32 and hamper that development. we need not commit back to trunk until we're further along.
Once we have it split up, it should be easier to follow the code and what it's doing. I'm pretty sure i have a general idea of what's going on as i'm reading it, but it's obviously not an entire part of AI. This seems to be part of the ai that deals with close ship to ship interaction. Perhaps it started out as only the fighting aspects, but later as the game evolved into more than just a space fighting sim, other interactions such as flightgroup behavior was added and wingmen interactions.
A better name needs to be found obviously, but i think a lot of what everyone is considering ugly or unfollowable has to do with the formatting. In VS we have no set standard like they have in the linux kernel, and i really wish we did. I just dont see how it would be enforceable being as how we have so few developers as it is, alienating any from their preferred style may hamper any actual development for the sake of aesthetics. Not that easily readable code is not necessary, but i fear such format rules would start getting hung up on tedious details.
That being said, when i split the file i'll do some full reformatting of the code so that at least the stupid code blocks are indented appropriately in relation to eachother.
edit: in fact, since i have off from my second job tonight, and i no longer sleep like a normal human being, i'll probably get started on this tonight.
Once we have it split up, it should be easier to follow the code and what it's doing. I'm pretty sure i have a general idea of what's going on as i'm reading it, but it's obviously not an entire part of AI. This seems to be part of the ai that deals with close ship to ship interaction. Perhaps it started out as only the fighting aspects, but later as the game evolved into more than just a space fighting sim, other interactions such as flightgroup behavior was added and wingmen interactions.
A better name needs to be found obviously, but i think a lot of what everyone is considering ugly or unfollowable has to do with the formatting. In VS we have no set standard like they have in the linux kernel, and i really wish we did. I just dont see how it would be enforceable being as how we have so few developers as it is, alienating any from their preferred style may hamper any actual development for the sake of aesthetics. Not that easily readable code is not necessary, but i fear such format rules would start getting hung up on tedious details.
That being said, when i split the file i'll do some full reformatting of the code so that at least the stupid code blocks are indented appropriately in relation to eachother.
edit: in fact, since i have off from my second job tonight, and i no longer sleep like a normal human being, i'll probably get started on this tonight.
Ed Sweetman endorses this message.
-
- Elite
- Posts: 7243
- Joined: Mon Apr 18, 2005 2:40 pm
- Location: LS87, Buenos Aires, República Argentina
Re: AI re-devlopment thread
More important is code review.safemode wrote:In VS we have no set standard like they have in the linux kernel, and i really wish we did.
It would be great to have code review, that would take care of each of our bad habits and slowly clean up the code.
That's impressively important... it's impossible to read code that isn't properly indented.safemode wrote:That being said, when i split the file i'll do some full reformatting of the code so that at least the stupid code blocks are indented appropriately in relation to eachother.
It's not obvious, it results from an interaction between a stack-based order system: when you set an order to the AI, like fire on this guy, the order may have a parent order that gets reinstated as the current order when the new order finishes (ie, when the target is destroyed).chuck_starchaser wrote:...and I wasn't even able to find the two state machines you mentioned.
I guess that makes the state machine very difficult to follow even in the XML scripts, and that's why noone can really make use of it. But it's there, at least theoretically.
-
- Elite
- Posts: 1567
- Joined: Tue Jan 26, 2010 2:03 am
Re: AI re-devlopment thread
If we had someone who had the time or willingness to follow the follwing a standard COULD be imposed on the code. Have a group standard deveolped that everyone can agree on, and elect one person to sanitize the code before it is merged with the trunk. It adds a layer or work to someone but overall allows everyone else to code as they please while at least *attempting* to follow a strict standard. Not the greatest solution but one that beats on people to at least try and conform to the norm but doesnt scream at em that you must use this standard or you can't code here. But.. all this is for another discussion.. back to the (labotomized) AI we havesafemode wrote: A better name needs to be found obviously, but i think a lot of what everyone is considering ugly or unfollowable has to do with the formatting. In VS we have no set standard like they have in the linux kernel, and i really wish we did. I just dont see how it would be enforceable being as how we have so few developers as it is, alienating any from their preferred style may hamper any actual development for the sake of aesthetics.
Last edited by pheonixstorm on Fri Feb 05, 2010 11:43 pm, edited 2 times in total.
Because of YOU Arbiter, MY kids? can't get enough gas. OR NIPPLE! How does that mkae you feeeel? ~ Halo
-
- Elite
- Posts: 8014
- Joined: Fri Sep 05, 2003 4:03 am
- Location: Montreal
- Contact:
Re: AI re-devlopment thread
It would be easier to agree on a formatting tool and settings. Then, I could format a file the way I want (need, really): open curley brace on next line, no space between if and (, etceteras, while working with a file; then reformat to the standard adopted before commit.
Latest version of Cinemut Opaque
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
-
- Elite
- Posts: 1567
- Joined: Tue Jan 26, 2010 2:03 am
Re: AI re-devlopment thread
I don't see why this:
is better than
and yes i like my if to have a space before () though if() is fine as well.. but the brackets to me is much more clear having the starting brace on the next line not on the same line as the if itself.
Code: Select all
if () {
... code
}
Code: Select all
if ()
{
.... code
}
Because of YOU Arbiter, MY kids? can't get enough gas. OR NIPPLE! How does that mkae you feeeel? ~ Halo
-
- Elite Mercenary
- Posts: 1329
- Joined: Thu Mar 27, 2003 11:51 pm
- Location: Manchester, UK
- Contact:
Re: AI re-devlopment thread
I prefer the same line {. Less wasted vertical space (fewer large empty lines, the end is more of an important separater than the beginning), I find it visually ties the block of logic together, and I find it much better for commenting.
Each to their own though, the important thing is consistency.
Code: Select all
if (foo) {
// explain purpose of block
bar;
}
Free Gamer - free software games compendium and commentary!
FreeGameDev forum - open source game development community
FreeGameDev forum - open source game development community
-
- Developer
- Posts: 2150
- Joined: Mon Apr 23, 2007 1:17 am
- Location: Pennsylvania
- Contact:
Re: AI re-devlopment thread
I use braces on the same line except for class definitions and function definitions.
So a function is
WhateverFunc ()
{
< indent > code
}
class whatever
{
< indent > stuff
}
But all procedural blocks have the brace on the same line. This is the type of subjective issues that are likely to never get ratified and i they do it becomes someone else's job to always clean up other people's work who just dont feel it necessary to go out of their way to change the way they code to contribute something freely when they really have no motive to do so (it's not like we have people clammering for the chance to contribute...unlike other projects )
I think something that _just_ agrees on indentation would be plenty helpful. But that requires using an editor that handles tab modification so that everyone can be on the same page as to what a tab is and how it's represented in the text file so it looks the same to everyone (or at least can be read in the same way).
I always used 3 spaces == 1 tab.
So a function is
WhateverFunc ()
{
< indent > code
}
class whatever
{
< indent > stuff
}
But all procedural blocks have the brace on the same line. This is the type of subjective issues that are likely to never get ratified and i they do it becomes someone else's job to always clean up other people's work who just dont feel it necessary to go out of their way to change the way they code to contribute something freely when they really have no motive to do so (it's not like we have people clammering for the chance to contribute...unlike other projects )
I think something that _just_ agrees on indentation would be plenty helpful. But that requires using an editor that handles tab modification so that everyone can be on the same page as to what a tab is and how it's represented in the text file so it looks the same to everyone (or at least can be read in the same way).
I always used 3 spaces == 1 tab.
Ed Sweetman endorses this message.
-
- Elite
- Posts: 7243
- Joined: Mon Apr 18, 2005 2:40 pm
- Location: LS87, Buenos Aires, República Argentina
Re: AI re-devlopment thread
Those preferences, like where to put spaces, and where exactly to put the curly braces, are way too personal to be agreed upon.
There are more important standards:
BTW: I propose 4 spaces for tabs because that's a standard I've seen all across the board. It's far more common than 3, 8 is simply too much, and... well... 4 is a power of two
There are more important standards:
- No using namespace x in headers
- One class per header file, few to none exceptions
- One class implementation per cpp file, except small internal implementation classes (comparators, helpers, internal structs)
- One cpp file per class
- Doxygen docs on all public classes and members
- Proper constness specifications
- No exception specifications see this
- Localize and avoid macro magic
- No 500-line functions
- No 400-line functions
- No 200-line functions either
- Relevant, expressive names
- camelCasing of methods and variables (lowercase initial)
- CamelCasing of classes and types (uppercase initial)
- CAPCASING/CamelCasing of constants and enumerated values (can't make up my mind in this one... CamelCasing makes for easier to read stuff, but doesn't differentiates them from classes and structs)
- No hungarian notation - EVER
- Uniform styling (within a file you're free to use braces and spaces and blank lines wherever you feel like, but be consistent)
- Proper indentation. Use spaces, not tabs, across. One level is 4 spaces.
BTW: I propose 4 spaces for tabs because that's a standard I've seen all across the board. It's far more common than 3, 8 is simply too much, and... well... 4 is a power of two
-
- Elite
- Posts: 8014
- Joined: Fri Sep 05, 2003 4:03 am
- Location: Montreal
- Contact:
Re: AI re-devlopment thread
You guys don't understand.
What I'm asking is for a tool and settings that we'd use consistently before commits, so that I can reformat code to suit myself, and then reformat to that standard before I commit.
I SIMPLY ***CANNOT*** WORK WITH { ON THE SAME LINE. DO YOU UNDERSTAND?
So, if I reformat code to suit myself, how can I avoid generating gazillions of differences in diffs?
Do you want me to do that?
I didn't think so.
So, let's just agree to a tool and settings that formats code in an agreed-to way for commiting; otherwise I WILL reformat every piece of code to suit my NEEDS, and you guys are going to scream.
What I'm asking is for a tool and settings that we'd use consistently before commits, so that I can reformat code to suit myself, and then reformat to that standard before I commit.
I SIMPLY ***CANNOT*** WORK WITH { ON THE SAME LINE. DO YOU UNDERSTAND?
So, if I reformat code to suit myself, how can I avoid generating gazillions of differences in diffs?
Do you want me to do that?
I didn't think so.
So, let's just agree to a tool and settings that formats code in an agreed-to way for commiting; otherwise I WILL reformat every piece of code to suit my NEEDS, and you guys are going to scream.
Latest version of Cinemut Opaque
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
-
- Elite
- Posts: 7243
- Joined: Mon Apr 18, 2005 2:40 pm
- Location: LS87, Buenos Aires, República Argentina
Re: AI re-devlopment thread
I don't know any tool that works neither reliable nor with your exact standards. I certainly don't think anyone will write one either.chuck_starchaser wrote:You guys don't understand.
What I'm asking is for a tool and settings that we'd use consistently before commits, so that I can reformat code to suit myself, and then reformat to that standard before I commit.
chuck_starchaser wrote:I SIMPLY ***CANNOT*** WORK WITH { ON THE SAME LINE. DO YOU UNDERSTAND?
I don't think any team works with such a workflow, it's slow and painful. Mostly because you'll have to battle (or pollute SVN) with the mistakes the formatter tool will make.chuck_starchaser wrote:So, if I reformat code to suit myself, how can I avoid generating gazillions of differences in diffs?
Do you want me to do that?
I didn't think so.
So, let's just agree to a tool and settings that formats code in an agreed-to way for commiting; otherwise I WILL reformat every piece of code to suit my NEEDS, and you guys are going to scream.
-
- Elite
- Posts: 8014
- Joined: Fri Sep 05, 2003 4:03 am
- Location: Montreal
- Contact:
Re: AI re-devlopment thread
That's false. There was an article years ago, not sure if in C++ Journal or DrDobbs (used to buy both), and the article was precisely about this problem, and he acknowledged that to many programmers formatting is more than just "a preference" and presented a solution that tied a formatter to (then CVS) to reformat code on checkout and commit. They were using the system at his company. I have a feeling you just don't WANT me to get this wish. This is damn important to me, if I'm going to get involved with the C++ code. But if you don't care for my help, then so be it. This is how so many great plans go to shit.
EDIT:
And just look at the injustice of this, Klauss. I've asked for this repeatedly over the years and all I get from you is the cold shoulder, every time. Now I capitalized what I've repeated so often, and you make a face about it. Safemode was saying he's tempted to run a formatter on all the code. Well, THAT is all I'm asking for, plus info about the tool used and the settings, so I can format the code in a way I can work with it, and then format it back before committing.
What is so evil about my request?
I recognize I'm in a minority here; most people around here like { in the same line. Fine. My mind cannot comprehend it, at all, but fine. All I'm asking is for the means to work the way I do without bothering you guys. Is that too much to ask?
Because what you seem to be saying to me is "learn to work with { in the same line, of fuck off".
Well, that's what I've been doing all these years, and will continue to do, as long as you continue to be inflexible and patronizing; I will just not touch the engine code. Hope that makes you really happy.
EDIT:
And just look at the injustice of this, Klauss. I've asked for this repeatedly over the years and all I get from you is the cold shoulder, every time. Now I capitalized what I've repeated so often, and you make a face about it. Safemode was saying he's tempted to run a formatter on all the code. Well, THAT is all I'm asking for, plus info about the tool used and the settings, so I can format the code in a way I can work with it, and then format it back before committing.
What is so evil about my request?
I recognize I'm in a minority here; most people around here like { in the same line. Fine. My mind cannot comprehend it, at all, but fine. All I'm asking is for the means to work the way I do without bothering you guys. Is that too much to ask?
Because what you seem to be saying to me is "learn to work with { in the same line, of fuck off".
Well, that's what I've been doing all these years, and will continue to do, as long as you continue to be inflexible and patronizing; I will just not touch the engine code. Hope that makes you really happy.
Latest version of Cinemut Opaque
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
Latest version of LaGrande noodleworks (scroll down).
An evolving La Grande How-To...
The non-working, but latest, CineMut test_bike
PU (Privateer: Parallel Universe's Home). WC or Privateer Drayman for you?
WCpedia --The Wing Commander Encyclopedia-- From Angel Deveraux through Belisarius to Zachary Banfeld...
WC Nexus forum, the Moonbase Tycho of WC fans.
-
- Elite
- Posts: 1567
- Joined: Tue Jan 26, 2010 2:03 am
Re: AI re-devlopment thread
Just so we can end this OT rant n roll (lets not pour a bucket o salt in anyones open cold sores here) here are what I have found to be the top three code formatters from the topics i've read as well as a gui interface for them.
http://astyle.sourceforge.net/
http://uncrustify.sourceforge.net/
http://sourceforge.net/projects/gcgreatcode/
Gui http://universalindent.sourceforge.net/
http://stackoverflow.com/questions/1017 ... n-check-in This page has some information on getting a formatter up to run at commit though it made no mention on checkout.. same script maybe? Not sure...
Maybe with those 3 formatters to choose from we can get one to do the format we want in svn and private copies. Can we get back to the AI now or start a formatter thread? I want to butt heads over the AI not personal formatting issues
http://astyle.sourceforge.net/
http://uncrustify.sourceforge.net/
http://sourceforge.net/projects/gcgreatcode/
Gui http://universalindent.sourceforge.net/
http://stackoverflow.com/questions/1017 ... n-check-in This page has some information on getting a formatter up to run at commit though it made no mention on checkout.. same script maybe? Not sure...
Maybe with those 3 formatters to choose from we can get one to do the format we want in svn and private copies. Can we get back to the AI now or start a formatter thread? I want to butt heads over the AI not personal formatting issues
Because of YOU Arbiter, MY kids? can't get enough gas. OR NIPPLE! How does that mkae you feeeel? ~ Halo