Get ready! Ultimate Hero 2008 Tournament - December 30th

Forums :: Desktop :: Mods :: Release: botwar

You must sign in to post.

Release: botwar :: May 27, 2007 @ 10:37am

Ensign philhassey

Joined: Nov 30, 2006
Posts: 800
Location: Zarcon

Hey - I've put together a BotWar mod so you can watch bots duke it out at high speed (generally games take 5-10 seconds!)

BotWar

So far it appears that ThirdParty's cobra bot is the best :)  I'll look into porting the in-game bots so I can see how they fair against it.

Get yourself ready, because pretty soon I plan on annoucing an official "BotWar" competition!

I've updated this mod with the main in-game bot "bot5000" and touched some minor things up a bit.

- Phil
post updated on May 27, 2007 @ 5:50pm
Re: Release: botwar :: May 27, 2007 @ 6:15pm

Ensign thirdparty

Joined: Dec 20, 2006
Posts: 279
Location: Eastern U.S.A.

It's a little buggy.  For your convenience I've written a variant of Kamikaze which exploits those bugs.  Here it is.  [Edit: I've removed Cheatbot since Phil has now seen the bugs.]  It uses four distinct cheats; you can comment out all but one of them if you want to see what each does.

- "cheat_horde" botwar allows cheatbot to send more ships from a planet than it owns (Suggested fix: see any of my released mods)
- "cheat_tamper": botwar allows cheatbot to directly modify planet ships, production, and owners
(Suggested fix: I don't know.  Somehow make the level read-only to bots, or pass the bot a fake copy.)
- "cheat_junk": botwar allows cheatbot to issue orders to other players' ships
(Suggested fix: probably similar to the fix for direct modification.)
- "cheat_winner": botwar allows cheatbot to modify its own win count
(Suggested fix: instead of making win counts variables which belong to the user in question, make them seperate)

Of course, we _could_ simply proof-read bots to make sure that they don't cheat.  But it'd be better if Botwar were robust enough that they didn't work in the first place.  With a sufficiently-complicated bot, it would be hard to tell for sure if it was doing anything fishy.
post updated on May 30, 2007 @ 8:40am
Re: Release: botwar :: May 27, 2007 @ 6:26pm

Ensign philhassey

Joined: Nov 30, 2006
Posts: 800
Location: Zarcon

I'll fix cheat_horde and cheat_junk for sure .. Since those should be "filtered" automatically by the level.fleet / level.redirect methods.  Doing something wrong with those would be easy enough.  (From watching some bot wars, I think some of my bots are doing bad plays by mistake.)

As for the other two - I think we'll leave 'em as "honor system" items.  I mean - if someone wins "the bot war", people are going to want to check out the code.  And if the code contains a cheat, boy are they gonna get it ;)  (The only way to fix the cheat_wins would be to fix cheat_tamper, and fixing cheat_tamper would be a lot of work!)

- Phil
post updated on May 27, 2007 @ 6:26pm
Re: Release: botwar :: May 27, 2007 @ 6:33pm

Ensign philhassey

Joined: Nov 30, 2006
Posts: 800
Location: Zarcon

Okay - I fixed the cheat_horde issue.  Looks like cheat_junk is the same issue as the other two, so I'm not so sure I can fix that without some hassle.

Anyway - that first one was a pretty important one.

- Phil

p.s. it's a lot of fun to run a war at 8x or 12x .. because then you can still watch the battles pretty well.
post updated on May 27, 2007 @ 6:34pm
Re: Release: botwar :: May 27, 2007 @ 6:40pm

Ensign thirdparty

Joined: Dec 20, 2006
Posts: 279
Location: Eastern U.S.A.

By the way, I'm trying to splice bot5000 into a mod like Classic so I can play against it, and am having trouble doing so: it raises odd exceptions.  What gives?

(edit: rest of post obviated by phil's latest post)
post updated on May 27, 2007 @ 6:40pm
Re: Release: botwar :: May 27, 2007 @ 6:41pm

Ensign philhassey

Joined: Nov 30, 2006
Posts: 800
Location: Zarcon

btw - just uploaded an update - with that fix as well as a cool tweak so you can change the speed in game with the number keys.  Fun Fun Fun.
Re: Release: botwar :: May 27, 2007 @ 6:42pm

Ensign philhassey

Joined: Nov 30, 2006
Posts: 800
Location: Zarcon

By the way, I'm trying to splice bot5000 into a mod like Classic so I can play against it, and am having trouble doing so: it raises odd exceptions.  What gives?

(edit: rest of post obviated by phil's latest post)


Can paste in the exception (at least the ending of it)?  It should be saved in your mods/data/log.txt file.

Thx.
Re: Release: botwar :: May 27, 2007 @ 6:58pm

Ensign thirdparty

Joined: Dec 20, 2006
Posts: 279
Location: Eastern U.S.A.

Yep, that's fixed Horde, which is the only one that could really happen by accident.  (Ah, it was so beautiful to watch, though: an expanding ring of death flashing outward from the homeworld like wildfire.  Only Kamikaze could survive the initial burn, and even it had no real chance.)

When I spliced Bot5000 into Classic, this error happened when I loaded the mod:
File "level.py" line 43, in init
File "bot5000.py" line 33, in init
File "bot5000.py" line 17, in change
AttributeError: Planet instance has no attribute 'rect'
['exec: g.init()']
post updated on May 27, 2007 @ 7:01pm
Re: Release: botwar :: May 27, 2007 @ 7:13pm

Ensign thirdparty

Joined: Dec 20, 2006
Posts: 279
Location: Eastern U.S.A.

Uh, wait a minute.  I just saw Bot5000 with a negative planet population.  Does your code really say "f.ships = max(from_.ships,ships); from_.ships -= ships"?  That's terrible, really completely terrible.  It ought to be "f.ships = min(from_.ships,ships); from_.ships -= f.ships".

Also, how about a countdown timer for when no planets are left?  Ending the game instantly isn't fair, often it's possible to come back from not having any planets if one still has lots of ships.  (For example, it's an entirely legitimate move against a Kamikaze with a better starting position than your own to try to swap places with it.  But under your rules, doing so yields a loss.)
post updated on May 27, 2007 @ 7:13pm
Re: Release: botwar :: May 27, 2007 @ 7:19pm

Ensign thirdparty

Joined: Dec 20, 2006
Posts: 279
Location: Eastern U.S.A.

So far it appears that ThirdParty's cobra bot is the best

Not only that: I think my lass bot is second-best.
Re: Release: botwar :: May 27, 2007 @ 9:19pm

Ensign philhassey

Joined: Nov 30, 2006
Posts: 800
Location: Zarcon

third - 

To get bot5000 to work, add a self.sync() before the bot is inited (see my level.py in botwar)

I fixed that bug (oops!)  How silly of me.

Regarding "end of game conditions" I gave it a bit of thought, a couple things come to mind:

1.  Games need to have a time limit for botwars, 'cause if you get to lousy bots, they could go at it forever, slowing down the war.

2.  Timeouts should result in a winner and a loser usually, otherwise a bot might be programmed to try to stalemate games it wasn't going to win.  And that just isn't "the Galcon way".  Likely this could be done the same way /stop is calculated - person with the most production wins.

3.  Need to have fair ending conditions for the game that don't hint at any particular strategy.  I suspect if #2 is fixed proper, I could just use the ending conditions from "in-game", because those seem to be just fine.

Thoughs?
Phil
Re: Release: botwar :: May 27, 2007 @ 10:04pm

Ensign thirdparty

Joined: Dec 20, 2006
Posts: 279
Location: Eastern U.S.A.

I think that the rules for the botwar game should be as much like the rules for the net game as possible.  But I agree on the need for a time limit followed by effectively a "/stop".
Re: Release: botwar :: May 28, 2007 @ 12:10am

Ensign philhassey

Joined: Nov 30, 2006
Posts: 800
Location: Zarcon

I think that the rules for the botwar game should be as much like the rules for the net game as possible.  But I agree on the need for a time limit followed by effectively a "/stop".


I just posted an update .. Check it out .. It's not quite the same as in the net game - since it allows dragging out the game for the full five minutes (no 30 second countdown).  

But it does good tie-breaking "production first, then ships" for deciding the winner of a round.  Please take a look and see if I didn't do something stupid again ;)

Phil
Re: Release: botwar :: May 28, 2007 @ 12:25am

Ensign philhassey

Joined: Nov 30, 2006
Posts: 800
Location: Zarcon

-- interestingly enough, my simple kamikaze bot seems to do pretty well.  I might have to set up a basic genetic algorithm to play with the 3 factors I have in that basic bot and see if I can find the optimal numbers.
Re: Release: botwar :: May 28, 2007 @ 12:26am

Ensign philhassey

Joined: Nov 30, 2006
Posts: 800
Location: Zarcon

-- on a whole different angle, is which bots are:

1. The funnest to play against a human
2. The hardest to play against a human
Re: Release: botwar :: May 28, 2007 @ 3:41am

Cabin Boy carn

Joined: Dec 16, 2006
Posts: 74
Location: LA

Thirdparty, when you get a chance come by #galcon on irc.freenode.org -- We have a working implementation of the galcon client protocol and currently have a simple bot that plays like zanthor. Phil has suggested that we make the multiplayer bot api identical to the mod bot api so that anyone who writes a mod bot can have their bot play online as well. Come help.
Re: Release: botwar :: May 30, 2007 @ 4:51pm

Ensign thirdparty

Joined: Dec 20, 2006
Posts: 279
Location: Eastern U.S.A.

botwar is occasionally throwing an exception (especially when running on large galaxies):
"level.py" line 112 in loop
"level.py" line 165 in stop
TypeError: comparison function must return int.


My guess is that the int(x) function is failing to produce an integer for sufficiently large values of x.

line 164 of level.py read:
return int(round(p * 1000000 + s))

I replaced it with:
if p * 1000000 + s > 0: return 1
elif p * 1000000 + s < 0: return -1
else: return 0

and this seemed to fix the problem.
Re: Release: botwar :: May 30, 2007 @ 6:51pm

Ensign philhassey

Joined: Nov 30, 2006
Posts: 800
Location: Zarcon

Thanks - added that in.  Will post sometime later...
Re: Release: botwar :: May 30, 2007 @ 10:18pm

Ensign thirdparty

Joined: Dec 20, 2006
Posts: 279
Location: Eastern U.S.A.

Here's a suggested modification to BotWar:
BotTourney

I've added an option for "tournament mode".  What it does is plays each level it generates with every possible mapping of positions to bots.  (For example, if you have bots A, B, and C in the game, and you're set to play one-on-one's, then each level will be played six times: once with A blue and B red, once with A blue and C red, once with B blue and A red, once with B blue and C red, once with C blue and A red, and once with C blue and B red.

It's not as interesting to watch, but it has the effect of eliminating luck due to pairings or to uneven starting positions: scores better reflect bots' skill levels.
Re: Release: botwar :: May 31, 2007 @ 11:12am

Ensign philhassey

Joined: Nov 30, 2006
Posts: 800
Location: Zarcon

Here's a suggested modification to BotWar:
BotTourney

I've added an option for "tournament mode".  What it does is plays each level it generates with every possible mapping of positions to bots.  (For example, if you have bots A, B, and C in the game, and you're set to play one-on-one's, then each level will be played six times: once with A blue and B red, once with A blue and C red, once with B blue and A red, once with B blue and C red, once with C blue and A red, and once with C blue and B red.

It's not as interesting to watch, but it has the effect of eliminating luck due to pairings or to uneven starting positions: scores better reflect bots' skill levels.


Yeah - that would likely yield statistically meaningful results much quicker.  Looks good.
Re: Release: botwar :: Jun 1, 2007 @ 8:12am

Ensign thirdparty

Joined: Dec 20, 2006
Posts: 279
Location: Eastern U.S.A.

I was watching a botwar and accidentally rotated my mouse's scrollwheel--and it threw an exception:

File "level.pyc", line 778, in event
  File "user.pyc", line 110, in event
TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'
['exec: g.event(e)']
Re: Release: botwar :: Jun 1, 2007 @ 11:46am

Ensign thirdparty

Joined: Dec 20, 2006
Posts: 279
Location: Eastern U.S.A.

So, uh, are you sure you want to call the bot loops every single frame?

If you have a botwar tournament, I'm going to enter a bot of Cobra's complexity.  Perhaps other people will too.

By default, Cobra is set to act once a second: once every 32 frames.  But Cobra set to act once every 24 frames is decidedly stronger than Cobra set to act once every 32 frames.  Do you see the problem?

With Cobra set to act once per second, on a large map there's not much point in cranking the speed up past maybe 6 game seconds per real second: it's just too processor-intesive.  (At least on my somewhat-aging laptop.)

If Cobra were set to act once per frame, and were playing against another bot of the same processor-intensity, then, on a large map, each second of game time would take something like ten seconds of real time.

-----

It shouldn't be the bots' decision how often to reappraise the situation.  Consider calling each bot's loop function only once per second instead of once per frame, so we can have them act every time they're called.
Re: Release: bottourney :: Jun 3, 2007 @ 8:17am

Ensign thirdparty

Joined: Dec 20, 2006
Posts: 279
Location: Eastern U.S.A.

The latest version of "bottourney" also has another minor feature: a checkbox called "variation".  If it's checked, then while levels generated will have approximately the number of planets, homeworld size, and homeworld ships indicated, they won't be exact.  This allows bots to be tested on multiple kinds of levels at once.
Re: Release: botwar :: Jan 3, 2008 @ 3:58pm

Ensign sunpin

Joined: Jan 2, 2008
Posts: 6
Location: Dallas, TX

There's a python module called timeit -- could a Galcon mod access it?  If so, you could do something like budget each bot 0.5 seconds of execution time for each second of game time.  They could still go over their time limit, but then they would't get called on subsequent clock ticks until they'd paid off the time debt (maybe with interest).  That way a simplistic but efficient bot could still go toe-to-toe with a bot that spent time always trying to calculate the perfect move.  It keeps the exercise approachable to novices, and prevents it from mushrooming into the uberbot scenario Thirdparty described.
Re: Release: botwar :: Jan 3, 2008 @ 8:24pm

Ensign philhassey

Joined: Nov 30, 2006
Posts: 800
Location: Zarcon

Okay - I've made a note to add a get_time() function to the mods section for next release.  Not sure when that will be, but for now I wouldn't worry about it until we get a bot that is that wasteful.

Thanks!
Phil
Re: Release: botwar :: Sep 10, 2008 @ 2:28am

Ensign m2tm

Joined: Sep 6, 2008
Posts: 52
Location: Regina, Sk, Canada

Once per second might be a bit slow for the bots to check the situation, once per quarter second might be better.  The reason would be that a few ships can land in a second, but many fewer can land in a quarter second and this is also not a short enough time to allow for a ton of instantaneous course changes etc.

Time is kind of moot as long as a standard is chosen, but once per frame is a bit crazy because if you have a bot who is checking trajectories etc and altering course accordingly it would have infinite control over its ships.  Is this a bad thing?  If it is and you want to introduce a bit of "thinking" time between each move a full second drags on long enough for the game state to change significantly and then you have to wait an entire second longer to react to an attack launched by another bot.

Maybe look at the amount of time it takes a starter class planet to tick ships and set the bots thinking time to that.  In that way two bots could equally exchange ships to infinity via counter attacks which sounds like a bug, but really just presents the optimal response time between wasteful and excessive.

Just my thoughts.

You must sign in to post.