<< Back to Warzone Classic Forum   Search

Posts 351 - 370 of 565   <<Prev   1  2  3  ...  10  ...  17  18  19  ...  23  ...  28  29  Next >>   
WarLight AI Challenge: 2014-05-26 14:44:01


ps 
Level 61
Report
cool, i'll try to schedule a livestream event to chat about this and take a look at some of the games, have to figure out dates not to clash with other livestream events and bother people to join me live, if anyone is willing to join in commenting please send me a message. i think it would be fun and nice buildup for the finals :)
WarLight AI Challenge: 2014-05-26 18:02:10

GreenTea 
Level 60
Report
Thanks, Blender, for big post from you :) Now I think it is safe to share some info and ideas about our bots.

So, breafly about my bot, it consists of such parts:
Core:
* Breadth first search utils.
* Attack analyzer - for precise calculation of chance to capture, average losts etc using formula of Bernulli.
* Game simulator - for making 'virtual' turns and working with modified state of map. Very usefull to modelling game on few turns ahead. Then all changes could be rolled back.
* Strategic score analyzer - analyzing of strategic value of every region on map. For example region near enemy bonus is more important then region far from enemy bonus.
Expand:
* Expand AI - finding best bonuses to expand, and best way to expand. Also possible to calculate best way to exapnd on many bonuses simultaneously. Used to found best picks, except
that first 2 picks are hardcoted to Australia :\
Battle:
* Battle AI - most complex part.
1) Prediction of enemy income and bonuses.
2) Analyzing every pairs of near reagions, where first is my and second is enemy region. Modelling all possible interaction between those regions using my income and predicted income of enemy.
3) Generation of all possible income usage and finding combination which gives max scores after analyzing of region pairs. Also on this step for every region I found best turn for it, which could be:
- regular attack (with all forces)
- split attack (in all direction, when big advantage of armies)
- partial attack (attack with part of forces)
- defence
- strategic move on neutral region (to protect my bonus or move to enemy bonus)
- stragetic move on my region (usually to protect my bonus)
4) Moving of rests from far (not border with enemy) regions.
5) Moving to enemy strategy.
6) Expand using Expand AI.
7) Identifying best order of moves.

And about 120 unit tests for separate modules and on various game situations. Something like this :)

Edited 5/26/2014 19:16:14
WarLight AI Challenge: 2014-05-26 20:32:23

GreenTea 
Level 60
Report
http://theaigames.com/competitions/warlight-ai-challenge/games/5383a2a54b5ab2088e1b9e53
If such game will be somewhere in finals, I'll be very upset..
WarLight AI Challenge: 2014-05-26 23:00:31

GreenTea 
Level 60
Report
WarLight AI Challenge: 2014-05-27 00:14:47


Garrett
Level 56
Report
I haven't participated in this thread at all while the competition was going on, but now that everything's locked in I'd like to join in on the fun.

First off, I hope everyone had a good time programming their bots (even through all those long hours debugging), and that we all have some good games! It's easy to watch your bot lose and blame it on yourself for not changing the logic up or getting rid of that one bug, but we should really be congratulating our opponents for doing an excellent job on their own bot. So good job everyone!

Now to share my AI logic. I still have a lot to learn regarding computer science, I learned it as a hobby a few years ago, so my code is terribly organized. That said, I think the main ideas behind it are valid, so I'll be glad to hear everyone's criticism on it.

-The picking strategy is quite simple, chosen from smallest bonus up, further organized by bonus safety (ways in) and regions are chosen from distance to other bonuses.

-Each round starts with predicting the enemies income, which works only if they deployed more than the previous known income a previous turn. It then assigns the smallest bonus that would fit the income shown to the enemy, if it's possible for them to have it.

-Enemy probabilities are then calculated. This includes lost picks if it's round 1, otherwise just some basic expansion predictions which could be improved quite a bit.

-Bonus goals are then calculated. This is the defining feature of my bot, it works based on 4 main bonus goals, which include Survival (if one's about to be eliminated), Capture (if it's a good candidate for capture), Break (if an opponent has it and it needs to be broken), and Elimination (if it's possible for an enemy to be eliminated completely from a bonus). Each of these are easier to calculate then you'd think. At the moment the calculations look like this:
bonus.Goals.Capture = bonus.ArmiesReward * (1 - enemyNearby) /
    (territoriesToCapture - nearbyArmies / 30.0);
SurviveRating = Minimum Ratio Of((mostSurroundingArmies + state.PredictedEnemyIncome) * 0.6) /
    (playerRegion.Armies * 0.7);)
bonus.Goals.EnemyElimination = (playerArmies + state.StartingArmies) * 0.6 /
    totalEnemyArmies;
BreakRating = 1 if enemyIsVisible, else it's 1*enemyProb of all territories.

All of these are of course conditional on if my opponent and I are in the bonus being analyzed.

-Next comes the DeployArmies code, this is easily the most massive section of the program, at over 700 lines. That's not bragging, I'm rather disappointed by how much typing I had to do to accomplish what I wanted, but it is what it is.

-To skim over the details, the bot looks over the bonus goals and makes objectives based off of them of the different types (survival, break, etc.), doing its best to sort from most important to least important.

-It then runs a loop over the objectives, deploying the minimum armies necessary to accomplish each objective, with different logic for each type.

-If at the end there are some leftover armies, it deploys them evenly to all deployment orders made (with some backup logic in case no objectives were made).

-Then the AttackTransfer orders are made, this section looks at all the remaining useful territories and decides what to do with their remaining useful armies (transfer, add to previous attacks, etc.). When the attacks are made the Priority is included (important, delay, safe, unsafe), but this could've used some more work as no delay orders are generated if they've gotten to the most useful territory. Some transfers are odd as well.

And that's that. Sorry about the wall of text if you weren't interested in this. And I wish everyone the best of luck for the remainder of the challenge! I don't expect my bot to do too great, but I might get around that 1 euro mark. :) And I'll leave with one recent game I liked against ps, whose move into North America seemed costly but eventually won out, and had some nice anti-AI maneuvers (on purpose?) in South America. Also, I enjoyed watching my AI run away in Africa after I had lost. gg ps!
http://theaigames.com/competitions/warlight-ai-challenge/games/5383a22e4b5ab2088e1b9e48
WarLight AI Challenge: 2014-05-27 11:57:59

GreenTea 
Level 60
Report
WarLight AI Challenge: 2014-05-27 12:48:21

Ikalgo
Level 50
Report
@GreenTea: Thanks! I'm now regretting not playing a higher percentage with Europe ;) Though yea... if you would be prepared for it I think you would handle it appropriately, perhaps even you will in some other games :)

This is nasty though: http://theaigames.com/competitions/warlight-ai-challenge/games/5383e7cb4b5ab2088e1ba427 (I also have something similar happen, sadly)

Edited 5/27/2014 12:52:04
WarLight AI Challenge: 2014-05-27 13:02:27

GreenTea 
Level 60
Report

This is nasty though: http://theaigames.com/competitions/warlight-ai-challenge/games/5383e7cb4b5ab2088e1ba427 (I also have something similar happen, sadly)


Yes, strategic scores for move on my region becomes highter then regular attack.. But too late for fix)

Edited 5/27/2014 14:44:39
WarLight AI Challenge: 2014-05-27 13:11:46

Ikalgo
Level 50
Report
Trogatog: I'm so embarrassed with this game http://theaigames.com/competitions/warlight-ai-challenge/games/53848ea54b5ab2088e1bb203

Edited 5/27/2014 13:12:04
WarLight AI Challenge: 2014-05-27 17:54:05

Ikalgo
Level 50
Report
Hey GreenTea, based on this game, http://theaigames.com/competitions/warlight-ai-challenge/games/5384cb8e4b5ab2088e1bb744, what is your criteria to attack? You attacked 42 units with 43 units? As you probably know, considering our bonuses, your chance for successfully breaking through is only 10%. A little later you also attacked 22 units with 23 units. So I'm curious what rule made your bot attack?

Edited 5/27/2014 17:58:28
WarLight AI Challenge: 2014-05-27 18:18:11

GreenTea 
Level 60
Report
umm.. Probably bot consider that not all 7 armies will be used by enamy to defend region. And for all cases of defend, with deploying 0, 1, 2... 7 armies it calculate average scores for attack. And this average score for attack becomes greater then average scores for my defence, calculated in same way (if I use 0, 1, .. 7 armies to defence). Tricky logic.. Some not trivial math standing behind this, and often it's hard to predict even for me what bot will do in next turn.

Edited 5/27/2014 18:26:32
WarLight AI Challenge: 2014-05-27 18:20:41

GreenTea 
Level 60
Report
Sometimes it's working when enemy start expanding in the same time when I attack.

Edited 5/27/2014 18:23:36
WarLight AI Challenge: 2014-05-27 19:06:48

GreenTea 
Level 60
Report
WarLight AI Challenge: 2014-05-27 21:23:00


Norman 
Level 59
Report
Hello

@Ikalgo:
The question you asked at stackexchange seems a bit strange to me. It's lacking the fact that you can place armies between the attacks. Furthermore I don't see you getting much gain from your calculations. If you just assume 0% luck you can easily calculate how many turns it will take you to break the opponent (I only find the question 'if' I break the opponent relevant). If you then have the minimum amount of needed armies I think that for each luck factor > 0% you have exactly a 50% chance of getting your break in a couple turns. Furthermore your bot has to answer the question if he really want's to keep hiting that one spot.


I don't think it's necessary to calculate with a brute fore attempt game states in the future. If you have good heuristics it should be possible to only calculate the next move. For example expansion: You don't wanna just attack random territories in a bonus but you wanna attack in a way that gets you closer to taking the bonus. Now you could calculate all possible expansion options for the next 3 turns and then pick the option that acutally let's you take the bonus. What I do however is just looking at which territory has the maximum amount of unknown neighbors in the bonus and then I attack that territory.

Same goes for fighting. A good heuristic could for example be that the closer a region is to your / the opponent bonus the more that region is worth. You can also try to attack those regions that get you closer to completely push the opponent out of the bonus.


I think it's more interesting in how I define a strong bot than how my bot acutally works:

First you need a function that tells you whether you are winning or losing:
GameState(ArmiesOnBoard,IncomeAndOpponentIncome,PositionOfArmies)
--> ArmiesOnBoard --> Your armies / guessed opponent armies
--> IncomeAndOpponentIncome --> Your income and the guessed opponent income
--> PositionOfArmies --> Maybe you have your armies somewhere in nomansland while the opponent has a huge stack that borders all your income on multiple borders.

Then you need a function telling you how many armies to use for expansion and how many for fight:
ExpansionFightArmies(FightingOptions, ExpansionOptions, GameState)
--> The amount of armies you use for expansion versus fighting has to depend on how much you can achieve this turn and how much armies you need to achieve this task. Furthermore the GameState is important. If you have the game won then stop taking bonus after bonus and finish off the opponent.

Then you need a function telling you how to expand properly:
Expand(GameState,ArmiesForExpanding)
For expanding it's also important to know where the opponent is what is a part of the GameState. You might wanna hit the spot bordering the opponent strongest or not expand into a bonus bordering the opponent.

Fight(ArmiesForFighting,Position,ArmyKillsAndLosses,GameState, GuessedOpponentMoves)
For me fight is everything that isn't expansion. When you march with a huge stack towards the opponent this also belongs to the fighting task.
--> ArmyKillsAndLosses: Killing opponent armies has a value on his own
--> GameState: Depending on whether you are winning or losing you have to take more risks fighting. When you are losing you might wanna accept a 70% chance of the opponent breaking your bonus with a full force attack while when you are winning you wan't to play safer.
--> Position is more abstract. You can give each territory a value depending on different factors. However the position not only depends on which territories you hold but it's also relevant how many armies you have there.
--> Guessed opponent moves is what all bots lack to some extent. Just because the opponent has a big stack sitting on a territory doesen't mean that this stack also has to be there at the end of the turn.
WarLight AI Challenge: 2014-05-27 21:23:03

Ikalgo
Level 50
Report
GreenTea: Ah, well yea I used monte carlo / markov chain application for obtaining the probabilities. It is very useful and I believe it to be the ultimate solution. Each of the 2 million cases I have simulated were simulated 1000 times each. I need up until Round 10 to load in everything (given that I'm using Python).

I'm wondering about you working with "a map of a few rounds ahead". Do you have any idea how those predictions fare, are they spot on usually?

And yes, Ad has also escaped from me before :(
WarLight AI Challenge: 2014-05-27 21:48:38

Ikalgo
Level 50
Report
Sigh, I was writing a long post and the page got refreshed.

Anyway, indeed it does not make much sense to simulate without taking into account income. I did in my actual simulations though.

Just some examples:

5 5 99 110 0.689
5 5 99 111 0.774
5 5 99 112 0.829
5 5 99 113 0.844

For example, the second line states that when both attacker and defender have an income of 5, the defender has 99 troops and the attacker has 112 troops, the attacker has 77.4% to break the enemy over time. It is not possible to use any linear formula to produce a result similar to this. You can imagine though how useful it is know these numbers at any given moment.

If you compare it for example:

5 5 6 7 0.402
5 5 6 8 0.701
5 5 6 9 0.91
5 5 6 10 0.973
5 5 6 11 0.996
5 5 6 12 0.997

You could simply find out for each placement of a troop where it adds the most probability.
In fact, if you would also add in your priorities per region of the map, this could get really sick!

Also, please look at our recent games (SA/AU). I can freely expand because I know how many troops I need to be safe in North Africa. Unfortunately I didn't have time to finish the tactic of capturing australia behind your back, an earlier version did better :/ It now just wanders around in Asia which ends up getting me killed.

So yea, basically what I'm trying to say is that you need good heuristics AND you need the math for the best strategy. Your decisions will be even better when backed up with the right numbers.

In the strategy part I can certainly learn a lot from you and the things you bring up are interesting, I only started playing Warlight during this competition.
I made a breakthrough with Europe recently, as I'm not trying to capture Brazil, but instead immediately go for Australia. I'm having mixed feelings as my bot is playing Europe as well as SA/AU, and I'm thinking I should have just polished one strategy instead.

Main problems with Europe has been solving the graph to optimize capturing Europe, sadly, I haven't solved it (but yea, that's where heuristics come into play). The opportunity for North Africa to attack 2 regions in Europe is something else I have struggled with.

Lastly, I'm interested in how you assigned values to regions? I assume it is very difficult to fine tune the weights, though it surely seem to be a superior solution! I read you wrote about it but I figured it is really difficult to find rules for assigning these values.

Edited 5/27/2014 22:00:13
WarLight AI Challenge: 2014-05-28 02:43:20


Norman 
Level 59
Report
Hello

Lastly, I'm interested in how you assigned values to regions? I assume it is very difficult to fine tune the weights, though it surely seem to be a superior solution! I read you wrote about it but I figured it is really difficult to find rules for assigning these values.

The only thing I cared about when assigning region values is whether they help my bot making smart moves or not. There is no true of false, just helpful and not helpful. Before I updated my fighting mechanics about two months ago the only information my bot used when performing attack moves were the region values and the opponent was some sort of an obstacle hindering me from taking my preferred regions. Basing all your moves on a simple integer value however doesen't result in very good moves. You also need to distinguish different situations. In fact I never fine tuned my region values and the situations that my bot distinguishes are far to less. However my region values work like this: The exact value of a region is unimportant. The information is just that region A has a higher value than region B. Since I don't want unimportant stuff to interfere with the important stuff I sometimes give some pretty high numbers but this is just to make the modeling easier.

The heuristics for giving values are pretty simple. However the values being good depends on if you know what is going on behind the fog.

For example when expanding in a SuperBonus:
- Give each neutral region +1 for each bordering unknown region in the same SuperRegion
- Give each neutral region +1000 for each possible opponent bordering SuperRegion

For the fighting part you have to ask yourself where do you want your bot to fight, for example:
- The more territories still owned by neutral in a bonus the less worthwile it's for you to fight for it.
- Regions that border the opponent SuperRegion / your own SuperRegion are especially worthwile
- Regions that belong to the opponent SuperRegion / your own SuperRegion are even more worthwile
- It's more worthwile to fight for small bonuses than for big bonuses.
- If you get the chance to completely push the oppoent out of a bonus then the remaining spots of the opponent in the bonus are worthwile (and vice versa). This is especially the case when there aren't any neutrals in the bonus.
- The closer a region is to your bonus / the opponent bonus the more worthwile it is

If you only use the region values to guide your moves you will get into trouble. The problem is that you want to perform different tasks each move. If one of them is extremely important like breaking the opponent bonus then it's better if you put a huge amount of armies to this task. My bot only distinguishes three different situations what isn't enough, I call them high important, medium important and low important.
- High importance --> Defending own bonus / breaking opponent bonus / taking over last spot in opponent bonus / not losing last spot in otherwise completely owned opponent bonus
- Medium importance --> Protecting entry to bonus
- Low importance --> All other stuff

The problem is that most games are to static / not messy enough so you don't see that well how me priorizing the regions comes into play.
http://theaigames.com/competitions/warlight-ai-challenge/games/53841d8f4b5ab2088e1ba896
http://theaigames.com/competitions/warlight-ai-challenge/games/5381ae1a4b5ab2583f2427bb
WarLight AI Challenge: 2014-05-28 04:40:11

Ikalgo
Level 50
Report
I like your general approach more though, just I feared it would take too long to fine tune these priorities and basically that it would be roughly the same as just writing down strategies like this. Each of your items makes a lot of sense though.

Below how I did my placements. Note that I have "tentacles" (created from playing Europe). These are spots I wish to obtain because I expect the enemy to be there or because it would give me an advantage to obtain this spot (for example, North Africa). I will use the find shortest path from all my regions and the region that is closest would be considered the tentacle ending.

In order:

PlaceDefendAtMostOnePerContinent - try to stay alive in all supers
PlaceAttackEnemyWithinOwnedContinent - one enemy in otherwise owned super
PlaceDefendOneVOneContinent - priority to defend if enemy can only attack 1 region
PlaceAttackNeutralInContinent('3')
PlaceDefendTwoVOne - if one region can attack 2 regions of mine in super, defend
PlaceTentacleDefend - defend a tentacle starting or ending region
PlaceTentacleAttackEnemy - try to go through enemy to go to goal
PlaceTentacleAttackNeutral - go through neutral to go to goal
PlaceDestroyEnemy
PlaceSeekEnemy

Attack transfers for Europe strategy (these are prioritized like that):

I also care about the order; either "begin", "doesn't matter", "last". The importance of the order is taken into account as well (so within each subcategory those with higher importance are done first/last)

In order:

self.decideExpansionTargets([["North Africa"], ["Indonesia"], ["Brazil", "Greenland"]], anyRegionInSuperIsOK=False)
self.ATAttackEnemyInContinent('3', p_min=0.2)
self.ATAttackNeutralInContinent('3')
self.ATDefendTwoVOne('3')
self.ATDefendOwnedContinents()
self.ATTentacle() - expand, defend
self.ATDestroyEnemy()
self.ATAttackNeutralInContinent('6')
self.ATAttackNeutralInContinent('2')
self.transferTroops()
self.ATSeekEnemy()

My transfer troops is also quite interesting. Leftover troops will move either to the strongest enemy nearby (< 4 regions away) if my troops could use reinforcements, otherwise move to close neutral, and otherwise move towards closest (but perhaps far away) enemy.

Edited 5/28/2014 07:51:11
WarLight AI Challenge: 2014-05-28 16:55:32


Trogatog
Level 52
Report
Edit: My bad, looks like it is actually something very different than I thought. Phew. Still a couple mistakes, but stupid logic bug on my part, not an operation error

Edited 5/29/2014 18:21:28
WarLight AI Challenge: 2014-05-29 06:46:24


Doushibag 
Level 17
Report
Dang you guys got all advanced. I started working on my bot pretty late (about a week into May). So I had to keep things simple so went with a real cheesy solution. I just place, with a little bit of randomness, some cheese on the map and have my mice (army stacks) find the cheese. Then new cheese is placed and this is repeated. I didn't know how else to keep my bot fed. When I tried doing it the non-cheesy way it seemed to just lock up and go on strike, malnutrition bug or something. How did you guys keep your bots fed so they wouldn't lock up? I was a noob programmer coming into this so it took me a while to even figure out my bot needed to eat. I just assumed they were machines without needs. Guess I really learned something taking part in this competition.
Posts 351 - 370 of 565   <<Prev   1  2  3  ...  10  ...  17  18  19  ...  23  ...  28  29  Next >>