Joshua

Come in here to talk about your sky-net style world-destroying super bots!

Moderator: Defcon moderators

User avatar
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm
Location: ::1
Contact:

Postby martin » Wed Feb 24, 2010 12:16 am

Ok, so I did a bit of work on the coroutines stuff, I didn't like the way it worked before so basically rewrote it.

If you check out the multithreading.lua in Joshua, you'll see that all functions are now in a single table acting as a namespace (globals are eeeeeevil). The most important change is timing, you can set the time that the tasks have to execute, it will then keep executing tasks until that time is exceeded. If yield is called when there is still spare time, it will ignore the yield, and if a task finishes when there are more in the queue it will start the next task and so on. This all sound good, except that in practice I have found that using a time of anyhting larger than 1 millisecond will crash defcon, which is unfortunate. 1ms is a surprisingly long time, however, and some of my long tasks take much less time to execute now :D

EDIT:: If you guys nab the multithreading file off the svn, feel free to use it.

My only advantage writing Joshua is I'm a far more experienced coder, why am I giving these benefits away? ;)
GENERATION 22:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
User avatar
roflamingo
level3
level3
Posts: 404
Joined: Fri Jan 19, 2007 10:25 am

Re: Joshua

Postby roflamingo » Wed Feb 24, 2010 12:25 am

martin wrote:my bot, called Joshua


I think of it as CatBot.
User avatar
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm
Location: ::1
Contact:

Postby martin » Wed Feb 24, 2010 2:06 am

CatBot? :/

What I really came here to say:

I've improved my multithreading module to execute tasks strictly in the order they were issued. Which is really really helpful!

Edit::

Ok, so I said that a queue for in order execution was useful, here's an example, this is part of my placement code (obviously drawing a box isn't really a long task, it's just here for an example):

Code: Select all

local bound
Multithreading.StartLongTask(function()
   bound = GenerateCityBoundingBox(JoshuaInstance)
end)
      
Multithreading.StartLongTask(function()
   whiteboard.drawBox(bound.minLongitude, bound.minLatatitude, bound.maxLongitude, bound.maxLatatitude)
end)


So, as you can see, I can logically divide up my big task into a series of smaller tasks
GENERATION 22:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
User avatar
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm
Location: ::1
Contact:

Postby martin » Wed Feb 24, 2010 6:56 pm

Work Log:

Been working on the unit placement code, at the moment the bots scans the bounding box around all allied cities, and generates a score for every integer location in the box. It then finds the highest scoring position and sticks a silo there, it keeps on until there are no more silos left. I have a pretty crappy silo placement system at the moment, I'll be working on that next, for now I need a break from 5 hours of Lua coding ><
GENERATION 22:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
User avatar
Ace Rimmer
level5
level5
Posts: 10803
Joined: Thu Dec 07, 2006 9:46 pm
Location: The Multiverse

Postby Ace Rimmer » Wed Feb 24, 2010 6:58 pm

martin wrote:Work Log:

Been working on the unit placement code, at the moment the bots scans the bounding box around all allied cities, and generates a score for every integer location in the box. It then finds the highest scoring position and sticks a silo there, it keeps on until there are no more silos left. I have a pretty crappy silo placement system at the moment, I'll be working on that next, for now I need a break from 5 hours of Lua coding ><

Why not do what I do and find the first best position and place around that, instead of 'first best', 'second best', etc. :?:
Smoke me a kipper, I'll be back for breakfast...
User avatar
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm
Location: ::1
Contact:

Postby martin » Wed Feb 24, 2010 7:01 pm

Well your arrangement will always generate a ring of silos, I was looking for something a little more flexible than that, if I up the score just around a silo, then I can increase the probability of a ring. However, if there was a map with two really huge cities a long way apart I would probably end up with 2 rings. It's all in the scoring function
GENERATION 22:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
User avatar
Ace Rimmer
level5
level5
Posts: 10803
Joined: Thu Dec 07, 2006 9:46 pm
Location: The Multiverse

Postby Ace Rimmer » Wed Feb 24, 2010 9:44 pm

martin wrote:Well your arrangement will always generate a ring of silos ...

Actually, my arrangement will [REDACTED] and [REDACTED], thus allowing [REDACTED]. So you see, while you think yours is more flexible, it's really just more 'haphazard'. :wink:

Edit: In truth, yours is just more flexible in terms of what game mode is being played and only with regard to game mode; it can place in any/all setups (or should be able to). While mine is more restricted at that level, it's much more flexible within the game mode than you would initially think.
Smoke me a kipper, I'll be back for breakfast...
User avatar
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm
Location: ::1
Contact:

Postby martin » Wed Feb 24, 2010 10:15 pm

It might be useless flexibility, in which case I can swap out silo placement for a different method later. Coming up with a good score function is difficult, and it's probably gonna need a genetic algorithm or something to pick decent values, which is more effort than I'm really willing to put into this.
GENERATION 22:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
User avatar
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm
Location: ::1
Contact:

Postby martin » Fri Feb 26, 2010 12:35 am

I spent today porting some code over from C#, a min-max-heap, which allows efficient extraction of the largest and smallest items from a large set of values (ie. I can mess with heaps of about 3000 items without a single yield, pretty efficient). So now I can just throw score values for every point in my territory into the heap, and pull out the maximum one.

Next, I'm going to move away from building placement and play with air patrols
GENERATION 22:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
User avatar
roflamingo
level3
level3
Posts: 404
Joined: Fri Jan 19, 2007 10:25 am

Postby roflamingo » Fri Feb 26, 2010 1:48 am

Sounds like Ace borrowed some code :D

I wouldn't split up silos to guard 2 large cities.
User avatar
Ace Rimmer
level5
level5
Posts: 10803
Joined: Thu Dec 07, 2006 9:46 pm
Location: The Multiverse

Postby Ace Rimmer » Fri Feb 26, 2010 2:44 am

Actually, I haven't even seen that new code, yet. :wink:
Smoke me a kipper, I'll be back for breakfast...
User avatar
roflamingo
level3
level3
Posts: 404
Joined: Fri Jan 19, 2007 10:25 am

Postby roflamingo » Fri Feb 26, 2010 5:28 am

Right. Well if you want any placement code, I will trade you for some navy code. 8)
User avatar
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm
Location: ::1
Contact:

Postby martin » Fri Feb 26, 2010 6:58 pm

Ace, how are you retrieving unit IDs for things once you've placed them (specifically airbases). PlaceStructure doesn't return a unitID which I expected it to, are you placing all structures and then going through a list of all units, pulling out just the airbases?
GENERATION 22:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
User avatar
Ace Rimmer
level5
level5
Posts: 10803
Joined: Thu Dec 07, 2006 9:46 pm
Location: The Multiverse

Postby Ace Rimmer » Fri Feb 26, 2010 9:22 pm

martin wrote:Ace, how are you retrieving unit IDs for things once you've placed them (specifically airbases). PlaceStructure doesn't return a unitID which I expected it to, are you placing all structures and then going through a list of all units, pulling out just the airbases?

Yep, exactly what I'm doing. It only takes half a tick to do it.

For the navy code, I'm not even looking in any tables, rather using GetAllUnits() and TeamID() ~= or == to "us".
Smoke me a kipper, I'll be back for breakfast...
User avatar
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm
Location: ::1
Contact:

Postby martin » Fri Feb 26, 2010 9:48 pm

Ok, well I implemented that, it's a bit of a pain though, I'd like to use my processing time for more useful things!

Next, I'm either going to play with air patrols, or guestimating positions of enemy silos from scouts (backtracking incoming shots)
GENERATION 22:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.

Return to “AI Bots”

Who is online

Users browsing this forum: No registered users and 1 guest