Codename: Gamma

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 » Tue Jan 19, 2010 11:33 am

This is Joshua.lua:

http://pastebin.com/m6ef7be4d

And this is main.lua:

http://pastebin.com/m6e13b5e3

Make no comments on the shitty code quality, please. :oops:
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 » Tue Jan 19, 2010 3:47 pm

Thanks!

martin wrote:Make no comments on the shitty code quality, please. :oops:

Well, seeing as I have no real knowledge or experience with code, it's all shiny to me. :wink:

Edit: You have "require utility", is there anything still in that script?
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 » Tue Jan 19, 2010 4:16 pm

woops!

http://pastebin.com/m55f08707

That's the utility, it's a modified version of the utility which is included with the luabot iirc.

By the way, these files are only live for one month, so make sure to copy em somewhere safe :)
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 » Tue Jan 19, 2010 11:20 pm

Question; is the math.random responsible for the utter slowness of placement? AceBot (not the real name) won't use complete random placement like the current AI does, but will use a very limited random placement, and I'm looking for a much faster way to get all units on the board.

Edit: I've worked out how to place all units in about *2 seconds, but for the life of me can't work out how to use SetState(), not sure how to obtain specific unitID's and/or the proper format to use.

*Instead of looking for a random place among the entire globe, narrow it down to specific regions, depending on the territory (and eventually depending on opponent/s territories).

I'd like to have a Bot up and running by next week and I should have most of Thursday to work on it (probably some tomorrow too) assuming I can get past this snag. Remember, I have absolutely no idea what I'm doing. :P

For example; instead of:

Code: Select all

      while GetRemainingUnits("AirBase") > 0 do
         SendChat("Deploying forces")
         while true do
            local x = math.random()*360-180
            local y = math.random()*360-180
            if (IsValidPlacementLocation (x, y, "AirBase")) then
               PlaceStructure (x, y, "AirBase")


This: (the basic location of the whole African land territory, will be more specific, but you get the idea)

Code: Select all

      while GetRemainingUnits("AirBase") > 0 do
         while true do
            local x = math.random(-16.1,50.1)
            local y = math.random(-34.5,37)
            if (IsValidPlacementLocation (x, y, "AirBase")) then
               PlaceStructure (x, y, "AirBase")


Of course, as I said above, eventually I only want the first ground unit (Silo) to be a pseudo random position and everything after that around it,based on all the players territories. There's only 30 possible 1v1 combinations, so it shouldn't be that hard. :P
User avatar
xander
level5
level5
Posts: 16859
Joined: Thu Oct 21, 2004 11:41 pm
Location: Riverside, CA, USA
Contact:

Postby xander » Wed Jan 20, 2010 1:45 am

Ace Rimmer wrote:Question; is the math.random responsible for the utter slowness of placement?

Looking at the code that you posted, it is not exactly math.random that is the problem (as you seem to have figured out). The problem is that the program picks a random location somewhere on the globe, then determines whether or not that location is valid. This almost certainly means that it is picking more bad locations than good, and has to run through the loop several times in order to get what it wants. A faster implementation might be to create a finite list or array of valid location for each continent, and have the computer pick from that list, or to create bounding boxes around each continent so that the choices of locations are more limited (which is what the second code block you have indicates that you have done).

xander
User avatar
Ace Rimmer
level5
level5
Posts: 10803
Joined: Thu Dec 07, 2006 9:46 pm
Location: The Multiverse

Postby Ace Rimmer » Wed Jan 20, 2010 2:04 am

xander wrote:A faster implementation might be to create a finite list or array of valid location for each continent, and have the computer pick from that list, or to create bounding boxes around each continent so that the choices of locations are more limited (which is what the second code block you have indicates that you have done).

Yeah, I plan on having a set of small co-ordinates for each continent (EU will be handled slightly different, obviously), maybe two or three from which the Bot will choose it's first silo position.

Or, like so:

1. Start Game
2. Determine territories being played (opponent and/or teammate)
3. Determine optimum 1st silo placement selecting a pseudo random position from multiple "boxes' (can't have the Bot too predictable).
4. Place remaining ground units in tight formations based on #2 and #3.

Of course, this all depends on figuring out the proper syntax for the referencing the right unitID. :roll:
User avatar
DTNC Vicious
Site Admin
Posts: 1780
Joined: Sat Mar 14, 2009 1:48 am
Location: North of the Wall
Contact:

Postby DTNC Vicious » Wed Jan 20, 2010 2:34 am

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

Postby martin » Wed Jan 20, 2010 11:00 pm

The placement code in the Joshua bot was very much a test just to check if I was using the APi methods correctly etc. Since placement is such a vital thing I planned to revisit it later when I had a deeper understanding of Defcon placement strategy and try to write one which actually takes into account enemy unit positions etc
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 » Thu Jan 21, 2010 12:10 am

Still, it was extremely helpful. :wink:

Do you know the proper way to obtain specific unitIDs? According to the debug mode, "Airbase1, Silo2, Fighter34", etc seems to be it, but that doesn't work.
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 » Thu Jan 21, 2010 11:49 am

What kind of data would you put *into* your function to get back a unitID? from the look of the Joshua source I am iterating through all unit IDs and then getting type, which seems to be the only way I ever do it :/
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 » Thu Jan 21, 2010 3:37 pm

My goal is to be able to reference specific units, i.e. AirBase 1 do this, AirBase 2 do this, etc. The SetState command is asking for "userdata", but alas, I have no idea what that means.

It looks like you created a table to pull the type from, correct? I've tried a number of things, including pulling the type from the table, but can't seem to get anything to work.

Edit: Just figured it out. I was able to change an airbase to Bomber mode. :D
Smoke me a kipper, I'll be back for breakfast...
User avatar
Ace Rimmer
level5
level5
Posts: 10803
Joined: Thu Dec 07, 2006 9:46 pm
Location: The Multiverse

Postby Ace Rimmer » Thu Jan 21, 2010 11:24 pm

Now, if only I could work out how to launch a plane. :roll:
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 Jan 22, 2010 10:06 am

If I remember correctly you need to set the action target of an airbase to somewhere. I can't quite remember though.
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 Jan 22, 2010 4:18 pm

I've tried entering Long/Lat separately, with another airbase, with the same airbase, with an integer (just the object ID of the airbase), just the airbase (same/diff), and the only message I keep getting is "nil value". Grrr!

And now, this morning, the Lua reference documentation is offline. http://www.corsix.org/defcon_luabot/documentation.html :cry:

Edit: Thankfully, the documentation comes with the Bot. Phew!
Edit2: Ok, so I'm an idiot. SetActionTartget is not a command; SetActionTarget is. :oops: Of course, now I can launch planes. Whee!
User avatar
xander
level5
level5
Posts: 16859
Joined: Thu Oct 21, 2004 11:41 pm
Location: Riverside, CA, USA
Contact:

Postby xander » Fri Jan 22, 2010 4:36 pm

Ace Rimmer wrote:SetActionTartget

Is that the command for fetching little fuity, cakey things?

xander
Last edited by xander on Fri Jan 22, 2010 4:40 pm, edited 1 time in total.

Return to “AI Bots”

Who is online

Users browsing this forum: No registered users and 1 guest