Jump to content

stevenlau

Community Members
  • Posts

    26
  • Joined

  • Last visited

4 Followers

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

stevenlau's Achievements

Discens

Discens (2/14)

38

Reputation

  1. This is the AI doing it. I found that geometry is still very difficult, so the AI does not build anything yet. But it will analyze current buildings and plan the fastest route to gather.
  2. Added report of hit accuracy for ranged units. During real fights, the accuracy is around 50% ~ 60%.
  3. In stats, it shows how many soldiers died. However, we do not know what kind of units (melee / ranged) and how they are killed. Are they killed by structure? By melee? By ranged? These stats may help us to plan our strategies or upgrade plans better. I made this mod to print these stats in chat. For example, in this screenshot, I killed 16 civilian using melee units. I killed 1 civilian using ranged unit. Their CC killed 2 melee units of mine. Watch it working live when you see me around in lobby.
  4. First look at https://gitea.wildfiregames.com/0ad/0ad/src/branch/main/binaries/data/mods/public/simulation/components/UnitAI.js I think the first thing you will need is some tools that allow you to quickly search for a certain keyword in ALL files in 0AD. For example, inside UnitAI.js you would see cmpAttack.IsTargetInRange, then you need to search for where is it defined. You will be keep moving between many files, and up and down within a 5000 lines file. You will easily get lost if you don't have a convenient tool. I personally use Emacs, but I don't think you will want that. Perhaps ask ChatGPT if they have better tools suggestion for you.
  5. You mean the overlap of fields you see in game? They actually are not overlapping. The "core" part of a field is smaller, and I'm computing based on that core part only. In game, they render a bit more field outside of that core part. That part cannot be farmed, and is for aesthetic effect only.
  6. 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. 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?
  7. This is the call to arms button, folks!
  8. Vanilla 0AD? Better not pull in there unless they have solid plan of formation bonuses.
  9. Two things. To let engine read your new tag in template (so that no error pops up), you need to edit the schema at the beginning of formation.js. To let the bonus really happen, you need to modify a few js, and you must understand the whole unit AI attack flow.
  10. Further thinking about my 1D simplication case, I find that we can obtain the actual probability quite easily. Since x and y are independent, we can just take the square of the probability, which means probability of x being within +-1.5m of target times the probability of y being within +-1.5m of target. Next, since infantry is considered as a circle, we further multiply it with the area of circle divided by area of square. So, the exact probability of archer hitting target at 60m is 73.35% x 73.35% x pi x 1.5 x 1.5 / (3 x 3) = 42.26%. A spread upgrade would make it 54.77%. Pretty low! Would anyone perform experiment to prove it correct or prove it wrong?
  11. Thanks for trying to understand my imprecise description. Random normal distribution is a bell shape of standard deviation of 1. If we multiply it by a spread of 2, it becomes a fatter bell shape, with standard deviation of 2. Spread is calculated like 2.25 x 60 / 100. It doesn't change like the way you relate with area. Consider it like a radius of a circle, centered on the landing point of projectile At 100m the circle is large, so shooting is inaccurate, at 50m the cirlce is smaller, more accurate. You are right that the area changes by 4 times, but spread is more like a radius, not area. This is a 1D value, not 2D. The random distribution is 2D. Multiply the 2D distribution with the 1D spread factor to make the distribution fatter, larger, more spread out. x y are not position of the landing point of projectile, but the random values to be added to the position of the landing point to make it spread out randomly. With spread, the landing position is no longer a point, but a 2D normal distribution centered on that landing point. You are right to point out that they "shouldn't" be independent. But as fact, the source code calculated them independently, probably to speed up computation. So the condition x^2 + y^2 = R^2 did not hold. x is just a random value with normal distribution, and y is just another random value with normal distribution. Together, x and y has no relationship. That's why the CDF is not circular. It is weird, but it is the current fact. Also seems you tried to understand "independent" as separate, and counted 3 spreads. When I mentioned independent, it is in the sense of random variables. Since it is 2D, there are only two independent random variables. Spread is a constant factor, like 2.25 for archer. At distance of 60m it is adjusted to 2.25 x 60 / 100. Multiplying the spread would make the random normal distribution larger, fatter, more spread out. And I guess your final intuitive interpretation is correct.
  12. Spread of common infantry - Archer:2.25 Crossbowman:3 Javelineer:4 Slinger:3 Spread means how inaccurate the shooting becomes at 100m from target. The spread is less when closer than 100m. For example, it is half at 50m. Thus, archer and crossbowman are proportionally the same: 2.25 x 60 / 100 = 3 x 45 / 100 = 1.35 A projectile (arrow / stone / javelin) is considered to hit a infantry when it arrives at radius < 1.5m from target (indeed, a circle). A projectile is considered to hit a calvary when it arrives at the 3m x 6m rectangle of the target (indeed, a rectangle), which is a little larger than the size of two infantry. Dog is smaller, elephant is larger, charriot is larger. Now, at the beginning of a shoot, after waiting a short initial prepare time (once only), the future location of the target (because it may be walking) is very often precisely predicted, and the projectile is shot there, at a speed around 70m-100m per second, depending on unit. It should mathematically hit the target at the exact position when the projectile lands. Therefore, if the target changed direction during this time, the predicted future location is no longer correct, and the projectile might miss. This behavior is the principle of dodging. Even if the target did not change direction, the projectile might also miss due to the spread. The exact spread is given by a pair of independent normal random variable at variance of 1m. It is then multiplied by the spread. The result is some sort of 2D normal distribution, but since x and y are independent random variables, the 2D CDF is not circular, but more like a square. It seems super difficult to mathematically calculate the exact probability of it hitting a target. Let's get a rough idea by assuming the 1D case. I don't know how much would it deviate from 2D case, would be great if some mathematician could help. (Edit: I solved the 2D case, see reply below) In the simplified 1D case, I just use some online normal CDF calculator, fixing lower bound at -1.5, upper bound at 1.5, mean at 0, standard deviation at 2.25 x 60 / 100 = 1.35. Archer hits an infantry at 60m with probability 73.35%. After an upgrade of spread (-20%), standard deviation = 2.25 x 0.8 x 60 / 100 = 1.08, the probability is 83.51%. Crossbowman and slinger hits infantry at 45m with probability 73.35%. At rank 2 spread -20%, the probability is 83.51%. Indeed, exactly same as archer at 60m, coincidentally. Javelineer hits infantry at 30m with probability 78.87%. At rank 2, the probability is 88.18%. The best unit would be rank 3 archer plus spread upgrade, at standard deviation = 2.25 x 0.8^3 x 60 / 100, hitting target at 60m with 97%. Last but not least, when a projectile misses a target, it is not wasted. It will hit some innocent person standing there. Reference: https://gitea.wildfiregames.com/0ad/0ad/src/branch/main/binaries/data/mods/public/simulation/components/Attack.js#L714
  13. What is clearance? It is 0.8 for most units. Roughly regarded as the size of a unit. Reference: https://gitea.wildfiregames.com/0ad/0ad/src/branch/main/binaries/data/mods/mod/simulation/data/pathfinder.xml#L58 Clearance as full width In the calculation of pushing, each unit is first considered as a 0.8 × 0.8 square. Then the radius of the circumscribing circle is 0.8 × √2 ÷ 2. Reference: https://gitea.wildfiregames.com/0ad/0ad/src/branch/main/source/simulation2/components/CCmpUnitMotion_System.cpp#L78 Clearance as half width In regarding unit as obstruction, each unit is considered as an axis aligned 1.6 × 1.6 square. Reference: https://gitea.wildfiregames.com/0ad/0ad/src/branch/main/source/simulation2/components/CCmpObstructionManager.cpp#L305
×
×
  • Create New...