wraitii Posted February 23, 2012 Author Report Share Posted February 23, 2012 (edited) There is certainly space to simplify my code, even without any API changes... I've modified stuffs from qBot while not necessarily removing them, changed things, made some pretty idiotic design choices now and then (It's now changed, but I asked the "game" for the entity associated with an ID... By asking said entity to give its ID. In other words, I asked for informations I already had while using it).I'll try to clean the code, to remove most errors, and to optimize the code for the next version... I'm currently cutting the map into smaller squares for the economy manager so it won't have to loop through every resource on the map each time it wants to assign a unit a task... It's working much faster (on Gambia river, a forest-ridden map, it's at least twice faster for each unit, so it's quite quickly 5 or more times faster), but it demands quite serious code change. Edited February 23, 2012 by wraitii Quote Link to comment Share on other sites More sharing options...
wraitii Posted February 23, 2012 Author Report Share Posted February 23, 2012 (edited) Allright, I've decided to upload this newer version a bit early, mainly because it's fairly interesting... The main feature is speeding up of the "reassignIdleWorker" function, by dividing the map into subsquares and looking in those. It's really much much faster on maps where there are tons of trees involved. On Gambia River, this newer version is easily 5 times as fast as qBot, sometimes more. There doesn't seem to by any bug left, though if you notice any "dodgy" behavior in the "looking for resources" area, let me know.Other things I did: clean up of the code, I removed many unused functions that were left-overs from qBot or early development... Actually implemented garrisoning citizens in case of major attacks. I did a lot of fairly small "sanity checks" that should remove most of the "error: whatever is undefined" errors, though I'm not sure I got them all. Fixed a little bug that could happen on some map with houses.(BTW: qBot should have a check in "accessibility". If the "start" point is undefined, there's an error).So now I can start the more interesting stuff, such as actually adding features.Download LinkEdit: bug noticed thanks to Pureon. It's not a gamebreaker but you'll get a ton of error messages if you garrison a soldier:Fix: line 378 of defence.js, add:if (enemy.position() == undefined) // unit is likely garrisoned. DO not check.continue;Line 428 of "attack_city.js"if (enemy.position() == undefined) // likely garrisonedcontinue;In defence.js, line 200, replace the if condition by this one:if (enemy.owner() == ennemiPotentiel.owner() && enemy.id() !== ennemiPotentiel.id() && enemy.position() !== undefined) Edited February 24, 2012 by wraitii Quote Link to comment Share on other sites More sharing options...
Pureon Posted February 23, 2012 Report Share Posted February 23, 2012 I'm not sure I noticed a performance improvement over qBot, but Marilyn did fight very well indeed.I was getting quite a number of errors and warnings though:http://pastebin.com/QmZetcv6Match was on the new Punjab map with Marilyn as player 1 Hellenes. Quote Link to comment Share on other sites More sharing options...
wraitii Posted February 23, 2012 Author Report Share Posted February 23, 2012 To notice the speed improvement, you'd have to check the profiler on time warp. It becomes very obvious then (otherwise, this function is called once every 10 turn so it's not that noticeable)These errors are very weird... Apparently, enemy units that are supposed to exist don't. I see absolutely no reason why... Any particular action that was happening when you got those (attacking marilyn, destroying her?)The warnings are "normal" debug warnings, though, you can turn it off in "Marilyn.js". Quote Link to comment Share on other sites More sharing options...
Pureon Posted February 24, 2012 Report Share Posted February 24, 2012 These errors are very weird... Apparently, enemy units that are supposed to exist don't. I see absolutely no reason why... Any particular action that was happening when you got those (attacking marilyn, destroying her?)Sorry, nothing obvious - I was still expanding my economy at the time, hadn't even scouted out the AI's base when the errors (not warnings) began appearing. Maybe around 10 minutes into the match. Quote Link to comment Share on other sites More sharing options...
historic_bruno Posted February 24, 2012 Report Share Posted February 24, 2012 These errors are very weird... Apparently, enemy units that are supposed to exist don't. I see absolutely no reason why... Any particular action that was happening when you got those (attacking marilyn, destroying her?)If you're dealing with positions, there are several reasons why it might be undefined. The target could be garrisoned, dead, or training in progress (created but not yet spawned). Basically you want to check the position is not undefined before using it, as early as possible so the errors don't propagate all over the place. I think this should be added as a helper function for AIs. Quote Link to comment Share on other sites More sharing options...
wraitii Posted February 24, 2012 Author Report Share Posted February 24, 2012 (edited) Mmmh, I forgot about garrisoning making the position undefined, this must be it because there's no way the units that are sorted by this function are dead. I'll give it a try.(What's fun is that I really, authentically suck at this game, so I never try to garrison anything. I'm even unable to defeat my own bot.)edit: Yup, garrisoning a soldier makes it go mad because I completely forgot about that possibility. Easy fix.Anyone else tried playing around a bit?Fix: line 378 of defence.js, add:if (enemy.position() == undefined) // unit is likely garrisoned. DO not check.continue;Edit: actually elsewhere too, I'll continue to playtest with some garrisoned units to see if there's any other spot.Line 428 of "attack_city.js"if (enemy.position() == undefined) // likely garrisonedcontinue;Edit^2: darn, also in defence.js, line 200, replace the if condition by this one:if (enemy.owner() == ennemiPotentiel.owner() && enemy.id() !== ennemiPotentiel.id() && enemy.position() !== undefined) Edited February 24, 2012 by wraitii Quote Link to comment Share on other sites More sharing options...
Pureon Posted February 24, 2012 Report Share Posted February 24, 2012 What's fun is that I really, authentically suck at this game, so I never try to garrison anything. I'm even unable to defeat my own bot.One of the easiest ways to defend against an AI is to garrison your citizen soldiers in a fortress/tower.I quite possibly did garrison a unit just before the errors appeared - it had been attacked by a leopard and needed healing Quote Link to comment Share on other sites More sharing options...
wraitii Posted February 24, 2012 Author Report Share Posted February 24, 2012 (edited) I can tell you with 100% certainty that you have indeed garrisoned a unit right before the unit appeared .Okay, so since that seems to be taken care of, I'll now proceed to try to actually add stuff. I've already made the AI stop changing its workers of task every minute, so it behaves more humanly (and efficiently) Edited February 24, 2012 by wraitii Quote Link to comment Share on other sites More sharing options...
Pureon Posted February 24, 2012 Report Share Posted February 24, 2012 It would be great to see a few AI scouts and some random raiding. This will hurt the AI's early economy, but it makes for a much more interesting and eventful match Quote Link to comment Share on other sites More sharing options...
gameboy Posted February 24, 2012 Report Share Posted February 24, 2012 Very good, You is in the design of a new AI? Quote Link to comment Share on other sites More sharing options...
wraitii Posted February 24, 2012 Author Report Share Posted February 24, 2012 No, I just decided during the Christmas Holidays to create a new AI. And since QuantumState, maker of qBot, is too busy to really work on qBot, I though I would keep on improving it.@Pureon: that's planned, should not be too hard to do at least basically. Quote Link to comment Share on other sites More sharing options...
gameboy Posted February 24, 2012 Report Share Posted February 24, 2012 But QuantumState is redesigned and optimized it ( QBot ). I hope he will soon finish designing it, I am looking forward to it.BTW: Can you solve the Qbot AI caused by game problem? Quote Link to comment Share on other sites More sharing options...
wraitii Posted February 24, 2012 Author Report Share Posted February 24, 2012 He has done a few modifications, but nothing fundamentally different, I think.I'm not sure what you mean by your second question, could you rephrase it?I've finished updating my attack plans to allow for more precise unit construction (archers, javelins and not only "ranged"), planning for raids. It was a bit of a pain, but it works. Quote Link to comment Share on other sites More sharing options...
gameboy Posted February 25, 2012 Report Share Posted February 25, 2012 Sorry, I mean: Qbot game lag, if you can solve this problem? Quote Link to comment Share on other sites More sharing options...
MishFTW Posted February 25, 2012 Report Share Posted February 25, 2012 @Gameboy: I doubt qBot is causing the game lag, probably just your hardware. @ wraitii: Great progress so far! My only suggestion: get this thing to make forts. Lots of them. And archers (or other range units) to go with them. They'll help Marilyn Quote Link to comment Share on other sites More sharing options...
Mythos_Ruler Posted February 25, 2012 Report Share Posted February 25, 2012 Got this error playing against Marilyn.interestinglog.zip Quote Link to comment Share on other sites More sharing options...
wraitii Posted February 25, 2012 Author Report Share Posted February 25, 2012 I can't see what would cause that, unless you played a civilization that has no known ranged infantry (the Romans perhaps?)... Anyway it's not important because that part of the code has been completely rewritten. Quote Link to comment Share on other sites More sharing options...
Mythos_Ruler Posted February 25, 2012 Report Share Posted February 25, 2012 I can't see what would cause that, unless you played a civilization that has no known ranged infantry (the Romans perhaps?)... Anyway it's not important because that part of the code has been completely rewritten.Romans have their skirmisher (Veles). Quote Link to comment Share on other sites More sharing options...
gameboy Posted February 25, 2012 Report Share Posted February 25, 2012 My hardware is no problem, I have a 4G DDR3 memory is indeed the problem of Qbot game lag. Quote Link to comment Share on other sites More sharing options...
wraitii Posted February 25, 2012 Author Report Share Posted February 25, 2012 (edited) Okay, yay new version.Actual improvements this time around:-Attack plans are better, and I implemented a "raid the villagers" type of attack... It's much of a work in progress, like the attack plans in general (this is really the one area that's freakin' hard to implement... No wonder most AIs use "create an army and send it to enemy base" as a means of attacking.). Though not all civilizations will benefit from it (It uses cavalry swordsman, and I think only hellenes have an early access to those. It'll be changed in the next version). Test it out on Oasis.-Attack plans are now started if the "maximum" amount of units are built.-Generally more efficiency during attacks for attack plans and defense. -gatherers should generally stay on their resource for longer, ie the AI will change their task less often.-Queue manager changed again: more readable, more efficient, more modular (individual plans can be set as "most important"). Generally better and more efficient.Technical stuff:-Attack plans use their own queues, and generally rewrote those a lot. More modular now.-Cleaned up the code further-In the "reassignIdleWorker", it checks if they did something before and puts this as the top priority. This is good: workers will change tasks less often.-Tactics can now split and regroup groups after initialization.I'm not 100% sure every new stuff is bug free, but I playtested it fairly thoroughly, so it should work. Report any bug you encounter, as well as any weird AI reaction.Download LinkEdit: darn ,still a problem I left over with garrisonning... Replace line 285 of "mil-Tactics.js" by this:if (!entity || !entity.position())And line 279 also needs to be changed to this:if (!unit || (unit && !unit.position()) ){Speed improvements over the economic manager are a bit countered because of the modifications to attack plans, but overall on "time warp" it's still faster than qBot on my computer. Edited February 26, 2012 by wraitii Quote Link to comment Share on other sites More sharing options...
iap Posted February 25, 2012 Report Share Posted February 25, 2012 Is this AI deterministic, in the sense that if the player will play (theoretically) twice exactly the same, then the AI will react exactly the same? I was just thinking, if you have a modular queue manager, you can arrange the queue with a precise formula that will consider all the input to produce the perfect output, but you can make it adaptable, so it will learn during the game (or between games).Am I making sense or is it a completely different thing?(Sorry to burst in like that ) Quote Link to comment Share on other sites More sharing options...
Zaggy1024 Posted February 25, 2012 Report Share Posted February 25, 2012 @Gameboy: I doubt qBot is causing the game lag, probably just your hardware.Definitely not true. Currently, if you play with AI, it will cause lag. If the lag isn't bad from the beginning of the game, it'll only get worse as the game progresses, since the AI is trying to control more and more of the units it's created. Quote Link to comment Share on other sites More sharing options...
wraitii Posted February 25, 2012 Author Report Share Posted February 25, 2012 (edited) Is this AI deterministic, in the sense that if the player will play (theoretically) twice exactly the same, then the AI will react exactly the same? I was just thinking, if you have a modular queue manager, you can arrange the queue with a precise formula that will consider all the input to produce the perfect output, but you can make it adaptable, so it will learn during the game (or between games).Am I making sense or is it a completely different thing?You're certainly making sense, but I do not have the skills to make it "non-deterministic". I'm not sure there is a point either. I think the AI in AoE3 is a bit what I'm trying to achieve : deterministic, but able to store a few things (such as "when the player attacked") and sort of react to that. Optimally, I'd like to be able to do that and better, but I'm unsure I have the skills required (I'm not a real programmer... Hell, I'm not even a programmer at all, I'm studying economics.)I also have very little idea of what the team wants for their AI, though seeing what was already achieved, I think my ideas are not that faraway from theirs.@Zaggy1024 : indeed. Edited February 25, 2012 by wraitii Quote Link to comment Share on other sites More sharing options...
Pedro Falcão Posted February 26, 2012 Report Share Posted February 26, 2012 I got beat by Marilyn! Playing Oasis I as the persians against Marilyn as Hellenes (Alpha 8 since i had some troubles getting the last version from the svn). I'm not very good a player, but i have to say it really surprised me to see this AI in action. She detected my attacks and sent defense before i could even see one of her buildings (does she ignore the fog of war?). At the last minutes, i packed some skirmishers and archers to scort the rams and noticed she gone for the first units of the formation, leaving the rams free to go for the civ centre, even though when i hit the civ centre she sent a small pack of melee soldiers to bring my rams down. She didn't exactly got me beat, but after she broke my army, i resigned.Great work, wraitii, i think this is the way to go. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.