Jump to content

stevenlauBot game start teleportation


stevenlau
 Share

Recommended Posts

I am developing an AI called stevenlauBot.  I have only made the game start move.  All units go to the tree nearest to CC, cav goes to chicken, either by walking or teleportation, whichever faster.  It looks cool!

My plan is to make the AI to play standard tactics like how I usually play (only Han).  It will be useful to practice 1v1.

output.gif

  • Like 4
Link to comment
Share on other sites

  • 5 weeks later...
  • 5 months later...

Six months has passed.  Development of stevenlauBot did not stop, but I have been dealing with a really difficult problem - optimal field placement around CC.  The algorithm improved over and over, and now reaches an optimal solution worth sharing.  Before I go into technical details, here are some screenshots of optimal placements in random Mainland.  Pink represents the region where we can place field freely, and blues are the fields.

a.small.png.d6869a3a712402ffc731905275a3c102.pngb.small.png.8594d74b36320ce81e1a61a7cc9756e5.pngc.small.png.7ef33d3f353b2fe240ea450f197c187b.pngd.small.png.623907eeedccb4a4d2f6cdb5ab47a3e6.pnge.small.png.ab879fc6978e64464e81d7e7bf56b07e.pngg.small.png.fc25ef1a3a4a1966636974b49024049d.png

Now I am writing some technical details.  I first define Gap and Hang.

Gap

Ideally we want to let a field to touch (snap) the CC (or actually any dropsite), so that farmers can efficiently drop resources without walking.  However, since farmers have a size and dropping range, we can actually leave a gap (around 5.6m) between field and CC and the farmer can still drop resources without walking.  Leaving such a gap might allow more fields to be placed.

Hang

In games, we often see players put field snapping at the corner of CC.  This is not ideal, because farmers will have a walk a bit to drop resources.  We name this case "hanging" entirely outside of CC.  If we now shift that field a little inward toward the CC, it is still hanging, but only part of it is hanging.  Then farmers can farm in the part where the field is not hanging, and they can drop resources without walking.  That non-hanging part is around 8m.

Now to state our problem more precisely, we want to place maximum number of fields around CC, allowing gap between CC, but keep certain non-hanging part.  We disallow rotation.  Although rotation might give better arrangement, the problem will become too difficult.  In fact, disallowing rotation is the sole assumption of our algorithm.  Under such assumption, our algorithm gives optimal placement.  I also claim that if we allow rotation, no efficient algorithm exists.

People who are familiar with algorithm, especially computational geometry, should realise this is a very difficult problem.  This is shape arrangement in continuous 2D space, and deterministic algorithm might not even exist.  Scientists usually do heuristics to find good-enough (but not optimal) solution in these problems.  I had also been working on heuristics, but as I keep improving my heuristics, I found that our problem is quite special and is much simplified.  It turned out that we can work out a combinatorial algorithm to really find the optimal placement.  We basically do trapezoidal decomposition of the region, that we do sweep line algorithm over all such trapeziums, exhaust all combinations, and merge linearly related constraints.  The algorithm is super complicated, but I think I made it.  Do you like it?

 

 

Edited by stevenlau
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...