The topic where you can tell how you liked the challenge, & how you solved it.
Thanks again csj, harshch000 & Netbattler11 [Testers: Illedan, AntiSquid, Bruno Felthes & Tiramon] for this amazing contest.
The topic where you can tell how you liked the challenge, & how you solved it.
Thanks again csj, harshch000 & Netbattler11 [Testers: Illedan, AntiSquid, Bruno Felthes & Tiramon] for this amazing contest.
Great contest, thanks everyone!
It seems that there are three more days to update the code, but itās not clear:
A few words on my code. I will finish around 30th or 40th so iāll not go into the details:
About the contest itself.
Good points:
Bad points:
BlitzProg, 105th (29th gold)
Well, that was quite the challenge. It took me a long while to appreciate and even then Iām still not sure what to think about it. I think I liked it, but oh man - so much frustration! So much abstraction, any wrong move will swiftly be punished by unexpected side effects, and unless you have perfected your approach (simulation included), youāre in for a lot of trouble.
The referee was simpler to understand for me this contest in comparison to the previous one, but it was too complex for me to accurately use to simulate. I had to simplify a lot of things and forget about using complex algorithms. I miss using Monte-Carlo and Genetics.
Thanks to MooMooN for the late advice which allowed me to get 50 extra places in the gold league
Wood 3 to Wood 2 : Build barracks on the nearest site, then just train. Boss does the same thing but waits purposely, so you canāt lose.
Wood 2 to Wood 1 : Build a tower on the nearest site, then barracks on the 2nd nearest. Then strengthen the tower indefinitely.
Wood 1 to bottom Silver : Same thing as above, but build three level 1 gold mines before doing that.
bottom Silver to Top Silver : Copycat on the boss, which means building mines until it gets +6 income, then barrack, then 3 towers.
Silver to Middle Gold : Painful effort went into beating that league. I tried many things during the week. After starting from scratch again and again this i what I came up with:
Bottom Gold to Top Gold (~75th) : I had to change my approach to get further.
Top Gold (~75th) to Top Gold (~25th) :
MooMooN suggested I should try to place a barrack near the center to increase the likelyhood of squashing my opponent early (thanks for that!) so in two hours I coded a āMission take over the centerā mode.
And that was it! In the end, I didnāt as bad as I first expected to.
Iām really tired now, but I have work today! Tomorrow is day off, so Iāll have a good sleep.
P.S. My twitter thread of me participating from the beginning of the contest to the end, with various replays posted in the way (French): https://twitter.com/BlitzProg/status/987689008443592705
You can update your application, not your code. In this specific contest the application doesnāt do anything so you can pretty much ignore it.
Hey there!
From Bronze to gold I used something very simple: going to the nearest site I build 2 mines (+upgrade), 3 towers, barracks-knight and then return to upgrade the towers. This worked surprisingly well because more often than not the barracks was placed closer to the enemy queen, and towers were forming a triangle-kind-of shape. Also, when shuffeling between the towers often made the enemy knights collide with sites. So, yeah, played the chances it seems.
I made some adjustments to enforce this kind of layout + I rushed to build the barracks before the towers, but also attacked the enemy barracks from time to time, when itās placed close to my queen (this last one actually beat the gold boss at the time). Building additional mines every now and thenā¦ and that did the trick.
Playing this dildo style (all in) was good to some point, but it has a downside especially in legend, since the queenās health is less and most of the players build a barrack and spawn knights right from the beggining. Of course the idea is to make the other player busy as the knights decay over time and the attack is not really effective (long term effect though) because ot the longer distance, but versus me is huge deal since I myself close the distance. I sticked to my strategy and of course my queen took a massive beating a lot.
Iām pretty pleased with this contest, because I didnāt do anything special (I didnāt even do pathfinding, unit or site avoidance, etc.) but got pretty far ahead.
Thanks, creators, I enjoyed this contest a lot!
Hey ! Iām almost stabilized and its looking like Iāll be 57th in legend. It was a really cool contest.
Iād say the strongest part of my bot was my knights avoidance a little bit of math and heuristic made me run away from the knights pretty efficiently, but I got passed in the end by the simulations (I would need a lot more math to beat them )
What was bad to the very end was my tower building. So I stole Xyze tactic of building a knights barrack on the start to make a bit of damage then camping with towers, it made my bot A LOT better, since it used the strength of my bot while ignoring its weakness. So I was pretty much hugging Xyze in the rankings, stayed in the top 10 until wednesday when people started to counter the camping tactic.
So I tried to bring back from the dead my non camping bot. My bot was pretty much working in 4 steps:
So my camping was pretty much just a goal that I could drop and bring back. I realized that my bot was doing decent if he could have 2 towers close to each other, so I just made a really simple check for a ā2 towers clusterā to make groups of 2 and I finally was able to beat my camping bot.
I made a āmake a swarmā tactic to hold knights to make a big swarm of knights and beat camping bots (like my old self) it was looking good at first, but then when I got stuck in gold top 10 when legend was out, I realized the lack of pression from my knights was giving my enemy precious time to build more. So just reverting that made me go to legend.
Then I tried to simulate. Cause one of the problem of my bot was trying to reach a site, encountering enemy knights, running away, then try again the same site, then run away again. So I tried to simulate the time it would take to reach a site with my queen, then the time (including training knights) the time the enemy knights would take to reach it, to ignore them and go to another site. But it made my bot WAAAY too passive, afraid of everything and getting pushed back with no space to build.
So in the end I pretty much submitted my thursday night codeā¦
Still, it was a very fun contest, Iām a bit disapointed in my self for hitting a wall in the end, but I really liked it.
Quite fun contest!
We held a littlehub with BlueGhost31 and from monday to friday, weāve watch game and comment strategy between 12h and 14h.
It was quite usefull to come up with a strategy.
On māy part, Iāve never simulate move and Iām quite prood of my ranking (and being the gold boss )
My code is nearly the same as on friday. Iāve mainly cut down useles branches since then.
regarding strategy, Iāve got three point
I think that next time, i will try to simulate a bit in order to optimize my decision making!
Thanks for this contest!
Hi,
17t Legend
I spent half of the contest hesitating between a pure simulation solution and a heuristic one (with a little simulation in micro-situations).
For both solutions, I needed the engine, so I started with this. Took me 2 days to write an bugged engine. After the initial draft, I spent a few days trying to figure out why the engine was slow and innacurate.
Pro-tip : re-read carrefuly the referee code when translating, and OVERTEST your engine in every possible corner case. Long story short, I lost shitloads of time with hidden bugs (the referee helped, as you can now run a local game with breakpoints in both your own code and the referee, and compare simulation steps on both sides to spot deltas).
Meanwhile, I was still hesitating between the two types of solutions and spent some time on both, in parallel; perfect time-wasting strategy.
The information given by the referee was once more incomplete, but it was pretty easy to guess enemy gold/income (assuming a queen standing still next to a mine is upgrading it).
Friday I finnally managed to fix most of my bugs and started focusing on a genetic algorithm, dismissing the heuristic version of my AI.
My evaluation function is rather classic :
defScore = (MIN(enKnights, 6) * (myTurretNumber * 4 + turrSize * 0.01));
I also wanted to add something that says āyou will lose some life, but in the long run thatās okā, but didnāt succeed.
Like in lots of other contests, my evaluation is poorly-balanced and lacks tons of stuff, but thatās the best I could come up with in 10 days.
On the game itself, it is quite unbalanced but very interesting nonetheless; simple inputs/outputs, easy naive solutions but enough depth to really scratch your head. Congratz CC team.
Alos, kudos to CG for introducing swapped matches in the rerun.
Neumann
60th in legend.
Heuristic bot, not much to brag about, perhaps the strongest part is the gold control. It shoots only if the enemy is close or has bad tower protection, otherwise it saves gold. Once a threshold is reached it will try to build a second knight barrack and go all out.
I had prepared for the contest by practising Clash Royale . I like Clash Royale for the deck selection aspect, and how to counter cards. I missed this in this competition, since the archers and giants were useless.
Still it was an interesting contest with ample of room for different strategies. I had a good time, thanks a lot to the creators of the game!
10th
I decided early to build a hybrid algorithm:
For the macro game (where to build, what to build) I use heuristics. But for the micro game (how to escape from knights) I have a simulation of the game.
Path finding is done by checking for any other sites between me and my target (circle-line intersection with the queenās radius added to the obstacle circle). I then combute the two tangents to the obstacle circle through my queenās location and chose the one with the intersection point closer to my actual target and go there instead of to the target directly. When I know where I want to go, I run a bruteforce over different angles to take enemy towers and my own knights (they could block me) into account and get as close to the target as possible. This did not work well all the time, but did an OK job in general.
The heuristics part is quite boring: If the enemy is near, switch to escape mode (with sim), otherwise do actions based on the location of my towers, barracks mines as well as the opponent units.
If the enemy is attacking (but not in direct range), I try to go to each site to possibly build a tower there and check if I can do so before the enemy arrives and hits my queen (using the sim again). I then choose the site that is the closest to the opponent while still in a āsafeā range.
Depending on whether I have more or less health than my opponent I either build towers and wait for the game to end or spam mines to attack and move the barracks closer to the opponent.
My simulation only uses depth 3 (when the enemy isnāt too close) or depth 2 (when the enemy is near and I will take damage for sure), because I donāt get many iterations and miss a lot of better options with higher depths (my sim is almost 1:1 the referee without optimizations - I supposed that adjusting the heuristics gives higher benefit than performance tuning).
It allows me to run away from the opponent and use collisions to my advantage not to take too much damage.
The simulation completely ignores Giants and Archers (not a big deal, as almost noone uses them) and also doesnāt spawn any creeps (resulting in smaller errors, as the spawn does a collision check as well - moving the creeps that already are on the map).
I really liked the game. It allowed for both heuristics as well as simulations to compete for the tshirt ranks. The graphics were well designed and simple (cool artwork for the towers; no real knights might not look that nice, but itās easier to debug this way - and I watch the replays to analyze the bots, not to admire the graphics ), I only missed a way to print debug text. I was quite happy, that the giants/archers didnāt work well (it would add more complexity and coding large heuristics is no fun for me).
On the downsides I see the assymetric collision + spawn giving the first player an advantage (there were two matches with swapped positions in the recalc, so Iām fine with it) as well as the Kotlin referee.
Latter is just a personal preference, as Iām used to C#/Java code. I was able to understand what the Kotlin code did, it just took me longer than usual.
Excellent contest! First time legend for me (45th), and second in python after a tough battle against Spacerouquin (Congrats, man! Well done!).
I totally agree with you all for the game graphics, which were excellent. And also the gameplay which allowed for both heuristics and simulation - much more like simple calculations in my case as I will explain.
Concerning heuristics, nothing much to say except that I beat my ifs blocks record: 17! I am sure some did much better with lessā¦ What made me gain some places however was my escape function, used when the queen is attacked. I did just like for mean max as it worked quite well : a wind rose of the future positions my queen can go : 16 points at 60 pixels distance away. And then, for each of these positions, ascribed a score according to the distance to the point I want to go to, the enemies around, the obstacles in between, distance away from my gold mines to avoid to break themā¦etc. Then I returned the best of these positions Quite easy to code and much valuable to escape enemies knightsā¦
To conclude, thank you very much for the contest, CG and the creators, much fun once again!
Thanks to the creators for a very fun contest. Very happy to have won a proper contest, especially after coming so close during Mean Max.
Hey (Wow, posting just after the winner )
25th Legend
Iāve started full heuristics.
I thought I wouldnāt have enough time with my current personal schedule to go deep in this contest. (aka sim)
Looks like CG contests are actually hard not to focus on while started oO
Went gold with some basic strategy:
Legend / Simulation
Then I noticed the top bots were siming, making some really cool moves
So I jumped in. I have some bugs in my sim I didnāt have the time to fix (or maybe I had and I should have, but thought "letās focus on macro strategy instead), which made the very end of the contest problematic for me (had to do some approximations)
I saw in several games opponents using the tactic of going to the center to build one rax, I used it to have a simple strategy to test my sim/avoidance.
This strategy + the sim made me go into legend right away.
After that, I just made my code more complex to handle some differents cases (Iām not sure if those modifications were all the time for the best though, but I might pop giants sometimes ā¦ definitely worth it!)
My simulation is using MC/depth 6, Iām doing it only for creeps not too far from my queen, with fitness using :
When I look at my final submission, I feel there are (at least) 2 huge issues Iāve left:
I feel with a perfect sim, I could have done way better (since I currently donāt fully rely on it because of bugs). But itās hard during a 10 days contest. I might come back for the multi
The contest:
Positive:
Negative:
Thanks to the creators of this really fun game, CG obviously and reCurse for not participating and letting me the #1 canada spot for the second time
ps (unrelated to the contest) : Being a C# programmer training my C++ here, Iām still sad not having Linq to quickly write and test heuristics. Iām wondering how I could quickly write readable code like in c++:
var jungleMobs = Units.Values.Where(p => p.UnitType == eUnitType.Jungle && p.DistanceFrom(Enemy.Tower) >Enemy.Tower.Range +50).OrderBy(p => p.DistanceFrom(Me.Tower)).Take(2)
If someone has advice for me, go ahead thanks!
4th Legend.
First of all thanks to the creators, it was a really fun contest with a lot of possible strategies and a good balance between sim and heuristic approaches.
Start heuristically
I started the contest with heuristics on first Friday since when I first saw the rules I thought ātowers, creepsā¦ this should be similar to BOTGā. I reached Bronze with a simple heuristics bot that built 2 mines, then a barrack and then towers. When the mines depleted it built new ones. I couldnāt code the first weekend, and when I took it back on Monday I knew heursitics evasion would never be as good as with sims, so I started working on the engine. I donāt agree with others that found it hard to code, I found it relatively simple to build a āgood enoughā engine in a few hours that could evade knights farily well. At this point my code was heuristics for build, move and produce, and when being attacked I used a random search of depth 4 to evade.
Switch to sim
Then I figured that since I had an almost fully working engine I should try to make all decisions by simulations, including creep production. I switched my code to a GA of depth 10 with a decaying factor of 0.95 and fixed the details that were making my simulation fail (thanks a lot to RoboStac and Illedan for their help understanding some details that I had missed from the Referee and from Kotlin!).
Depth
Regarding the depth, Iām not entirely sure why but I was able to find good solutions despite achieving only like 250 sims per turn on depth 10 (because of the expensive engine and my code is not the most efficient). I even had good results with depth 14. I think itās because I didnāt use much rival information in my eval, so the impact of the rival decisions usually takes several turns to affect my queen (knights attacking for instance), so the solution of the previous turn shifted is a very good starting point.
Eval
I always find it difficult to write good eval functions. I find it hard to compare the value of for instance losing 1 unit of health vs building a mine or increasing a towerās hit points. In the end my eval takes into account all the following:
Missing information
Since symmetric sites are consecutive in ids, i set the maxExtractionRate of the sites symmetric to my known sites. Hence I could estimate preety accurately the total extraction rate of the rival queen and also her gold.
Enemy prediction
For rival prediction, I only used the following:
Good Saturday, Bad Sunday
On Saturday night I sent a version of the code without expecting much, and it ended up in 2nd place, right in between Agade and RoboStac !
After that I spent most of my Sunday trying to simulate the rival queen with my GA for the first milliseconds of the turn, but I failed misserably while my ranking dropped slowly to towards the 10th place. Iām still not sure what went wrong, but my bot couldnāt stop making stupid decisions and I couldnāt find the bugs that caused that behavior. Pursuing that instead of improving my eval was the worst decision I made on the contest. On Sunday afternoon I decidedo to drop rival simulation, go back to my Saturday version and try to improve that. Until that moment I didnāt have any Giant barracks in my moves, and my mining vs towering decisions were very conservative (max 2 mines unless iām in a preety comfortable position). On Sunday night I made a change to be much more mining aggressive, and I tried that code against Agade, Xyze and Risus and to my surprise, this aggressive behavior paid off and I was beating them more often than not ! I submitted this expecting the same results as Saturday night, butā¦ The excesive aggressiveness paid off against some, but it took excesive risks and got destroyed in a lot of matches, even to players in the lower end of legend.
Letās balance it out
Finally I made some more adjustments to make the AI more balanced between the mining/towering dicotomy, and with that change I ended up 3rd/4th in the ranking on Sunday night (Agade/Azkellas were computing atm) and finally after the rerun ended up in a comfortable 4th place (same as in BOTG). I really wanted to end up in a podium position, but hey ! Maybe the next contestā¦
Thanks again to the creators, congratulations to the top 3 and specially to RoboStac that wrote an amazing AI that dominated the competition almost from start to finish. Great work !
Iāve managed to make it to Rank 30 in Gold besides spending very less time coding.
Wood to Bronze :
I spent my first 6 hours in wood3 writing my classes. After that it was easy to get to bronze in just 1 hour. I initially didnāt even needed mines because we have gold per minute without mines.
Bronze to Silver:
I wrote a basic sim hoping to implement random search because random search helps avoiding creeps to escape optimally. In a game turn all we can do is 1) Move to a random point or 2) Build at the site Iām located at. Try 40000 random choices at a depth of 5 and choose the one which gives the best score. I score my number of barracks, towers and my distance to my next target and distance away from closest enemy creep.
That helped me get to Silver.
Silver to Gold:
I realized that for making the eval work for the whole problem i need to implement the sim correctly and the weight distribution is very complicated to code because there are just too many factors only if else can resolve. Also as I could only spend very less time for the contest, I switched back to if else. (Feel free to tell me Iām lazy to write a proper sim and eval)
I did aggressive placement of barracks with a full defensive (not as good as simās defense. But my attack is much stronger)
Climbing to high gold
Copying the boss strategy didnāt help me go above top 100 because there were too many anti boss strategy at the bottom. I build my mines at my spawn corner, then build a aggressive baracks then build my towers in the other edge of my spawn corner (so my mines wonāt be destroyed). This helped me stay defensive as well as not hindering my attack. This strategy miserably failed against gold boss because gold boss builds barracks very close to my tower area and I had very less options to hide. But this was sufficient for me to be there at the top gold.
This was the first contest where I wrote code with few bugs (and none of them were crashing my bot with segmentation faults or run time error) and was able to fix bugs quickly. (May be Iāve improved? or is it just the problem is too easy to write code for?)
My repeated feedback that I give after every contest : Open this for Multiplayer immediately just like any other coding challenge websites (like Topcoder or Codechef or Codeforces or what not). Peopleās interest will get reduced 2 weeks from now when you open it up on multiplayer.
Hey T-Dup,
For this contest I coded a LINQ-like queries in C++:
const Unit closestEnemy = game.Units().All().Enemy().Creeps().ByDistTo(myQueen).First();
The trick here is that the filters methods in your query class should return reference to *this
, that allows chaining them:
class UnitsQuery
{
public:
UnitsQuery(const std::vector<Unit> &units);
UnitsQuery &That(Filter &&filter)
{
filters_.push_back(std::move(filter));
return *this; // <-- this allows chaining
}
UnitsQuery &Sites()
{
return That(IsSite);
}
std::vector<Unit> AsVec();
Unit First();
...
Itās not as pretty as LINQ, and you have to code quite some code manually, but in the end it does its job quite well.
And to save a bit of performance, you could operate not on a Unit
directly, but on a reference or a pointer to it.
Being a C# programmer training my C++ here, Iām still sad not having Linqā¦
If someone has advice for me
Request Boost to be added to environment. It has range adapters that allow syntax like items | filtered(predicate) | transformed(mapping)
.
Thanks everyone for posting your strategies; it is very interesting to read.
I have 2 questions for you guys:
For those using simulation-based strategies, how did you guys come up with the set of moves that your queen could make each turn? Like the queen can travel anywhere within 600 radius; how do you determine which were the āinterestingā moves you would choose between each turn?
What is your dev workflow like? I spent my time writing all my code in a single file but this became painful. Is there some tool which lets you write code in multiple files but then compile it all into one file for submission?
Many thanks.