It is currently Mon Apr 23, 2018 9:09 am Advanced search

One more strategy guide!

Share and discuss ideas for your entries here.

One more strategy guide!

Postby RebelXT » Mon Oct 04, 2010 3:49 am

Hey All,

I'm hoping this "brain dump" will help those who are just getting started with the challenge and also some who are trying to break TOP 100. The depth of this AI challenge is so great that there is a lot of room for sharing.

Please read excellent strategy posts by Obeleh and dmj too!

viewtopic.php?f=17&t=593
viewtopic.php?f=17&t=814#p5102

There are multiple "aspects" of the game: Offense, Defense, and Expansion.

Expansion

Expansion is all about capturing neutral planets.

* The bigger the planet, and the fewer ships it has, the better. Also, the closer the planet is, the better since you can get there quicker and start producing more ships.
* It's very important to capture a good number of desirable neutral planets during first few turns of the game. Production rate is the most important metric in the game.
* Usually a bot would send multiple fleets on the first turn.
* Normally you want to send X+1 ships to a neutral planet with X ships to capture it
* If you want to capture a planet that is exactly halfway you might want to send more than X+1 ships

Advanced strategy:

* If you have sent a fleet to a neutral planet, and enemy has countered, you have to reinforce your attack with additional fleets
* If enemy makes a mistake of attacking a neutral planet which is relatively close to your planets, you can "steal" neutral planet by sending a fleet which would arrive one turn later than enemy's initial attack.

Defense

Defense is very important since losing a planet to the enemy means a huge ship production differential drop.

* Send reinforcement fleets from multiple planets, but send as few ships as possible required to defend the planet. "On the edge" defense means that you send reinforcement so small that your planet's ship count drops down to zero upon enemy fleet arriving, but you don't lose the planet. Cool!
* Look at all the enemy fleets attacking your planet, and calculate exactly how many ships you need to send and from which planets to reinforce planet under attack.
* It's possible to perform "simulation" to calculate planet's future status in X moves, so you can figure out exactly how many ships are needed to reinforce
* Send reinforcements from planets which are not under attack or have "spare" ships

Offense

Offense is all about attacking enemy planets.

* If you want to capture enemy planet, you want to calculate how many ships it will have by the time your attacking fleet(s) reach enemy planet. Both enemy planet's production rate and enemy's reinforcement fleets have to be taken into account.
* The bigger the planet, and the fewer ships it has, the better.
* Transit time (or distance) is a huge factor. You don't want to attack enemy planets deep inside their territory since it takes very long time for your attack to reach enemy's planet, and enemy has enough time to reinforce it.

Advanced strategy

Ship funneling in advanced strategy designed to prevent keeping your spare ships deep behind the front lines. I.e. you want to centralize your forced and keep most of your ships close to the strongest enemy planets since this allows you to perform quicker short-distance attacks with bigger fleets.

Defense is normally not jeopardized by ship funneling since you have enough time to send some of your ships back to your back planets under attack.

Ship funneling also helps to minimize risk of having too many ships in the air since long travel is bad (you lose control of your ships while they are in flight).

Metrics

There are tons of metrics which can be calculated upon every turn to help decision making. The same metrics apply to both you and enemy, and it's important to calculate metrics for both sides. Some of the most important metrics are:

* Total ship count
* Total production rate
* Ships needed to defend each planet under attack
* Spare ships for each planet (i.e. how many ships we can send elsewhere without risking losing a planet)

Bot writing best practices

Logging

Make sure you can run your bot with logging enabled (debug mode) so that you can log useful information helpful to understand bot's decisions. If your bot sends a fleet from planet X to planet Y, you need to be able to tell why it sent the fleet (offense, defense, etc).

Versioning

It's a good idea to version your bot since there are so many potential strategies and ways to tweak bot's code. Simple linear versioning schema should work.

Testing

* Test against example bots on all 100 maps and keep track of how many maps your bot wins, and how many turns it takes to win on average
* Run your new bot's version against the previous version(s) to make sure there is an improvement.

Public TCP server

This server allows to run your bot against other people's bots without having to upload your code to official challenge servers. This is AWESOME since you get to run you bot locally, so you see all of the logging info, and you see if your bot times out, crashes, or issues invalid command.

See http://www.benzedrine.cx/planetwars/ for more details. Kudos to dhartmei for hosting the server!

Performance

Caching becomes extremely important when you start doing lots of calculations upon every turn. Distances between planets, nearest enemy planets, etc, etc. It's very easy to get over 1 second time limit if caching is not used.

Using Python?

If you like Python, please consider using unofficial python starter kit since it provides a lot of boilerplate code for you out of the box. See viewtopic.php?f=18&t=459 for details. Kudos to Ulope and others for excellent work!

My fork of the python kit (http://github.com/apinkin/planetwars-python-kit) includes the following:

* test scripts to test your bot against all example bots on all maps
* DanielVF's HTML5 canvas visualizer (replacing java game viewer)
* TCP server client
* Script for replaying a server game locally

Hope this helps someone!

If you have read this far, you are REALLY addicted to this challenge, and you deserve an insider's secret advice! Please check out Galcon forums which have some excellent advice on strategy by human players. There is a lot to learn by just playing the Galcon game against human players. Watch some high rank people play, and you will see a lot of very advanced strategies in action.

http://www.galcon.com/forums/14/15/

The following threads are great start:

http://www.galcon.com/forums/14/15/905/?cur=0
http://www.galcon.com/forums/14/15/2711/?cur=0

-rebelxt
RebelXT
Colonel
 
Posts: 81
Joined: Fri Sep 10, 2010 2:05 pm

Re: One more strategy guide!

Postby Evgenius » Mon Oct 04, 2010 1:50 pm

This is the best strategy guide so far!
Evgenius
Major
 
Posts: 37
Joined: Fri Sep 10, 2010 10:16 am
Location: Minsk, Belarus

Re: One more strategy guide!

Postby RebelXT » Mon Oct 04, 2010 2:35 pm

Thanks, Evgenius!

I also wanted (but forgot) to reference your great post on making bot deterministic.

viewtopic.php?f=18&t=788&start=0
RebelXT
Colonel
 
Posts: 81
Joined: Fri Sep 10, 2010 2:05 pm


Return to Strategy

Who is online

Users browsing this forum: No registered users and 1 guest

cron