Jump to content

Non-random BuildingAI


Evaluating non-random building ai about 1 month into 26.6  

20 members have voted

  1. 1. Do you prefer the current community mod (26.6) building arrows to a26 building arrows?

    • yes
      5
    • no
      13
    • I could go either way
      2
  2. 2. The civic center arrows are too strong against rushes when garrisoned

    • Yes
      16
    • No
      4
  3. 3. Sentry towers are too strong against rushes

    • yes
      11
    • no
      9
  4. 4. Turtling is too strong because of non-random buildingAI

    • yes
      13
    • no
      7
  5. 5. Which of the following solutions would you support the most?

    • Don't change anything.
      1
    • Reverse the non-random arrows entirely.
      7
    • Balance the CC, Tower, and Fortress arrows.
      5
    • Make buildings shoot at random unless targeted.
      6
    • Make the civic center and fortress shoot at random unless targeted.
      1


Recommended Posts

I've long had my qualms with the random arrow damage provided by buildings, ships, and siege towers. While I guess it might appear more realistic, random arrows make defensive buildings unfavorable:

  • defensive buildings do little to deter small groups of units because damage is spread across all units. These units may still deal the damage their full numbers allow. In addition, they can just go home and heal. On the same thought, this makes them less interesting for offensive purposes.
  • defensive buildings are very effective when enough towers and forts overlap on an enemy army. Since all arrows find damage (no overkill), the towers accomplish area denial more than simply aiding the defender to beat an army.

I think building defenses would be more interesting and relevant to gameplay if all building arrows of a given attack targeted 1 unit, which by default would be the closest unit to the building. In theory, this would also make player controlled building arrows a little more logical. Out of curiosity, I made a little hack on BuildingAI to try this out and it "worked", with arrows targeting 1 unit at a time. However, it was not consistently the closest unit, and it caused freezes.

Is anyone else interested in this kind of change to building AI? That is, non-random targets? Has it been attempted before?

Edited by real_tabasco_sauce
  • Like 2
Link to comment
Share on other sites

5 minutes ago, wowgetoffyourcellphone said:

I don't want to see ships and siege towers snapping around at their targets though.

what do you mean by snapping around?

I'd say ideally, ships could end up with something more like unitAI for fighting (I think we talked about this in the naval overhaul discussion).

Edited by real_tabasco_sauce
Link to comment
Share on other sites

I think I would like what you describe for something like siege towers/ships. (This has also irked me for sometime)

Don't think I would want for buildings, though. 

It would make towers effectively the same as CCs and forts sue to unit “overkill.”
 

Also possibly OP in small to medium sized fights because a unit would die at whatever the rate of fire would be, which would make towers very consequential (I.e., early game rushes could easily be stopped with a 100w investment). 
 

I kind of like how buildings can have little effect to suddenly killing an entire army at once. I think it adds more macro tactics and is one of the reasons why advancing armies don’t easily snowball after killing their first base (I.e., it is common that an army dies fighting the second CC it tries to take down because the units are already low health). This is personal preference, though

relatedly, I think your two examples are positive. Towers weakening entire armies make countering much easier since a bigger, lower health army might be weaker than a smaller full health army. Likewise, towers create a two variable calculation instead of one, based only on unit numbers. Towers being more effective when close to each other also encourages more strategic builds  

  • Like 2
  • Haha 1
Link to comment
Share on other sites

1 hour ago, BreakfastBurrito_007 said:

In either case I would like to see melee units die faster to towers and ranged units slower to towers. 

Notwithstanding what I said above, I think it would be nice if towers and other defensive buildings had a preference for closer units. It doesn't make sense how towers are just as likely to randomly shoot arrows at faraway, hard to hit moving units as they are to shoot arrows at units trying to capture the tower/other defensive buildings. I wouldn't want it to be as simply as "targeting the closest unit" but I would like something where towers are like 3x as likely to target units within 10m than targets 50m away. But such a system gets complicated fast and I don't think we have code for that. 

  • Like 3
Link to comment
Share on other sites

4 hours ago, chrstgtr said:

I think I would like what you describe for something like siege towers/ships. (This has also irked me for sometime)

Don't think I would want for buildings, though. 

It would make towers effectively the same as CCs and forts sue to unit “overkill.”
 

Also possibly OP in small to medium sized fights because a unit would die at whatever the rate of fire would be, which would make towers very consequential (I.e., early game rushes could easily be stopped with a 100w investment). 
 

I kind of like how buildings can have little effect to suddenly killing an entire army at once. I think it adds more macro tactics and is one of the reasons why advancing armies don’t easily snowball after killing their first base (I.e., it is common that an army dies fighting the second CC it tries to take down because the units are already low health). This is personal preference, though

relatedly, I think your two examples are positive. Towers weakening entire armies make countering much easier since a bigger, lower health army might be weaker than a smaller full health army. Likewise, towers create a two variable calculation instead of one, based only on unit numbers. Towers being more effective when close to each other also encourages more strategic builds  

Agree on everthing, although overlapping forts/cc are a bit OP me thinks.

3 hours ago, Freagarach said:

Sounds like we want it to be a user-choice. ^^ (spread-attack or focus fire, not limited to structures)

Just sad it is hard to get user-preferred default values in the simulation properly (e.g. stances).

interesting, stances for building-AI would make it more transparent and user-friendly.

  • Like 2
Link to comment
Share on other sites

7 hours ago, real_tabasco_sauce said:

what do you mean by snapping around?

Well, with unit AI a unit turns to face its target quite rapidly. With soldiers this isn't too bad, but with a large siege tower and large ships, those units turning to face their target will look very rapid indeed. Large object wheeling around very fast. Perhaps there can be a target angle element where this can be relieved a bit.

Also, will need code to handle multiple projectiles. @Freagarach As currently the UnitAI only allows 1 projectile.

  • Like 1
Link to comment
Share on other sites

33 minutes ago, Gurken Khan said:

I think it already would be a step forward if towers etc. prioritized units. Currently they target buildings randomly even if enemies are around. :rolleyes:

But yeah, I would like to be able to tell my towers what/who to shoot at.

i thought as far as units are in range it will ignore building or?

 

Link to comment
Share on other sites

8 hours ago, Freagarach said:

Sounds like we want it to be a user-choice. ^^ (spread-attack or focus fire, not limited to structures)

Just sad it is hard to get user-preferred default values in the simulation properly (e.g. stances).

9 hours ago, real_tabasco_sauce said:

I think with the right spread values, this could be optimized to be less of a problem, but I see what u mean.

My thoughts were more to the effect of: structures with more default/garrisoned arrows (forts, ccs) would have more spread, while towers would have less spread. This way towers are more precise at longer ranges, with less risk for over kill. Forts and CCs on the other hand would get a slight spread increase compared to towers, with forts probably more than CCs.

Then going further, I think it would be better to allow player control of the building arrows than provide stances to adjust building behavior, but that's just my opinion.

Link to comment
Share on other sites

1 hour ago, Gurken Khan said:

Not as far as I observed. But I could be wrong. What does the code say?

Template for defense towers says it prefers eating humans for breakfast template_structure_defensive_tower:20

Building AI weights all targets using this and shoots at higher priority new targets as well as it current UnitAI target BuildingAI.js#L327

It seems there is a special code path for Buildings that have both UnitAI and Building ai UnitAI.js#L2183 which is used for ships.

  • Like 1
Link to comment
Share on other sites

My little hack seems to work for buildings and siege towers until the crash, I haven't tried it with ships. yeah it works with ships too.

I had to remove the weighted list for targets for it to work, so currently buildings are equally considered alongside units (since it's really just by proximity). Would it be fine for towers to shoot buildings if they are the closest unit? Or would it be better to first find a soldier within range and only shoot buildings if there are no soldiers?

I am very inexperienced with javascript (this was my first time writing js), so should I open a WIP patch or would someone with more experience rather take up the idea?

Edited by real_tabasco_sauce
Link to comment
Share on other sites

18 minutes ago, real_tabasco_sauce said:

Would it be fine for towers to shoot buildings if they are the closest unit? Or would it be better to first find a soldier within range and only shoot buildings if there are no soldiers?

I'd always prefer units. What good does it do if some arrows hit a nearby house or barracks?

  • Like 1
Link to comment
Share on other sites

yes the priority should be units, i think currently the default does just that. Shoots units in range and switch to buildings when there's no units nearby. According to the buildingAi script @Stan` sent if there are enemy units within range of the tower, the tower will prioritize shooting at the units over the buildings and if there are no enemy units within range of the tower, the tower will shoot at the closest enemy building. Maybe your towers shoots at both units and buildings when they are in range at the same time because of the modifications you made @real_tabasco_sauce? That will be a huge disadvantage for you cause your towers shooting at both buildings and units wouldnt cause too much to the opponents units

Link to comment
Share on other sites

30 minutes ago, rossenburg said:

Maybe your towers shoots at both units and buildings when they are in range at the same time because of the modifications you made @real_tabasco_sauce? That will be a huge disadvantage for you cause your towers shooting at both buildings and units wouldn't cause too much to the opponents units

Well the way I did it, the closest unit is selected as the target and it will be targeted until destruction. Whatever is closest is attacked until death, so If the target is a building, it has to be destroyed. Obviously, this solution is really just a proof of concept so I could make the video above.

Ideally, the script could check for any soldiers within range before resorting to attacking a building.

Also ideally, one attack's worth of arrows (default+garrisoned arrows per 2 seconds) would be sent to the closest target in targetUnits. After all the arrows are sent, the closest unit would be searched for again, rather than shooting the now more distant unit to death.

The second task might not be too hard, but for the first, I have no idea how to check the class of an entity in targetUnits. And then there are the freezing issues. I can open a patch later today if people think we should go ahead with this idea.

Edited by real_tabasco_sauce
  • Like 1
Link to comment
Share on other sites

It would be favourable for towers to focus fire on 1 unit and killing it before moving on to the next unit, as this would weaken the enemy units quicker. In addition, I think sentry towers need some hard 3x counter against archer cavalry, as these archer cavalry units are currently impossible to counter in phase 2 for non-archer civilizations.

Link to comment
Share on other sites

Ok, so I fixed the following today.

On 07/03/2023 at 11:25 AM, real_tabasco_sauce said:

Ideally, the script could check for any soldiers within range before resorting to attacking a building.

Also ideally, one attack's worth of arrows (default+garrisoned arrows per 2 seconds) would be sent to the closest target in targetUnits. After all the arrows are sent, the closest unit would be searched for again, rather than shooting the now more distant unit to death.

The second task might not be too hard, but for the first, I have no idea how to check the class of an entity in targetUnits. And then there are the freezing issues. I can open a patch later today if people think we should go ahead with this idea.

No freezing, and buildings are targeted last. I'll make a patch in a few hours.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...