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)
Errorbinaries/data/mods/public/simulation/ai/common-api/utils.js:88ESLintBear (no-use-before-define)ESLintBear (no-use-before-define)
Errorbinaries/data/mods/public/simulation/ai/petra/defenseManager.js:589ESLintBearESLintBear
Errorbinaries/data/mods/public/simulation/ai/petra/defenseManager.js:589JSHintBearJSHintBear
Errorbinaries/data/mods/public/simulation/ai/petra/defenseManager.js:589JSHintBearJSHintBear
Errorbinaries/data/mods/public/simulation/ai/petra/defenseManager.js:589JSHintBearJSHintBear
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)
Warningbinaries/data/mods/public/simulation/ai/petra/defenseManager.js:589JSHintBearJSHintBear
Unit
No Unit Test Coverage
Build Status
Buildable 13147
Build 26134: Vulcan BuildJenkins
Build 26133: Vulcan Build (macOS)Jenkins
Build 26132: Vulcan Build (Windows)Jenkins
Build 26131: 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
2477–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

forgot to rename

binaries/data/mods/public/simulation/ai/petra/attackPlan.js
1544

ouch

binaries/data/mods/public/simulation/ai/petra/defenseManager.js
589

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
2479

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

need sqrt here

binaries/data/mods/public/simulation/ai/petra/attackPlan.js
1549

issue

1552–1553

range = 8100

binaries/data/mods/public/simulation/ai/petra/defenseManager.js
142

issue

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

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

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

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