Page MenuHomeWildfire Games

[Petra/Ai] Use parabolic range calculation when checking range of ranged attacks using elevation bonus from templates
Changes PlannedPublic

Authored by Silier on Sep 6 2020, 3:52 PM.

Details

Reviewers
None
Summary

This will help ai mainly on flat maps to place foundations out of fire range of enemy structures, so Petra will less likely lose resources because of useless trying to build stuctures again at some place.
This does not solve elevation bonus given by terrain hight or foundations destroyed by enemy ranged units.

Test Plan

Check that number literals are squared correctly.
Check squared parabolic ranges are compared with squared distances.

Diff Detail

Repository
rP 0 A.D. Public Repository
Branch
/ps/trunk
Lint
Lint OK
SeverityLocationCodeMessage
Errorbinaries/data/mods/public/simulation/ai/common-api/entity.js:984ESLintBear (no-use-before-define)ESLintBear (no-use-before-define)
Warningbinaries/data/mods/public/simulation/ai/common-api/entity.js:778ESLintBear (no-extra-semi)ESLintBear (no-extra-semi)
Warningbinaries/data/mods/public/simulation/ai/common-api/entity.js:778JSHintBearJSHintBear
Warningbinaries/data/mods/public/simulation/ai/common-api/entity.js:837ESLintBear (brace-rules/brace-on-same-line)ESLintBear (brace-rules/brace-on-same-line)
Warningbinaries/data/mods/public/simulation/ai/common-api/entity.js:854ESLintBear (brace-rules/brace-on-same-line)ESLintBear (brace-rules/brace-on-same-line)
Unit
No Unit Test Coverage
Build Status
Buildable 13130
Build 26081: Vulcan BuildJenkins
Build 26080: Vulcan Build (macOS)Jenkins
Build 26079: Vulcan Build (Windows)Jenkins
Build 26078: arc lint + arc unit

Event Timeline

Silier created this revision.Sep 6 2020, 3:52 PM
Silier requested review of this revision.Sep 6 2020, 3:58 PM
bb added a subscriber: bb.Sep 6 2020, 5:38 PM

Shouldn't we do something similar for all attackRange queries in the ai?

binaries/data/mods/public/simulation/ai/petra/headquarters.js
2478

attackRange might be a better name

Silier updated this revision to Diff 13456.Sep 8 2020, 10:24 PM

use correct elevation range calculation

Successful build - Chance fights ever on the side of the prudent.

builderr-release-macos.txt
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libsimulation2.a(precompiled.o) has no symbols

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/1525/display/redirect

Silier planned changes to this revision.Sep 8 2020, 10:30 PM
Silier added inline comments.
binaries/data/mods/public/simulation/ai/common-api/utils.js
30 ↗(On Diff #13456)

forgot to rename

binaries/data/mods/public/simulation/ai/petra/attackPlan.js
1544 ↗(On Diff #13456)

ouch

binaries/data/mods/public/simulation/ai/petra/defenseManager.js
589 ↗(On Diff #13456)

hmm, what to do here, it is fishing boat so meh ? but I want to avoid sqrt

binaries/data/mods/public/simulation/ai/petra/headquarters.js
2481

could do radius*radius out of loop

Silier updated this revision to Diff 13457.Sep 8 2020, 10:37 PM
Silier retitled this revision from [Petra/Ai] Use elevation bonus from template when checking if entity can fire at us to [Petra/Ai] Use parabolic range calculation when checking range of ranged attacks using elevation bonus from templates.
Silier edited the test plan for this revision. (Show Details)Sep 8 2020, 10:39 PM
Silier planned changes to this revision.Sep 8 2020, 10:58 PM

dummy
(a+b)*(a+b) != a*a + b*b

Silier added inline comments.Sep 9 2020, 8:34 AM
binaries/data/mods/public/simulation/ai/petra/attackManager.js
179 ↗(On Diff #13457)

need sqrt here

binaries/data/mods/public/simulation/ai/petra/attackPlan.js
1549 ↗(On Diff #13457)

issue

1552 ↗(On Diff #13457)

range = 8100

binaries/data/mods/public/simulation/ai/petra/defenseManager.js
142 ↗(On Diff #13457)

issue

binaries/data/mods/public/simulation/ai/petra/headquarters.js
2481

issue

Stan added a subscriber: Stan.Sep 9 2020, 8:46 AM
Stan added inline comments.
binaries/data/mods/public/simulation/ai/petra/attackManager.js
179 ↗(On Diff #13457)

need sqrt here

Could square the dist ?

Silier added inline comments.Sep 9 2020, 8:59 AM
binaries/data/mods/public/simulation/ai/petra/attackManager.js
179 ↗(On Diff #13457)

hmmm, yes

Nescio added a subscriber: Nescio.Sep 9 2020, 10:46 AM

loose

Is this some kind of sociolect? I'm asking because I've also observed other team members write ‘loose’ (i.e. set free, release) instead of ‘lose’ (i.e. be deprived of, cease to have) more than once.

no, thats just my english, thank you

Silier edited the summary of this revision. (Show Details)Sep 9 2020, 10:48 AM