Codename: Gamma
Moderator: Defcon moderators
- Ace Rimmer
- level5
- Posts: 10803
- Joined: Thu Dec 07, 2006 9:46 pm
- Location: The Multiverse
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
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.
- Ace Rimmer
- level5
- Posts: 10803
- Joined: Thu Dec 07, 2006 9:46 pm
- Location: The Multiverse
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.
For example; instead of:
This: (the basic location of the whole African land territory, will be more specific, but you get the idea)
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.
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.
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.
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
- Ace Rimmer
- level5
- Posts: 10803
- Joined: Thu Dec 07, 2006 9:46 pm
- Location: The Multiverse
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.
-
- Site Admin
- Posts: 1783
- Joined: Sat Mar 14, 2009 1:48 am
- Location: North of the Wall
- Contact:
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.
- Ace Rimmer
- level5
- Posts: 10803
- Joined: Thu Dec 07, 2006 9:46 pm
- Location: The Multiverse
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.
- Ace Rimmer
- level5
- Posts: 10803
- Joined: Thu Dec 07, 2006 9:46 pm
- Location: The Multiverse
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.
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.
Smoke me a kipper, I'll be back for breakfast...
- Ace Rimmer
- level5
- Posts: 10803
- Joined: Thu Dec 07, 2006 9:46 pm
- Location: The Multiverse
- Ace Rimmer
- level5
- Posts: 10803
- Joined: Thu Dec 07, 2006 9:46 pm
- Location: The Multiverse
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
Edit: Thankfully, the documentation comes with the Bot. Phew!
Edit2: Ok, so I'm an idiot. SetActionTartget is not a command; SetActionTarget is. Of course, now I can launch planes. Whee!
And now, this morning, the Lua reference documentation is offline. http://www.corsix.org/defcon_luabot/documentation.html
Edit: Thankfully, the documentation comes with the Bot. Phew!
Edit2: Ok, so I'm an idiot. SetActionTartget is not a command; SetActionTarget is. Of course, now I can launch planes. Whee!
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.
Who is online
Users browsing this forum: No registered users and 4 guests