Page MenuHomeWildfire Games

remove optional arguments of randFloat
ClosedPublic

Authored by bb on Apr 22 2017, 11:14 PM.

Details

Summary

In a previous random cleanup commit, these optional arguments were left, but were ment to be removed afterwards when all occurrences were removed. Removing all those in this patch.

Test Plan

load changed rms in Atlas

See that the code is logical equivalent

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

bb created this revision.Apr 22 2017, 11:14 PM
Owners added a subscriber: Restricted Owners Package.Apr 22 2017, 11:14 PM
bb added inline comments.Apr 22 2017, 11:15 PM
binaries/data/mods/public/maps/random/deep_forest.js
163 ↗(On Diff #1434)

Didn't inline this and below to avoid inconsistency throughout the file.

leper added inline comments.
binaries/data/mods/public/globalscripts/random.js
30 ↗(On Diff #1434)

Remove this part of the comment too if you remove the default parameters.

bb updated this revision to Diff 1435.Apr 22 2017, 11:48 PM

update comment accordingly as noticed by leper

Vulcan added a subscriber: Vulcan.Apr 23 2017, 2:01 AM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/866/ for more details.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/867/ for more details.

elexis accepted this revision.Apr 27 2017, 4:40 PM
elexis added a subscriber: elexis.

Wasn't really convinced to remove the 0, 1 but since that function is used in the simulation, might be better off having users of the function specify a value.
(Would like to keep the randBool(0,5) if you don't mind though, since I don't see how the meaning of the arguments would ever change and 0.5 will be the vast majority of calls)

binaries/data/mods/public/maps/random/ardennes_forest.js
124 ↗(On Diff #1435)

✓ seems more readable indeed

binaries/data/mods/public/maps/random/caledonian_meadows.js
167 ↗(On Diff #1435)

✓ that is nicer to read

312 ↗(On Diff #1435)

✓ that is nicer to read as well

359 ↗(On Diff #1435)

385 ↗(On Diff #1435)

737 ↗(On Diff #1435)

✓ (since we wanted to get rid of TWO_PI)

binaries/data/mods/public/maps/random/corsica.js
184 ↗(On Diff #1435)

✓ oh yes, that seems better, no need to compute the values.

was wondering whether that 17 had some meaning, but I can't find anything, appears to be an experimental/artistic value, just like all the other RMS values.

0.49 + 1/17 is 0,548823529, so the error 0,1176471%

336 ↗(On Diff #1435)

binaries/data/mods/public/maps/random/cycladic_archipelago.js
105 ↗(On Diff #1435)

249 ↗(On Diff #1435)

✓ since startAngle was declared above

257 ↗(On Diff #1435)

meh, if we have to

binaries/data/mods/public/maps/random/deep_forest.js
163 ↗(On Diff #1434)

✓ notice -1 can now be a result and 0 can't be a result anymore, but that is neglible since the likelihood of these numbers appearing is about zero

201 ↗(On Diff #1435)

211 ↗(On Diff #1435)

234 ↗(On Diff #1435)

240 ↗(On Diff #1435)

binaries/data/mods/public/maps/random/latium.js
97 ↗(On Diff #1435)

Some could make this 0.01 a const, so this is making the existing code easier to read but less nice to manipulate.
The 0,01 could be moved out of that function even

102 ↗(On Diff #1435)

and reused here

binaries/data/mods/public/maps/random/new_rms_test.js
34 ↗(On Diff #1435)

binaries/data/mods/public/maps/random/rmgen/library.js
129 ↗(On Diff #1435)


Using "// Uniform distribution of the area" as you have proposed on irc
Since r is sqrt(uniform), PI*r^2 must be uniform

binaries/data/mods/public/maps/random/rmgen/misc.js
778 ↗(On Diff #1435)

binaries/data/mods/public/maps/random/rmgen/noise.js
35 ↗(On Diff #1435)

93 ↗(On Diff #1435)

✓ yep, that looks much nicer

binaries/data/mods/public/maps/random/rmgen/placer.js
51 ↗(On Diff #1435)

✓ yes nice

binaries/data/mods/public/maps/random/rmgen/terrain.js
45 ↗(On Diff #1435)

binaries/data/mods/public/maps/random/rmgen/utilityfunctions.js
217 ↗(On Diff #1435)

✓ inlining only and using Math.foo

binaries/data/mods/public/maps/random/schwarzwald.js
437 ↗(On Diff #1435)

This revision is now accepted and ready to land.Apr 27 2017, 4:40 PM
fatherbushido added inline comments.
binaries/data/mods/public/maps/random/rmgen/library.js
129 ↗(On Diff #1435)

Something like "uniformly distributed on the disk".
(The comment should be on the top of that block, it was misleading to put it near r).

Also complete since no calls to randFloat() are remaining. Tested only corsica vs sardinia and didn't notice any difference for that 0,1% percent change, the other changes are trivially correct.

elexis added inline comments.Apr 27 2017, 4:56 PM
binaries/data/mods/public/maps/random/rmgen/library.js
129 ↗(On Diff #1435)

k
disk indeed seems to be the correct mathmatical phrase:
https://en.wikipedia.org/wiki/Disk_(mathematics)

Also our favorite AE/BE distinction again:

When there is no clear convention, the spelling disk is more popular in American English, while the spelling disc is more popular in British English.

https://en.wikipedia.org/wiki/Spelling_of_disc

So disk it'S going to be

This revision was automatically updated to reflect the committed changes.