[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4586: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4588: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4589: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
[phpBB Debug] PHP Warning: in file /includes/functions.php on line 4590: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3765)
AI Challenge Forums • View topic - My First Strategy Guide

It is currently Sat Jan 20, 2018 5:10 am Advanced search

My First Strategy Guide

Share and discuss ideas for your entries here.

My First Strategy Guide

Postby Obeleh » Tue Sep 14, 2010 8:20 am

Hello. First off, I'd like to say how great the tournament is. So far it's been a lot of fun and very timeconsuming ;)

I wanted to write a piece to help the newcomers with some basic stuff. I think that the help that's given on the main page wont get you very far anymore. I hope there are people intreseted in contributing to this. Feel free to copy paste anything. I'd like it to mention your name when you make edits and I hope you'll mention mine too ;)
To the admins: Feel free to link to this on the site :)

So here it comes:


(and,...?)

I hope there's some usefull things inhere for beginners. Maybe even some people higher up. But I just hope it levels the playing field a little and that you learn from it. As a small disclaimer. I don't study AI neither have I read about it. This is just my own reasoning. I'll try to start with the the easy stuff and move up to the harder problems.




I have found logging to be my best friend in programming myBot ;) It's key to knowing what's happening. Make sure you log all errors. When I write a new strategy I put a try catch around it and make sure when something goes wrong that at least I know it was this or that method that failed. But don't just log errors. You will want to log as much as you can about that new strategy you're implementing. If you see your bot make a decision that shouldn't happen you should be able to read the log and see what conditions led your bot to this decision. You can turn off the decision logs after you're sure it works but there are a few things I always log.

a. The last 5 digits of the current system time in miliseconds
b. The current strategy that's giving orders for example: "Offense orders" or "Defense Orders". This way I know in what context an issueorder has been given
c. Log the issueOrder commands. So that you know from,to and numships
d. The starting conditions (SEE XXX)




In the beginning of a round make sure you know how good you are doing compared to your opponent. This way you can make sure you dont go on a full out offense when you're behind. Things you want to know are:
a. Your total shipcount
b. Ships enroute
c. Average shipcount per planet
d. Planetcount (you/neurtal/enemy)




I know this is programming in general but allways abide by this rule from Donald Knuth: "Programs should be written for people to read, and only incidentally for machines to execute."
And I dont know who wrote this:
"It's easier to opitimize correct code that to correct optimized code."
So make sure you can understand what you write and the rest is secondary




Calculate how rewarding it is to invade a planet. Things you should take in account are:

a. How far is it
b. How many ships does it have
c. Are you on the winning or loosing hand
d. Is it close to an enemy planet
e. Do you have ships enough to invade. There is no use of attacking a planet that is stronger than you




Check what planets are under attack and what planets are close and strong enough to help out




Do this when you're winning or when you see a cheap pick. But dont weaken yourself by attacking to much.




Did you notice all those ships on the planets that are in the corner of the map. Make sure they do something. Dont waste your resources by having them do nothing



If you issueorder make sure you adjust the numships on the source planet. This might seem weird at first but you can (and should) do this. You wouldn't want to send more ships than possible. And like in part 1. Log every issueorder.




This will be a basic function you need. In the next part we will want to calculate the expected state of a planet. But in order to do so you will need to know how an attack by one fleet affects a planet. This is different for different planet owner and fleet owner. I wrote 1 function to handle this.



In order to know a planets expected stat you will need to simulate a its growth for n rounds.




Before I issue orders I calculate the how many ships I need to send in order to win an attack. You will need to simulate attack outcomes and growth for the time it takes you to travel to the planet. Which is n rounds for n distance. I have different ExpectedPlanetState functions. One that takes a planet and a list of incoming ships. One that takes a planet, a list of incoming ships and X for how many turns I want to simulate in advance. And one that just takes a planet and asks PlanetWars for all incoming fleets and then simulates growth for each round and simulates attack outcomes. Note that you should make a copy of the original planet and leave the original planet in the actual state. We're only simulating here.




When you issueorder and send out a fleet you will want to take this in concideration when you fire the "ExpectedPlanetState" function. So inside your PlanetWars make a function that takes a fleet and adds it to the list of other fleets.
Obeleh
Lieutenant
 
Posts: 13
Joined: Thu Sep 09, 2010 9:16 am

Re: My First Strategy Guide

Postby yellowseed » Tue Sep 14, 2010 4:49 pm

These are some great tips. I've just started logging, and it's a great help in debugging as well as improving my strategy.

I'm not sure about modifying the PlanetWars' planets and fleets while generating orders and doing simulations: a subtle bug in one strategy could mess things up for all the later strategies. I'd rather use separate structures for orders, and then take these into consideration when generating predictions.

Good emphasis on choosing carefully between a variety of strategies, and doing correct simulations to figure out how many ships need to be sent. I think a lot of strategies will work well through the lower majority of the rankings, but anybody near the top must be doing most of the things you mention here.
yellowseed
Lieutenant
 
Posts: 11
Joined: Fri Sep 10, 2010 10:05 pm

Re: My First Strategy Guide

Postby Obeleh » Tue Sep 14, 2010 5:11 pm

Obeleh
Lieutenant
 
Posts: 13
Joined: Thu Sep 09, 2010 9:16 am

Re: My First Strategy Guide

Postby madfire » Tue Sep 14, 2010 6:40 pm

Great guide. I basically learned most of it the hard way, but there were still a couple moments that make me reach the editor for more improvements.
User avatar
madfire
Cadet
 
Posts: 9
Joined: Tue Sep 07, 2010 10:12 pm

Re: My First Strategy Guide

Postby Indome » Wed Sep 15, 2010 7:37 am

Great stuff Obeleh, will be great for newcomers!

Thanks for sharing and good luck ;)
Indome
Cadet
 
Posts: 6
Joined: Wed Sep 15, 2010 7:36 am

Re: My First Strategy Guide

Postby katebus » Wed Sep 15, 2010 10:41 am

Very good first guide ;D

BTW: Do you have any strategy that helps us "to find time for this fun contest" ;-D
katebus
Lieutenant
 
Posts: 10
Joined: Mon Sep 13, 2010 2:25 pm

Re: My First Strategy Guide

Postby ath888 » Wed Sep 15, 2010 11:06 am

ath888
Major
 
Posts: 31
Joined: Sun Sep 12, 2010 12:39 am

Re: My First Strategy Guide

Postby rangzen » Wed Sep 15, 2010 9:49 pm

"If you can upload your bot and have it running, you've done half of the path."

:D (not sure of my english)
User avatar
rangzen
Lieutenant-Colonel
 
Posts: 42
Joined: Sun Sep 12, 2010 6:14 pm

Re: My First Strategy Guide

Postby olex.s » Thu Sep 16, 2010 7:43 am

Nice guide, well done. I'd like to stress the importance of logging - with some bots, only detailed logs of every action can help you find out, what the hell that thing is doing and why :) I didn't have logging earlier - 250ish ranking, properly logged everything yesterday, viewed a few example games in detail, fixed a bunch of fairly obvious bugs - voi-la, rank 42, and still improvement ideas to implement.
olex.s
Captain
 
Posts: 26
Joined: Tue Sep 14, 2010 6:51 pm


Return to Strategy

Who is online

Users browsing this forum: No registered users and 1 guest

cron