Code Royale (CC03) - Feedback & Strategies

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. :heart_eyes:

3 Likes

Great contest, thanks everyone!

It seems that there are three more days to update the code, but itā€™s not clear:

  • what is the effect of these changes, nor
  • how to do this, because clicking on that image leads to the page where there is only a link to the leaderboard.
1 Like

A few words on my code. I will finish around 30th or 40th so iā€™ll not go into the details:

  • Rewrite the engine
  • Cry on the performances
  • Tweaks the engine until itā€™s good
  • Use an AG
  • Cry on the performances where you have 20 knights on the board
  • Use a bruteforce on 2 turns when thereā€™s too many knights on the board
  • Copy a strategy from the top 5

About the contest itself.

Good points:

  • Almost perfect viewer. Thereā€™s only one thing missing in the viewer (the maximum mining of the sites). Itā€™s clear, everyone understand what itā€™s going on
  • At first sight the contest looks pretty fun but when you dig up a little ā€¦ (more in the bad points)
  • Pretty easy to have a working AI with a simple strategy. Easy to enter.

Bad points:

  • Referee in kotlin
  • Very bad balance between creeps. Giants and archers are useless because knights are too strong.
  • I just canā€™t understand why the engine is like this. In the end the winner of the contest is probably the only one with a perfect engine and good performances.
  • A complex engine like this one will not help heuristics. I donā€™t know why people think a ā€œhard to codeā€ engine will help heuristics. It will not. If we canā€™t predict the future with a simulation, how do you think an heuristic can do that ? You want to create a contest where heuristics will win ? Just use a massive branching factor. Look at Ghost in the Cell, itā€™s the perfect example.
  • I tried nearly all the contest to create a working strategy with giants. It will never work. My code in the arena is the code i submitted on monday.
  • Non symetric collisions and spawns. Very weird. The entire engine was nearly symetric but because of this 2 aspects the first player has a big advantage.
7 Likes

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 :slight_smile:

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:

  • Pseudo-simulator to estimate how much damage I will receive within 6 turns, including collisions.
  • If danger is detected, calculates the barycenter of ennemies, vector to the nearest tower to decide the spot where I should hide behind.
  • Donā€™t try to get through the site, run around it (trigonometry involved)
  • Considering where the enemies are so I donā€™t run back and forth into them doing so.

Bottom Gold to Top Gold (~75th) : I had to change my approach to get further.

  • Do not immediately try to rebuild gold sites that has depleted. Also remember to not build on sites that already were depleted before.
  • Altered slightly the strategy depending on how much starting health I have.
  • Changed the behavior according to the health difference with the opponent : the greater the advantage I have, the more defensive Iā€™ll get.
  • Make it so I efficently dodge sites that are on the way, like I do when running around a tower. This is not as efficient as pathfinding but it is simpler and still made a noticeable difference.
  • When building a new tower, try building on a site covered by at least two towers and that is not under enemy tower range.

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.

  • At the beginning, calculates the site closest the center that is closer than me than it is to the enemy, and the site which is the closest to the nearest corner (south west corner if red, north east corner if blue)
  • Run to the middle, maxing gold mines if sites are found on the way, then place a barrack.
  • Retreat to the corner, trying to build towers (without upgrading) on the way.
  • Build a tower on the corner site (and upgrade if I still have time before the first wave of enemy comes in)
  • The ā€œMission take over the centerā€ mode is shortened to building the barrack to the nearest plot instead of the center if the enemy is already preparing a wave. This is very important, or I lose to 95% of the gold league.
  • When corner tower is built, my old approach takes over and finishes the job.

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. :slight_smile:

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

10 Likes

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! :slight_smile:

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. :slight_smile:

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! :slight_smile:

9 Likes

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 :open_mouth: )

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:

  • Find a ā€œgoalā€
  • Find the best site based on my goal and build something there
  • Update movement: avoid sites, avoid enemy towers
  • Train stuff

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.

14 Likes

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 :slight_smile: )
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

  • an init phase where i try to build as much mine as possible and at least one barrack then i switch on one of the two other possibilities
    -I got more heath, i try to camp (but iā€™ve seen too many time my bored queen go for a walk under enemy towerā€¦)
    -I got less health, i try to land attack with synchronized knight wave(It was very simple, but i was happy to make it, even if it donā€™t seem to improve much the code)

I think that next time, i will try to simulate a bit in order to optimize my decision making!

Thanks for this contest!

5 Likes

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 :

  • Big bonus for health (overrides everything else)
  • Malus for destructed buildings (exemple : I build a mine over a tower)
  • Malus for each enemy knightā€™s health and squared distance to my queen
  • Gold income difference
  • Small malus for distance to the closest available site
  • Defense score (struggled with this one, and the result sucked) :
    defScore = (MIN(enKnights, 6) * (myTurretNumber * 4 + turrSize * 0.01));
  • enKnights = the number of enemy knights (those on the maps, those who are being produced, and 3 virtual knights for every 80 golds the enemy has)
  • myTurretNumber = sum(turrets) { 1.0 + (turret.distToMyCorner / 2800.0) } (I tried to favor turrets that are closer to the enemy corner, thus further away from my own corner)
  • turrSize = sum of turrets radiuses

    Itā€™s linear and it doesnā€™t have the notion of ā€œtoo much defenseā€. In lots of scenarios, my AI will build only towers. I tried to use log() and shit to make my AI stop doing that, without success.
    It also lacks a position component; for both the turretsā€™ positions on the map, and my queenā€™s position regarding the turrets. Often, my AI is making a pretty tower maze, then goes in the corner to make another one and gets stuck in there, trying to avoid incoming waves of knights, not taking advantage of the previously mentioned maze.
    I added a position score (mean of distances between my queen and my turrets), that didnā€™t work very well.

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

16 Likes

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!

6 Likes

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 :wink: ), 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.

20 Likes

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!

7 Likes

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.

My postmortem for this contest

29 Likes

Hey (Wow, posting just after the winner :heart_eyes:)
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:

  • If there are units close, go to the opposite direction of the closest one. (which is definitely not working well: Lot of time I was just blocked by a site behind me, or by the borders of the map)
  • If Iā€™m at a site, choose what to build. (bunch of if else)
  • Otherwise try to find a close site with no structure or a tower to grow.
  • Doing knights as soon as I can (if I have 2 rax, wait to train in both at the same time)

Legend / Simulation
Then I noticed the top bots were siming, making some really cool moves :slight_smile:
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 :

  • My queen health
  • total enemy creep hp (so they go under my towersā€¦ right?)
  • my mines destroyed during the process
  • Is my queen in range of my towers.

When I look at my final submission, I feel there are (at least) 2 huge issues Iā€™ve left:

  • I hesitate a lot when units are close. Where I could just DO stuff, like growing tower with safety. This is because I go into the PANIC ESCAPE MODE where I just try moves and not build anything.
  • I donā€™t make enough mines when Iā€™m ahead, which leads me to lose some games Iā€™ve started well.

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 :slight_smile:

The contest:

Positive:

  • I really liked this contest : a perfect mix between sim and heuristics (and being able to reach top 15 legend without sim is a good thing IMO)
  • Iā€™ve had 2 friends trying it (first CG contest for both of them), and they had fun. (They both ended up in the silver division)
  • Not too many inputs, I really like this. No aggro to keep track of or other weird stuff.
  • Perfect balance in game complexity for my taste.
  • Clear visuals
  • Kotlin referee. I actually think itā€™s fun to discover new language this way :thinking:

Negative:

  • Archers behavior seemed the most complex, but they werenā€™t useful
  • Being 25th doesnā€™t deserve a t-shirt

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 :smiley:

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! :wink:

10 Likes

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:

  1. My queen health (a lot of value) and the rival queen health (very little value).
  2. A score for each tower, mine or barrack. I used a logarithmic function to model the value of increasing the tower hp. The first 200 points are worth much more than the last 200 to complete the 800. Mines are worth more if they are close to the edges of the field, towers are worth more if they are more thowards the center, and barracks are worth more if they are closer to the enemyā€™s side.
  3. Distance to closest empty site.
  4. Health of rival creeps.
  5. On sunday I added a bonus for having a Giant barrack and for producing Giants if Iā€™m in the situation of having much more extraction rate than my rival.

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:

  1. She doesnā€™t move
  2. She improves towers and mines if she is touching them
  3. She produces knights every time she can.

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 !

12 Likes

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? :stuck_out_tongue: 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.

3 Likes

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.

2 Likes

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:

  1. 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?

  2. 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.

1 Like