<< Back to Warzone Classic Forum   Search

Posts 371 - 390 of 565   <<Prev   1  2  3  ...  10  ...  18  19  20  ...  24  ...  28  29  Next >>   
WarLight AI Challenge: 2014-05-29 16:03:50


Trogatog
Level 52
Report
I just place, with a little bit of randomness, some cheese on the map and have my mice (army stacks) find the cheese.


Brilliant :)

So the first time I ever made into first place was with a pretty small bot without a lot of logic that only knew to take SA and take advantage of people not knowing how to play AU (ironic, right?). This took me from 50th or so place straight to first. Once there, it became obvious that I was playing against bots that actually knew what they were doing (and competing with other smart SA bots) and really had to step up my game.

I will say, every time I played against Dalek was frustrating as all hell. Even in my final bots. Screw you and your better-than-me-at-warlight coding efforts :P (that was sarcasm in case you missed it. I actually have great respect for Norman and his bot)

Anyways, I'm no where near as good of a WL player as the rest of the top guys in the AI challenge, so I basically had to adapt by copying. I see something awesome your bot did that was awesome, I would code up something similar.

...or against. Perfect example here is Gadzbot's notorious ability to take Indonesia from Siam turn 1 and me not be totally prepared for it. I coded up a whole routine to not only protect against that scenario (I'm sure you noticed 125ch209), but start taking advantage of those picks that can sabotage the opponent early. Of course, I forgot one small detail before submitting my final code that keeps making me sad every time I see it happen: When Siam is available and Central America isn't, make South America picks my 1st and 2nd. Whoops! This is the functionality I was referring to when I said "I actually named some of my routines after the offending player. Before calling it "CheckForPossibleSabotage" it was "GoF***UpGadzbot", haha.

My biggest weaknesses in WL is early game and large frontiers. The latter I didn't have to worry too much in this map, thankfully. But the early game, even at the end of the coding challenge, is something that causes me strife. A main issue with my bot is that it didn't detect when I lost a bonus on turn 2 or 3 due to a good luck roll by my opponent (11 took a 9. I mean, c'mon, who does that?).

Eventually I moved my bot over to an AU-pick first bot - hard coded, but I like the idea someone proposed earlier about using the "harder to get to" method - mostly because I started using the knowledge of knowing where you were to my advantage. For example, if you had both SA picks and our 3rd picks were kissing in Africa, I knew you needed at least 5 armies to take South America. So, I would sit there and count what you lay down every turn that wasn't in SA and know that you were still at a 5-army income. If I get my first three picks or only see one of your armies, I guess your last two picks are in Europe and do the same thing, hopefully interrupting you in time. Australia was only ever given priority over SA if: I received both picks in AU, or; I received a starting region in 3 different continents. Other than that, my bot was actually still an SA bot, just with AU picked first.

Genius, right?

Anyways, I keep seeing you guys talking about how you're calculating attacks and percentages and statistics and blah blah blah... Here, I 100% agree with Norman and I only code battles for 0% luck. On average, it's what will statistically happen more often. No matter what, you're going to lose to a perfect roll by your opponent even if you calculate everything exact.

public enum BattleRegions
{
    Attacker,
    Defender,
    Neither
}

private BattleRegions WhoWinsOnAttack(BotState currentState, int fromRegionArmies, int toRegionArmies, int opponentIncome, bool noOpponentIncomeThisRound)
{
    var attackingArmies = fromRegionArmies;
    var defendingArmies = toRegionArmies + (noOpponentIncomeThisRound ? 0 : opponentIncome);
    var defendersDestroyed = attackingArmies * .6;
    var attackersDestroyed = defendingArmies * .7;

    var attackingArmiesLeft = attackingArmies - attackersDestroyed;
    var defendingArmiesLeft = defendingArmies - defendersDestroyed;
    if (attackingArmiesLeft <= 0)
        return BattleRegions.Defender;

    if (defendingArmiesLeft <= 0)
        return BattleRegions.Attacker;

    if ((int)attackingArmiesLeft + currentState.StartingArmies == fromRegionArmies && (int)defendingArmiesLeft == toRegionArmies)
        return BattleRegions.Neither;

    return WhoWinsOnAttack(currentState, (int)attackingArmiesLeft + currentState.StartingArmies, (int)defendingArmiesLeft, opponentIncome, false);
}

private BattleRegions WhoWinsOnDefend(BotState currentState, int toRegionArmies, int fromRegionArmies, int opponentIncome, bool noOpponentIncomeThisRound)
{
    var attackingArmies = fromRegionArmies + (noOpponentIncomeThisRound ? 0 : opponentIncome);
    var defendingArmies = toRegionArmies;
    var defendersDestroyed = attackingArmies * .6;
    var attackersDestroyed = defendingArmies * .7;

    var attackingArmiesLeft = attackingArmies - attackersDestroyed;
    var defendingArmiesLeft = defendingArmies - defendersDestroyed;
    if (attackingArmiesLeft <= 0)
        return BattleRegions.Defender;

    if (defendingArmiesLeft <= 0)
        return BattleRegions.Attacker;

    if ((int)attackingArmiesLeft - 1 == toRegionArmies && (int)defendingArmiesLeft + currentState.StartingArmies == fromRegionArmies)
        return BattleRegions.Neither;

    return WhoWinsOnDefend(currentState, (int)defendingArmiesLeft + currentState.StartingArmies, (int)attackingArmiesLeft - 1, opponentIncome, false);
}


As you can see, I'm a big fan of recursive functions :)

The boolean noOpponentIncomeThisRound comes from a private class-level variable that tells me if I calculated or guessed where you are placing your armies for the turn. Basically, these routines simulate the attack, take what armies are left over, and plug them back in assuming that you and I are going to put all of our armies on these stacks again. Keep going until one region loses all their armies. If you're going to say "It should be until the attacker has 1 army left, not zero" -- maybe for your code, not mine. That's taken into consideration on the number of armies initially passed in.

Not perfect (if these regions don't get army placements, they might not next turn, etc), but it seems to do the trick for what I need it to do.

This can be quite easily modified to determine the number of turns it will take to get to desired defeat by creating a class level variable that is reset in the calling function and then gets incremented every time the routine is called recursively.

I also use these routines to detect stalemates (if the winner for both regions is always the defender, we're most likely in a stalemate on that region).

One last final piece of advise I truly want to recommend: Learn how to figure out your opponent's income. I notice a lot of you try to "hide" your income -- which is smart unless you've already given it away to me 5 turns ago :) If I calculate that you have South America, I also know you're going to have it until I own a Region in South America. The method to calculate opponent income is actually a lot less trivial than you think!

First, determine what super regions you don't know anything about, meaning ALL regions are owned by player "unknown" (if you see a neutral region, you already have enough information on that super region to know it's unowned).

If your opponent lays down more than 5 armies in your field of sight, figure it out according to those unknown owned super region how many armies your opponent put down:

foreach (var unknownSuper in state.UnknownStatusSuper)
{
    switch (unknownSuper.Id)
    {
        case (int)SuperRegionNames.Africa:
            if (VisibleIncome > 7)
                AddOwnedSuperRegion(unknownSuper.Id, state.FullMap, state.RoundNumber);
            break;

        case (int)SuperRegionNames.Asia:
            if (VisibleIncome > 14)
                AddOwnedSuperRegion(unknownSuper.Id, state.FullMap, state.RoundNumber);
            break;

        case (int)SuperRegionNames.Australia:
            AddOwnedSuperRegion(unknownSuper.Id, state.FullMap, state.RoundNumber);
            break;

        case (int)SuperRegionNames.Europe:
            if (VisibleIncome > 9)
                AddOwnedSuperRegion(unknownSuper.Id, state.FullMap, state.RoundNumber);
            break;

        case (int)SuperRegionNames.NorthAmerica:
            if (VisibleIncome > 10)
                AddOwnedSuperRegion(unknownSuper.Id, state.FullMap, state.RoundNumber);
            break;

        case (int)SuperRegionNames.SouthAmerica:
            AddOwnedSuperRegion(unknownSuper.Id, state.FullMap, state.RoundNumber);
            break;
    }
}


(Note, I have an enum set up for both Regions and SuperRegions to identify their IDs by name)

If you think the numbers above won't work in certain situations, you're probably right, but those situations are games you've already lost. When I detect the opponent owns, I have a routine that takes care of adding important opponent information to my opponent tracking class, you can put whatever you want in between the "case:" and the "break;" :D

Anyways, that's a quick peek into the guts of Trogabot. I'll bring more to the party later and I hope I taught you new coders something :)

Edited 5/29/2014 16:31:10
WarLight AI Challenge: 2014-05-29 16:48:42

GreenTea 
Level 60
Report

foreach (var unknownSuper in state.UnknownStatusSuper)
{
switch (unknownSuper.Id)
{
case (int)SuperRegionNames.Africa:
...


This is what im calling hardcoded bot :)
Can't wait when we will start fight on random maps.
WarLight AI Challenge: 2014-05-29 17:17:57


Trogatog
Level 52
Report
Yeah, but with 6 supers to choose from, it's easy in this map to pick. I'm hoping that we get a 10-map random generation, but this is something easy to make into a generic method. It was coded so long ago that I never got around to modifying it since there were more pressing matters to fix, like who is GreenTea and what is he doing better to beat me??? :)

A quick glance at my code tells me that it would just be using what bonuses I know you have, calculate which give me a higher total than what was know previous round. If you control SA and I'm in AF, you're likely to have taken NA, etc.

There's a small bit of hard-coding from lower numbered versions that never got fixed, like in this example. Again, all due to priorities.

Another bit slap on the hand I gave myself for my code was setting up my place army routines to seamlessly transition over into a Strategy pattern. All the signatures on the methods are the same, so I could have made them generic, created a decision class, and let the pattern go at it. Alas, it was not meant to be.

I'd really like to see if Jim could set up a separate environment so that we can keep playing around with our bots in a non-competitive environment because I want to clean up my code so bad, but I don't want to break anything. Perhaps giving us the ability to queue up our bots against selected opponents or up the range of opponents to +50 and -50
WarLight AI Challenge: 2014-05-30 17:54:13

GreenTea 
Level 60
Report
I had made improvement which gives 56% of wins vs version on site.. :'(

Edited 5/30/2014 17:56:32
WarLight AI Challenge: 2014-05-30 20:48:56


Doushibag 
Level 17
Report
56% wins vs current version? Not bad, but my new version gives 7% more cheese. That's less hungry botting. Can't beat that.
WarLight AI Challenge: 2014-05-30 23:45:55


Trogatog
Level 52
Report
ps, I don't think either of our bots expected this and had no idea what to do:

http://theaigames.com/competitions/warlight-ai-challenge/games/538915d24b5ab20a0172afe6
WarLight AI Challenge: 2014-05-31 04:02:16


Doushibag 
Level 17
Report
ps's bot seems to dominates mine. Played him 6 times and he's beat me every time. This is the best I've done: http://theaigames.com/competitions/warlight-ai-challenge/games/53879cca4b5ab20a017292c8
I might have actually tied (or possibly even won) in that game except he had two lucky attacks that gave him the advantage. The other 5 games he's won in 15 to 30 turns. Perhaps I'm just saving my lucky victory over him for later :P

I doubt he feeds his bot cheese so I figure some of these bots will be a bit anemic by the semifinals and I'll be able to have a lucky streak with my well fed bot. Atleast I assume your prior method of feeding your bots was doing it manually and then updating it and since you can't do that during the competition I figure my lone advantage lies in my cheesiness.
WarLight AI Challenge: 2014-05-31 09:56:51


ps 
Level 61
Report
Trogatog: mine should have started expanding into europe once the stacks were high on SA, no idea why it didn't, would have to debug it, but there is no motivation to do that now that the competition is closed :)
WarLight AI Challenge: 2014-05-31 22:20:30

{rp} pedrito 
Level 48
Report
Ikalgo: does your bot deploy his newly acquired North America income out of my sight on purpose? To "hide" the bonus? Well done.

http://theaigames.com/competitions/warlight-ai-challenge/games/538a38e44b5ab20a0172c687
WarLight AI Challenge: 2014-05-31 22:32:52

Ikalgo
Level 50
Report
pedrito: Yes! I was making specific changes on the last day to counter you and GreenTea; he actually immediately rushed me in North America as soon as he found out the income. So I went for 2 changes, hiding income and going for Australia to attack.

First to hold the border region in Asia so I can protect in time (GreenTea was building a large army in Australia in preparation of going to North America). Secondly, obtain North America, and then finally rush Australia. Note that my calculations allow me to nicely expand. I also monitor Europe at the same time; whenever 2 regions are held in Europe at the same time bordering North Africa, I would "smartly" try to break the bonus.

My main problem was that I wasn't able to test building an army in Asia. In the end, the troops just wander off rather than go for Australia, and they've ran into Dalek so many times causing me to lose (which is very frustrating!), and it happens not only against him. I was trying to keep it safe by implementing those 2 changes, but I believe against the current competition I could just hide income and instead simply first capture North America and then rush Australia; no need to hold Asia because you guys won't be checking unless you see my income.

Ah well, lesson learned.

Edited 5/31/2014 22:48:01
WarLight AI Challenge: 2014-05-31 23:56:01


Norman 
Level 59
Report
Hello

Can you give a link where you have North America + South America and the opponent has Australia and he then rushes North America from Australia? I don't think this is possible. The only way I can see this happen is when you use your extra +5 armies to expand like crazy instead of finishing the opponent off fast. Once you have more armies than him in Africa the game is won imo.

My bot also can tell that you have North America when you deploy more than 7 btw ;)... he just doesen't use that information properly. It's a problem that when you just start coding without specifying first it's quite hard to add completely new thoughts later.

The easiest solution to win is just keep stacking in Africa until you have enough to hit him. I can't remember my bot ever lost a game in such a situation and my bot doesen't even defend North Africa since he always attacks when there is an opportunity.
WarLight AI Challenge: 2014-06-01 08:10:49

Ikalgo
Level 50
Report
Hey,

Norman: Here is the example I was basing the assumptions on (http://theaigames.com/competitions/warlight-ai-challenge/games/5380e9f84b5ab2583f241863). There are a couple of more games like this. I was afraid that simply hiding the bonus wouldn't be enough to prevent the enemy from going to North America sometime in the game (also it is possible that the bots not only consider placements, but also transfers "to"; I know bots of a higher level would certainly take it into account). Before I knew we have enemy placement info, I was checking the amount of troops on the enemy regions at the end of the turn. If 2 turns the same increase, then that's what I would predict for the 3rd turn. This led to some great predictions, but somehow after changing placements instead of end-of-turn-counts the prediction didn't work that well anymore (e.g. I used to attack 2 troops with 5 if I was pretty confident it wouldn't be reinforced, but now this never happens anymore and I don't know why).

Oh and wow, it's so interesting to hear you were struggling with the specifics. I went for a general approach but with my split up strategies I couldn't really fit it and just went specific in the end. I still feel going "general" is the way to go. I guess what we would need is a general system that easily allows exceptions; but how :)?

Edited 6/1/2014 08:54:46
WarLight AI Challenge: 2014-06-01 17:22:21


Trogatog
Level 52
Report
First turn 5 win I've ever had I think. Best prior was 7:

http://theaigames.com/competitions/warlight-ai-challenge/games/538a92944b5ab20a0172cd55
WarLight AI Challenge: 2014-06-01 20:03:09


125ch209 
Level 58
Report
Hi, i uploaded my bot on github, so you guys can have a good laugh :D

https://github.com/125ch209/Gadzbot/tree/8e283bb1f30b4693fa0c8dd84317b4e24e49957d
WarLight AI Challenge: 2014-06-01 20:09:24

GreenTea 
Level 60
Report
to Blender: about http://pastebin.com/LryLDniy. Now I understand what you mean by simulation.. Im also tried to do this approash in the beggining, but find out that even with big number of simulations dispersion of results was too high. For example for first 1000 simulated attacks chance of capture was 0.76, and for second 1000 attacks - 0.74. Its not good when behaviour of bot depends so much from random numbers.

But it is possible to precise calculate average losts and also chance to capture using iterative calculation by formula of Bernulli
http://mathbits.com/MathBits/TISection/Statistics2/bernoulli.htm

For my bot simulation is little bit different. It is repeated virtual attack on region to give answer on question "coul'd I capture enemey region when from now I starting to attack with all forces and when enemy will use all his income on defence".
WarLight AI Challenge: 2014-06-01 20:11:47

GreenTea 
Level 60
Report
125ch209: wow. ~3000 lines of spaghetti code in one file xDD
WarLight AI Challenge: 2014-06-01 22:07:09


Doushibag 
Level 17
Report
1 Germany SupremeDalek-v358 Norman Java WarLight 2025
2 Ukraine GreenTea-v63 GreenTea Java WarLight 2022
3 Netherlands AdsRiskbot-v187 AdsRiskbot C# ExactFamily vdH 2019
4 Spain pedrito-v173 pedrito PHP WarLight 1961
5 United States Trogabot-v625 Trogatog C# The NerderyKansas CityWarLight 1927
6 Canada WisdomsPower-v138 Garrett C# WarLight 1917
7 China Herz-v229 herz Java UCLA 1905
8 Netherlands TheeYo-v246 Thee?Yo! C++ ASML 1899
9 Netherlands Blender-v875 Dualinity Python 1899
10 France Gadzbot-v1336 125ch209 Java WarLightFrench CommunityArts et Métiers Paristech 1890
11 Portugal psWarlighter-v101 psenough C# WarLight 1888
12 United States RaptorBot-v406 AllianceBot Java Ravenwood High SchoolWarLight 1860
13 Dbagbot-v85 Doushibag C# WarLight 1851
14 France KewaKareban-v182 kendou Python WarLightAm I the only one around here who's not in an university? 1841
15 Germany mweb-v478 mweb Java mweb 1837
16 Germany Webmartino-v204 Webmartino Java 1809
17 Germany Speedy2014-v191 Speedy2014 Java 1803
18 Czech Republic HouplessBot-v41 Houp C# Am I the only one around here who's not in an university? 1803
19 Poland Damian_Warlight-v228 Damian Java Wroclaw 1797
20 Switzerland Muli-v196 Muli Java WarLight 1786
21 Netherlands Assimilator-v49 mjjw C# Exact 1772
22 Poland SupremeLeader-v48 Scony PHP Poznan University of TechnologyWarLight 1752
23 Canada Alleirbag-v150 alleirbag Python WarLight 1750
24 Netherlands Toldea-v71 Toldea 1730
WarLight AI Challenge: 2014-06-01 22:09:30


Doushibag 
Level 17
Report
WarLight AI Challenge: 2014-06-01 22:14:31


125ch209 
Level 58
Report
heuuuuu.... pedrito and green tea on the same bracket?? really?

my bracket : 10-12-22-24
green tea: 2-4-14-16

does that makes sens? i mean i'm not complaining but...

Edited 6/1/2014 22:25:26
WarLight AI Challenge: 2014-06-01 22:25:12


Doushibag 
Level 17
Report
Being lucky number 13 in the ranks I get the pleasure of playing #1 SupremeDalek first! Fantastic, he'll give me a quick delivery to the loser's bracket and relieve me of any hope of lucking my way into the finals.
Posts 371 - 390 of 565   <<Prev   1  2  3  ...  10  ...  18  19  20  ...  24  ...  28  29  Next >>