Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quarry 3.0 #288

Merged
merged 11 commits into from
Nov 13, 2022
Merged

Quarry 3.0 #288

merged 11 commits into from
Nov 13, 2022

Conversation

OgelGames
Copy link
Contributor

@OgelGames OgelGames commented Oct 31, 2022

Another feature and performance rewrite for the quarry.

Main changes:

  • Added configurable offsets (x/z) to the quarry's digging area.
  • The quarry now only digs below itself, to allow for the new offsets.
  • Quarries no longer have a rotation, and have been changed to match visually.
  • The quarry formspec is now updated on right-click, instead of on every run.
  • Less metadata usage.
  • Improved working area visualization (see below).

Doing some basic testing by timing the running of 20 quarries, I found an improvement of 45% when running, and 68% while idle. The majority of the saving is from not updating the formspec every run, but there are also less calculations done when running.

The new visualization uses particles spawners to show the edges of the working area:

Implements and closes #147 (ping to @dennisjenkins75)

@BuckarooBanzay
Copy link
Member

Nice! I like the use of particlespawners for the region (and might steal this idea on another project 😉)

I had my test-setup of 120+ quarries on the pandorabox test-server and decided to update the technic mod to this branch and see if/how it behaves.

Sadly every quarry i already placed was rotated with "face" down and had a param2 of 2 (not sure if that's relevant)

screenshot_20221031_131440

Oh, and somehow the front-texture was missing/blacked-out :/

@OgelGames
Copy link
Contributor Author

OgelGames commented Oct 31, 2022

@BuckarooBanzay that looks correct, quarries don't have a rotation anymore, so I changed the design to look like there is a hole on the bottom. (I forgot to mention that sorry).

Prehaps I should change it to a nodebox with an actual hole... 🤔

@dennisjenkins75
Copy link

Awesome. Will the old quarry behavior be supported as well (so that existing ship designed that assume the old behavior will continue to function)?

@S-S-X
Copy link
Member

S-S-X commented Oct 31, 2022

The quarry now only digs below itself, to allow for the new offsets.

Debatable but I'd like this to be configurable because it apparently prevents using forward (and a bit of upward too) digging quarry ships I've used a lot.

@OgelGames
Copy link
Contributor Author

Will the old quarry behavior be supported as well (so that existing ship designed that assume the old behavior will continue to function)?

Yes, existing quarries will be configured by an LBM to match their previous digging area, so they will continue to work the same. The only exception is changing the radius, as that doesn't behave the same way as before.

The quarry now only digs below itself, to allow for the new offsets.

Debatable but I'd like this to be configurable because it apparently prevents using forward (and a bit of upward too) digging quarry ships I've used a lot.

It's not possible to dig up anymore, otherwise the quarry would dig itself and whatever is around it.

@S-S-X
Copy link
Member

S-S-X commented Nov 1, 2022

The quarry now only digs below itself, to allow for the new offsets.

Debatable but I'd like this to be configurable because it apparently prevents using forward (and a bit of upward too) digging quarry ships I've used a lot.

It's not possible to dig up anymore, otherwise the quarry would dig itself and whatever is around it.

I can add functionality for that if needed, would be just complaining if selected offsets overlap quarry itself.

Another way which could bring both compatibility with old methods and new content could be introducing Quarry Mk2 where old quarry could simply use exact same code but with limited configuration and old tiles?

But I guess only if someone else would also see use for old functionality or introducing another tier with different functionality...

@OgelGames
Copy link
Contributor Author

Another way which could bring both compatibility with old methods and new content could be introducing Quarry Mk2 where old quarry could simply use exact same code but with limited configuration and old tiles?

I really want to avoid adding another version of the quarry, not only because the old version will be mostly obsolete, but also communicating about them will get confusing.

But I guess only if someone else would also see use for old functionality

So far only FeXoR and MCLV have commented on the new quarry (see #offtopic), and FeXoR doesn't mind:

[Libera] <FeXoR> Ah, right, just digging up won't be possible any more. A minor downside IMO ;)

Need to get some more players testing them.

@BuckarooBanzay
Copy link
Member

vletter

nice 👍

One thing though: could it be possible that a switching station begins to run in one place and trigger the technic_run of an not-yet converted (old) quarry somewhere else? (not anywhere near the player to trigger the migration lbm)
If so: what would happen then?

@OgelGames
Copy link
Contributor Author

OgelGames commented Nov 2, 2022

could it be possible that a switching station begins to run in one place and trigger the technic_run of an not-yet converted (old) quarry somewhere else?

I don't think so... if technic_run was called, then the node would have to be loaded, which means the LBM should have run... right? I thought LBMs run regardless of what triggers the loading of the node.

EDIT: I tested it and LBMs do require players to trigger them, but calling technic_run doesn't seem to cause any problems... Will do some more testing tomorrow.

@S-S-X
Copy link
Member

S-S-X commented Nov 2, 2022

I tested it and LBMs do require players to trigger them

LBM is named after Load but it is actually executed on Activate instead of block loading...

@OgelGames
Copy link
Contributor Author

LBM is named after Load but it is actually executed on Activate instead of block loading...

Yep... I should have just looked at the docs: https://github.com/minetest/minetest/blob/88820cd31c2fe21c8c16ee547a3335131e8ba009/doc/lua_api.txt#L7891-L7893

I added a simple check to prevent quarries digging before they've been updated, they wouldn't crash but they would start digging with the default offsets of zero.

@OgelGames
Copy link
Contributor Author

Did some more testing, specifically for the previous bug in #143, and it stops correctly at max_depth.

I did find a weird thing where the quarry instantly finds the first node to dig (it should take several cycles), so I'll have to figure that out before I merge this.

fix absolute positions, add max depth check, and load the area
@OgelGames
Copy link
Contributor Author

OgelGames commented Nov 12, 2022

Turns out the ground search was using absolute positions, so it was finding the ground on the first run, and instead the digging loop was finding the ground. (I guess it must be well optimized to do that within 3000μs 👀)

Also added a depth check to the ground search, and loading of the area.

@github-actions
Copy link

Click for detailed source code test coverage report

Test coverage report for Technic CNC 87.36% in 11/14 files:

File                             Hits Missed Coverage
-----------------------------------------------------
programs.lua                   263  0      100.00%
materials/technic_worldgen.lua 32   0      100.00%
materials/init.lua             14   0      100.00%
materials/default.lua          183  0      100.00%
materials/basic_materials.lua  17   0      100.00%
init.lua                       16   0      100.00%
digilines.lua                  55   0      100.00%
cnc.lua                        53   0      100.00%
formspec.lua                   104  7      93.69%
api.lua                        219  43     83.59%
pipeworks.lua                  25   13     65.79%
materials/moreblocks.lua       0    29     0.00%
materials/ethereal.lua         0    37     0.00%
materials/bakedclay.lua        0    13     0.00%

Test coverage report for technic chests 45.56% in 6/6 files:

File          Hits Missed Coverage
----------------------------------
chests.lua    102  18     85.00%
init.lua      34   18     65.38%
register.lua  84   78     51.85%
formspec.lua  76   93     44.97%
inventory.lua 10   100    9.09%
digilines.lua 2    61     3.17%

Test coverage report for technic 63.45% in 96/96 files:

File                                      Hits Missed Coverage
--------------------------------------------------------------
max_lag.lua                               12   0      100.00%
machines/register/init.lua                15   0      100.00%
machines/register/freezer_recipes.lua     13   0      100.00%
machines/other/init.lua                   8    0      100.00%
machines/MV/solar_array.lua               12   0      100.00%
machines/MV/init.lua                      17   0      100.00%
machines/MV/grinder.lua                   17   0      100.00%
machines/MV/generator.lua                 9    0      100.00%
machines/MV/freezer.lua                   17   0      100.00%
machines/MV/extractor.lua                 17   0      100.00%
machines/MV/electric_furnace.lua          17   0      100.00%
machines/MV/compressor.lua                17   0      100.00%
machines/MV/centrifuge.lua                17   0      100.00%
machines/MV/cables.lua                    40   0      100.00%
machines/MV/battery_box.lua               17   0      100.00%
machines/MV/alloy_furnace.lua             19   0      100.00%
machines/LV/solar_array.lua               11   0      100.00%
machines/LV/init.lua                      17   0      100.00%
machines/LV/grinder.lua                   16   0      100.00%
machines/LV/generator.lua                 9    0      100.00%
machines/LV/electric_furnace.lua          15   0      100.00%
machines/LV/compressor.lua                20   0      100.00%
machines/LV/cables.lua                    40   0      100.00%
machines/LV/battery_box.lua               15   0      100.00%
machines/LV/alloy_furnace.lua             17   0      100.00%
machines/HV/solar_array.lua               11   0      100.00%
machines/HV/init.lua                      12   0      100.00%
machines/HV/grinder.lua                   17   0      100.00%
machines/HV/generator.lua                 9    0      100.00%
machines/HV/electric_furnace.lua          17   0      100.00%
machines/HV/compressor.lua                17   0      100.00%
machines/HV/cables.lua                    39   0      100.00%
machines/HV/battery_box.lua               17   0      100.00%
legacy.lua                                33   0      100.00%
items.lua                                 107  0      100.00%
crafts.lua                                133  0      100.00%
machines/LV/led.lua                       73   1      98.65%
config.lua                                50   1      98.04%
machines/register/compressor_recipes.lua  36   1      97.30%
machines/LV/geothermal.lua                75   3      96.15%
machines/register/cables.lua              96   4      96.00%
machines/register/solar_array.lua         46   2      95.83%
machines/network.lua                      403  19     95.50%
machines/LV/solar_panel.lua               42   2      95.45%
machines/register/alloy_recipes.lua       40   3      93.02%
tools/init.lua                            13   1      92.86%
machines/LV/water_mill.lua                67   6      91.78%
init.lua                                  22   2      91.67%
machines/compat/tools.lua                 58   6      90.62%
machines/LV/lamp.lua                      111  13     89.52%
machines/register/grindings.lua           42   5      89.36%
register.lua                              28   4      87.50%
machines/register/grinder_recipes.lua     106  16     86.89%
machines/register/battery_box.lua         239  41     85.36%
tools/flashlight.lua                      64   13     83.12%
util/throttle.lua                         9    2      81.82%
machines/register/machine_base.lua        165  41     80.10%
machines/LV/extractor.lua                 18   5      78.26%
radiation.lua                             271  80     77.21%
machines/power_monitor.lua                59   19     75.64%
machines/register/recipes.lua             62   20     75.61%
machines/register/centrifuge_recipes.lua  21   7      75.00%
machines/switching_station.lua            80   32     71.43%
effects.lua                               5    2      71.43%
machines/overload.lua                     12   5      70.59%
machines/MV/wind_mill.lua                 46   22     67.65%
machines/supply_converter.lua             95   46     67.38%
machines/other/coal_furnace.lua           2    1      66.67%
machines/switching_station_globalstep.lua 31   16     65.96%
machines/other/injector.lua               72   39     64.86%
tools/multimeter.lua                      130  78     62.50%
machines/MV/hydro_turbine.lua             43   26     62.32%
machines/MV/tool_workshop.lua             56   34     62.22%
machines/other/coal_alloy_furnace.lua     80   49     62.02%
machines/register/generator.lua           122  88     58.10%
machines/register/common.lua              63   51     55.26%
tools/cans.lua                            53   48     52.48%
machines/init.lua                         56   54     50.91%
tools/mining_lasers.lua                   36   35     50.70%
machines/LV/music_player.lua              46   46     50.00%
machines/other/constructor.lua            67   69     49.26%
tools/tree_tap.lua                        24   27     47.06%
tools/vacuum.lua                          16   20     44.44%
machines/HV/forcefield.lua                103  155    39.92%
machines/HV/quarry.lua                    131  209    38.53%
machines/HV/nuclear_reactor.lua           119  205    36.73%
helpers.lua                               54   99     35.29%
tools/sonic_screwdriver.lua               16   33     32.65%
machines/compat/api.lua                   16   34     32.00%
tools/chainsaw.lua                        37   80     31.62%
machines/other/frames.lua                 184  445    29.25%
tools/mining_drill.lua                    65   195    25.00%
machines/other/anchor.lua                 14   74     15.91%
tools/prospector.lua                      14   99     12.39%
machines/compat/digtron.lua               4    41     8.89%
machines/register/extractor_recipes.lua   6    77     7.23%

Raw test runner output for geeks:

CNC:

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
31 successes / 0 failures / 0 errors / 0 pending : 0.489475 seconds

Chests:

W:	Configuration: invalid key	exclude_textures
●●●●●
5 successes / 0 failures / 0 errors / 0 pending : 0.033881 seconds

Technic:

●◌◌●●●◌●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●◌●●●●●W:	Deprecated technic.register_power_tool use. Setting max_charge for oldlegacy:powertool
W:	Deprecated technic.register_power_tool use. Setting max_charge for oldminimal:powertool
W:	Deprecated technic.register_power_tool use. Setting max_charge for oldhalfway:powertool
W:	Deprecated technic.register_power_tool use. Ensuring fields for oldlegacy:powertool
W:	Using metadata charge values for oldlegacy:powertool
W:	Updated legacy Technic power tool definition for oldlegacy:powertool
W:	Deprecated technic.register_power_tool use. Ensuring fields for oldminimal:powertool
W:	Using metadata charge values for oldminimal:powertool
W:	Updated legacy Technic power tool definition for oldminimal:powertool
W:	Deprecated technic.register_power_tool use. Ensuring fields for oldhalfway:powertool
W:	Mod oldhalfway seems to be aware of technic.plus but oldhalfway:powertool is still using deprecated registration, skipping meta charge compatibility.
W:	Updated legacy Technic power tool definition for oldhalfway:powertool
●●●●W:	Use of deprecated function technic.set_RE_wear with stack: oldlegacy:powertool
●W:	Use of deprecated function technic.set_RE_wear with stack: oldlegacy:powertool
●●●●●●●W:	Use of deprecated function technic.set_RE_wear with stack: oldminimal:powertool
●W:	Use of deprecated function technic.set_RE_wear with stack: oldminimal:powertool
●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
222 successes / 0 failures / 0 errors / 4 pending : 10.102244 seconds

Pending → spec/api_spec.lua @ 133
Technic API Machine registration registers my_mod:my_battery
spec/api_spec.lua:133: Battery box registration does not include all fields

Pending → spec/api_spec.lua @ 190
Technic API Machine registration registers my_mod:machine_base
spec/api_spec.lua:190: Base machine registration does not include all fields

Pending → spec/api_spec.lua @ 285
Technic API internals technic.cables TBD, misleading name and should be updated
spec/api_spec.lua:285: TBD technic.cables naming and need, see technic networks data for possible options

Pending → spec/supply_converter_spec.lua @ 78
Supply converter building overloads network
spec/supply_converter_spec.lua:78: overload does not work with supply converter

@OgelGames
Copy link
Contributor Author

I think this is ready to merge now, it's at least safe enough for live testing 💥

@OgelGames OgelGames merged commit d58afd8 into master Nov 13, 2022
@OgelGames OgelGames deleted the quarry-3.0 branch November 13, 2022 03:01
@Athozus Athozus added this to the 2.0.0 milestone Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for alternate HV Quarry dig pattern
5 participants