It is currently Thu Jun 20, 2013 5:04 am Advanced search

Tell us your secrets, unleash your bot's code!

Share and discuss ideas for your entries here.

Re: Tell us your secrets, unleash your bot's code!

Postby Xrillo » Thu Dec 02, 2010 11:02 am

bocsimacko wrote:
Xrillo wrote:I tried a few setups and finally settled with not doing any actual playouts. I merely built a tree, and each node was given a score - a linear combination of win/loss and the score-ratio. This makes sure you'll rely on the actual win rate in the end but also makes it greedy and trying to take all planets.


I don't understand. If there are no playouts then what is the win/loss in the linear combination?


Ah, sorry.. at each terminal node I let the universe run until all fleets arrive at their destinations and score that position. I didnt consider this a playout since you're not actually making any moves..
Xrillo
Captain
 
Posts: 24
Joined: Fri Oct 01, 2010 8:17 am

Re: Tell us your secrets, unleash your bot's code!

Postby Manwe56 » Thu Dec 02, 2010 10:59 pm

Name: Manwe56
Profile: http://ai-contest.com/profile.php?user_id=9492
Final Rank: 32
Language: Java
source code: https://github.com/Manwe56/Manwe56-ai-c ... lanet-wars
Executable Jar : attached (just rename .zip in .jar since jar files are not accepted)

Most of the code basis has been written in Test Driven Development. You will find a test package in the sources containing all the tests I have written. Those tests are all checking under a given trivial situation of the world, that my bot is sending the expecting fleets during one turn. I did not write lower level tests because I did not want to loose time maintaining tests on a code that might evolve a lot.

After a certain stage, I faced difficulties to write tests : it is quite perfect to ensure your bot will manage a certain situation, and you are not breaking the previous features, but when you want to tests if you get "stronger" by changing an evaluation function for example, I did not find any way to go further.
So fine tuning has been done like the others contestants i guess : running a new version against my previous versions, running the bot on the tcp server etc...

There is packages in the sources, and for the submissions I had a little script that copied everything in a new folder, and removed package definition/imports.

I also modified the game visualizer in order to display more information. I was trying to understand how I could re-balance my ships between the planets to avoid putting one planet in danger.
For each planets, the visualizer computes the planets states until maximum distance between planets. Then on each planets, for each turn, it calculate how many ships could reach the planet for both player.
Then on each planet:
    The planet is neutral : the text displayed has the color of the player with the maximum of ships that could reach the planet. The number displayed after the # represent the difference of ships between the player with max ships and the other player at the turn of the maximum
    The planet is owned by a player : we find the minimum of the difference of ships of the owner and the other player. If this difference is negative (so it exists a turn where the planet could be lost) the color of the text will be the other player. Then the absolute value of this difference is displayed

It is quite amazing how you can "see" who will win in a early stage of the game with this visualizer. I tried to use this information (trying to maximize the "influence" map), but I did not succeed to stabilize something enough efficient.

Now on the code of the bot:
There is no magic, and it is very similar to other top players

maximum simulated turn is the maximum distance between two planets on the map

1) compute all the states of the planets, for each turn. Based on this, compute for each turn how many ships could reach a planet for each player.
2) Compute the "front" planet and "future front" planets. the future front is the front with the planet owner of the maximum simulated turn
3) Try to cover planets that might fall to the enemy if we are not sending reinforcement
4) This is the attack step:
Determine eligible targets. Eligible targets are all the neutral planets, enemy front planets, and my planets that I will lost
For each eligible target try to find a possibility of attack with my planets, starting from the nearest. I determine on each planet the available ships without any risk to loose the planet. I add my planets contribution until I find a combination that allow to conquer the planet with the following conditions:
The number of ships to send depends on the target : if it is enemy, I just want to be sure to capture it when all the fleet arrives, ie no defensive move is possible on impact. If it is neutral, I will need to ensure I will be able to keep this planet until the max simulated turn. If the neutral is closer than an enemy, ships that are required due to potential enemy reactions are included in the ships to send. Else those ships are reserved in the planet. On each step, The order are executed and refreshes the simulation to avoid side effects. The possibility rating is the number of turn until I begin to gain ships compare to my enemy.
Execute the best possibility, and remove the target from the eligible targets. Return to beginning of 4 until there is no other possibility to execute
5) recompute front to take into account our attacks
6) if a planet is not a front planet, send ships that are not required to keep the planet to the nearest front planet
7) with the ships of definitively lost planet, try to plan suicide attacks on enemy planet expecting a defensive move that will allow to have time to counter

Note that there is two phase : one phase of expansion where I try to conquer neutrals quickly. In this case, neutral planets are considered as enemy on the front calculation. It allows to keep ships behind for faster conquest. Then there is the offensive phase, where only enemy are considered to calculate front planets, and step 3 is simply not executed because I do not need to re-balance my ships considering enemy moves. I did not took the time to find a good criteria for the phase transition, so I hard coded 5 turns...It was more to avoid on a few maps to send almost all my ships in a direction when in one or two turn I would have been able to capture a neutral planet next to my starting position

I also have some special things in the step 4) : I try to find a solution in the future, allowing to wait to take a more interesting planet (else I remarked the planets are taken in order of their ships number, and not really interest). If this solution is the best, the ships are reserved for the entire turn.

The major weakness of my bot is that it never place in the other player point of view. basically, if it could take a 70/+1 neutral, but by doing this allow the enemy to capture a middle neutral 11/+3 planet, it does not cancel the move...The other major weakness is that my bot does not store anything between two turns. So it is not able to really make the same assumptions on the attacks it previously launched, and the attacks it is planning. It usually allow the other player to take control of a neutral at the beginning it was able to maintain

I really enjoyed this contest! Thanks you all for this great challenge!! :D
Attachments
ShowGame.zip
Modified visualizer. Rename it in ShowGame.jar for use
(70.89 KiB) Downloaded 84 times
Manwe56_final.zip
Manwe56 final submission. Rename it in .jar for direct use
(69.39 KiB) Downloaded 98 times
Manwe56
Lieutenant
 
Posts: 12
Joined: Tue Oct 19, 2010 4:39 pm

Re: Tell us your secrets, unleash your bot's code!

Postby krokokrusa » Sat Dec 04, 2010 11:39 am

Profile: krokokrusa
Final Rank: 350
Language: Java
Source: planetwars-bot-java

Unofficial rank: ~700
Language: C++
Source: planetwars-bot-cpp
krokokrusa
Cadet
 
Posts: 1
Joined: Mon Sep 13, 2010 4:36 am

Re: Tell us your secrets, unleash your bot's code!

Postby ludakris » Sat Dec 04, 2010 6:38 pm

Profile: ludakris
Final Rank: 122
Language: Java
Final Source: PlanetWars
Rewrite Source: PlanetWarsRewrite
Post Mortem: Planet Wars Post-Mortem

I did a simple iterative approach to making a bot. I added new abilities, did regression against my bots, ran on Dhartmei, etc. I did TDD calculation related logic and some complicated list/collection methods. I discuss my bot in more depth in my post mortem.

My bot played out the current state of the board to determine the known future, and only did attacks using a single source planet per turn (no coordinated multi-planet attack).

The bot that I ended up submitting was the final version of what was really meant to be a good test bot which was left largely unchanged for the last month of the contest. I started down a path of rewriting my bot so that I could have better modelling around creating future state of an entire Universe and to add in a Reservation system for coordinated multi-planet attacks. The rewrite never reached a point where it was better than the test bot (though very close, likely would have been in the top 200). This was especially unfortunate because when the map generator changed, my test bot dropped from the 50s and 60s to about 150, but I continued to invest my time in the rewrite.

Overall, this was a great competition. I look forward to the next one.
ludakris
Cadet
 
Posts: 2
Joined: Sun Oct 03, 2010 10:03 pm


Re: Tell us your secrets, unleash your bot's code!

Postby InvaderZim » Sun Dec 12, 2010 2:44 pm

Profile: InvaderZim
Final Rank: 395
Language: Java
Final Source: InvaderZim

The post mortem will be coming in a bit. Haven't had time to get to it yet.
InvaderZim
Cadet
 
Posts: 4
Joined: Sun Oct 03, 2010 6:47 pm

Re: Tell us your secrets, unleash your bot's code!

Postby eashoka » Sun Feb 20, 2011 2:20 pm

Estimated Rating : 3270 - 3280
Estimated Rank : 60 - 70
Language : Java
Source, tournament Results and rating calculation : https://github.com/ashokae/planet-wars-bot

Why this talk about estimated ranks and ratings ? Find the full story here please : http://iq-games.blogspot.com

In short, I ran a local contest since I joined the competition way too late. (details on results and rating calculation of this can be found in the excel final-results.xls downloadable from the url)

Special thanks to GreenTea, Smloh, Manwe56, Deccan, Exaide, Ludakris, Eburnette, InvaderZim and zvold for submitting your java code and made it all possible for me. You guys really made my day! (or two months really). I have a lot of admiration for you all. Will put few analysis on your bots (what I saw while running them for two months :-) ) on the mentioned blog above.

If any of you have still time and passion left for the Planet Wars, you can run the provided tournament code (I just modified the PlayGame.jar slightly in Engine.java) and let me know your thoughts.

Best of luck for all in the upcoming competition!! Looking forward to meet you guys (and your bots)
eashoka
Lieutenant
 
Posts: 16
Joined: Tue Nov 30, 2010 10:32 am

Previous

Return to Strategy

Who is online

Users browsing this forum: No registered users and 0 guests

cron