Joshua

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

Moderator: Defcon moderators

martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm

Postby martin » Mon Feb 22, 2010 4:53 pm

Gogo triple post! I gave up on trying to write the bot in C# a while a go, I don't know enough C++ or Lua to be able to get sockets or pipes working. So, today, I started learning Lua (it was a really boring double lecture at 9am, what better time to teach myself a new language?). It's actually not a bad language, although it gives you plenty of leeway to write really crap code ;)

I've started laying out a nice modular framework for Joshua, I've rewritten the city survey code, and deleted the crappy forces deployment code that I had in there before.

First problem I have encountered, all cities seem to have a population of 4 million, anyone else getting that?
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 » Mon Feb 22, 2010 4:56 pm

martin wrote:... although it gives you plenty of leeway to write really crap code ;)

Wha? This is probably the only reason I can do anything with the bot. :p

martin wrote:First problem I have encountered, all cities seem to have a population of 4 million, anyone else getting that?

I'll check, haven't done anything with population before except with existing whiteboard funtions (e.g., lat, long / pop)

That tells me (the different circle/square sizes based on population) that it 'works'.
Smoke me a kipper, I'll be back for breakfast...
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm

Postby martin » Mon Feb 22, 2010 5:00 pm

Ace Rimmer wrote:
martin wrote:... although it gives you plenty of leeway to write really crap code ;)

Wha? This is probably the only reason I can do anything with the bot. :p


Well the code isn't object oriented, it's prototype based, which isn't bad, but newbies coders are gonna ignore that and write a procedural program, which will be horrible to maintain after a while ;)

Ace Rimmer wrote:
martin wrote:First problem I have encountered, all cities seem to have a population of 4 million, anyone else getting that?

I'll check, haven't done anything with population before except with existing whiteboard funtions (e.g., lat, long / pop)

That tells me (the different circle/square sizes based on population) that it 'works'.


I draw circles around citites too, and they're all the same size, even though they're based on pop. I printed out the populations of all cities in my table, and they are definately all 4million.
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 » Mon Feb 22, 2010 5:06 pm

Which version of the Lua API are you using? The new 0.3?
Smoke me a kipper, I'll be back for breakfast...
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm

Postby martin » Mon Feb 22, 2010 5:11 pm

I have no idea, how do I find out?
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 » Mon Feb 22, 2010 5:14 pm

Well, I still have both folders and zip files, which are labeled. The main.lu file is the only place I know to really look as there's no version indication.

version 0.2:

Code: Select all

-- Make require look in this folder
package.path = [[AI\luabot\?.lua;"]] .. package.path


version 0.3:

Code: Select all

-- Make require look in this folder for .lua files
package.path = debug.getinfo(1, "S").source:match[[^@?(.*[\/])[^\/]-$]] .."?.lua;".. package.path
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm

Postby martin » Mon Feb 22, 2010 5:17 pm

I have

Code: Select all

package.path = [[AI\luabot\?.lua;"]] .. package.path


Which I guess means I'm using the old version :(

Do you have a handy link to the download for the latest version?
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 » Mon Feb 22, 2010 5:20 pm

I thought you subscribed to the mailing list?

Here you go.

Also, I'm pretty sure it worked correctly in 0.3. O_o I'll try to test it a bit later and see what it says for me.
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm

Postby martin » Mon Feb 22, 2010 5:23 pm

I do, I'd forgotten all about that.

Thanks, I'll give this a go and see what happens...

EDIT::

Tried that, bot still runs fine, but cities still all have4 mil population. Was a new version of the defcon bot executable ever release? If so, then I guess I might have an outdated version of the game itself? :s
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 » Mon Feb 22, 2010 6:09 pm

martin wrote:Tried that, bot still runs fine, but cities still all have4 mil population. Was a new version of the defcon bot executable ever release? If so, then I guess I might have an outdated version of the game itself? :s

Not that I'm aware of. I'll try it now; I think I have a free moment. I'll post in just a minute.

Edit: Silly me, I completely forgot about my psuedo targeting code, which works already (both 0.2 and 0.3)

Code: Select all

   local allCities = GetCityIDs()
   local us = GetOwnTeamID()
   for i, city in ipairs(allCities) do
      local pop = city:GetCityPopulation()
      if city:GetTeamID() == us then
         table.insert(myCities, city)
      else
         table.insert(enemyCities, city)
         if pop >= 2500001 then
            table.insert(targetCities, city)
         end
      end
   end

SendChat(#targetCities) has been telling me 19 cities for quite some time (which is less than 25).

Either way, test results with 0.2:

Code: Select all

<snip>
            table.insert(targetCities, city)
         end
      end
      SendChat(pop)
   end


Image

Do you have a setting in the advanced settings menu changed or a command line argument changing the populations/city arrangement?
martin
level5
level5
Posts: 3210
Joined: Fri Nov 19, 2004 8:37 pm

Postby martin » Mon Feb 22, 2010 6:25 pm

Ok, using a default game mode and default score mode, I am launching with special command line options as far as I can see. I started a game with me as a player (no bot, except default ones). All cities show 4.0M population when I hover over them...

EDIT:: Well well well, I copied across the dat files from my full copy of defcon, and the bot version has correct city numbers. I wonder how I broke that :/
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 » Mon Feb 22, 2010 6:27 pm

Screenshot? I really don't believe it. :P

Edit: Never mind then. :P
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 » Mon Feb 22, 2010 8:36 pm

Martin -

If you were in LUA then the 3 of us can collaborate :D Ace and I have already done a lot of code compare as you can see and we both have made some decent progress.

Still no combat yet. I am trying to write from Defcon 5 forward; Ace has skipped ahead to other more violent parts of the game :D

I would like to combine code streams with others, to help unite goals and collaborate on ideas to generate a working bot faster.
User avatar
Ace Rimmer
level5
level5
Posts: 10803
Joined: Thu Dec 07, 2006 9:46 pm
Location: The Multiverse

Postby Ace Rimmer » Mon Feb 22, 2010 8:40 pm

I haven't really skipped ahead, I'm just working in 'parts'. :p

That is placement first (thought I had worked that out, but obviously not :P ), movement next, then combat. I just had an itch to scratch with regard to launching, so I tried to implement that bit too. :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 » Mon Feb 22, 2010 8:50 pm

Ace Rimmer wrote:I haven't really skipped ahead, I'm just working in 'parts'. :p

That is placement first (thought I had worked that out, but obviously not :P ), movement next, then combat. I just had an itch to scratch with regard to launching, so I tried to implement that bit too. :wink:


Just joshin' ya...but you raise an interesting point. Having the bot react and play defensive is one thing...having it plan out multipronged naval strategies is the really hard part for me. I can't wrap my head around how to really kick that off in simple bite-sized pieces.

Return to “AI Bots”

Who is online

Users browsing this forum: No registered users and 4 guests