-
-
Notifications
You must be signed in to change notification settings - Fork 385
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
Improve tradeships #4984
Improve tradeships #4984
Conversation
Just a heads up: adding sources below src/ automatically adds them to the build, which I'm guessing you didn't intend for src/ship/PPTester since it has a |
@The-EG Thanks! To be honest, I have not yet figured out what to do with |
@Gliese852 Perhaps it's something we can add to the Ctrl-i menu? (I don't know what it does, but I like in-game debug tools!) |
@impaktor I just can't think of how it can be useful in debugging. Rather, it can be useful for navigation in space. With minor modifications it will be possible to calculate the time of arrival at the station, for example. |
be227fa
to
f67523a
Compare
Yay! The two new Github Actions ran (gcc & clang). |
@impaktor it's strange that the checks passed, locally I get a linking error, because there are two |
Odd that the checks aren't at least warning about the duplicate main symbols, but it's definitely there. |
90f15ea
to
6bab35d
Compare
I decided to replace a separate test file
|
now it's even playable |
dd73b6c
to
0539fd2
Compare
@Gliese852 given that the TradeShips.lua file is now well over 1800 lines of Lua code (even with debug code), I would highly recommend that you create a folder for it in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few things stood out to me; I'll wait to review the Lua until it's a little bit more manageable (and I have more time).
@Web-eWorks divided |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slowly but surely making my way through this review. Here's a batch of change requests; I'll dig into the meat of the PR further tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yet more changes - I'm sure some of these are pointing at code you didn't write, but it's a good time to do some cleanup of the module anyways.
d40efe8
to
f32efbe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yet another batch of changes; only three files are left to review but I'm out of time to review those right now.
@Web-eWorks probably I will put the changes that I make in separate commits, and then I will squash them all where necessary |
88d7c05
to
c87c21e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't had a chance to playtest this (or anything else) for a while now, but the code is good to go! Thank you @Gliese852 for working so hard to make the code easy to maintain and understand for contributors (and for putting up with my pedantic style suggestions 😄) - this PR is quite a big one, but you've done an excellent job with it.
@Web-eWorks Thank you very much for taking so much of your time to review! I played for a few hours, mostly courier missions, everything seems to work stably. |
A one-dimensional case is considered, given the parameters of the ship and the length of the path, a flight plan is calculated, which allows determining the time, speed, and mass of the ship at any point on the way. Also added a simple simulator for testing purposes.
Function description: The ship rearranged from its current position to a given body in space, for a given part of the path, as if it were flying in a straight line, consuming fuel and changing speed. The ship's current speed is ignored and is considered to be equal to target's. This function changes the coordinates, the mass of fuel in the tank, and the speed of the given ship. This function will be used so that when the game starts, or the player jump into the system, the NPC ships looked as if they had been moving on their routes for a long time.
- Preparations: Add method Ship:GetCargo Add method Ship:GetDurationForDistance Add method Ship:Create Add method ui.treeNode & ui.treePop Add method LuaObject::CreateInLua Add functions for convenient selection of a random array element Add some numerical utilites Add a tool to easily draw a table from an array Fix ui.Format.Number Turn off the output when the ship changes frames Reduce the detection range of hyperspace clouds Remove the call LuaEvent::Emit immediately after exiting hyperspace Split Tradeships.lua into 5 modules - Tradeships For current system, calculate all possible routes of tradeships, durations, flows; arrange ships in space in such equilibrium state, as if the have been flying about their business for a long time. Calculate the average spawn interval for new ships, and parking intervals, so that the stations are not overcrowded or empty. Сreate a tab in the debug window with full information on routes, ships, stations, remote systems.
- Move the drawing of the system map pigui to a separate handler to ensure that it will always be drawn strictly after the SystemView object - Fix the setting of the m_colliding parameter of the ship during deserialization
Squashed all tempourary commits |
Don't worry about the VS failure, I'll fix that up once it's merged. |
What's RelWithDebInfo? OK, so just drop default number of ships and this will be ready for merge? |
Release with Debug Info - it's a default Cmake build target that compiles with optimizations and debug symbols (what we ship in releases). Yes, just drop the default number of ships until such a time as we're able to optimize some of the remaining bottlenecks in the code, and this PR is ready to merge. |
- reduce the flow to the most popular station in system by 40%. - reduce the maximum station load by 25% - reduce the maximum ships limit by 40% This is to improve the performance. although these parameters are independent, it is better to change them synchronously. For example, if you just reduce the allowable number of ships, in all systems this number can become the same. If the load on the station is not reduced, the ships will stay there for too long.
@Web-eWorks I'll probably make this change in a separate commit to clarify how the flow is set up. |
Merged! Thank you for all of the work on this @Gliese852! |
tradesh_git.mp4
TODO
create a pre-calculation of the ship's path according to the specified parameters
create a function that spawns ships "on the way" with checking for possible collisions at the insertion point
improve the method of creating merchant ships, using these functions
(TradeShips.lua)
Commits
Add class for pre-calculating spaceship path
A one-dimensional case is considered, given the parameters of the ship
and the length of the path, a flight plan is calculated, which allows
determining the time, speed, and mass of the ship at any point on the
way. Also added a simple simulator for testing purposes.
Add function PutShipOnRoute
Function description:
The ship rearranged from its current position to a given body in space, for a given part of the path, as if it were flying in a straight line, consuming fuel and changing speed. The ship's current speed is ignored and is considered to be equal to target's.
This function changes the coordinates, the mass of fuel in the tank, and the speed of the given ship.
This function will be used so that when the game starts, or the player jump into the system, the NPC ships looked as if they had been moving on their routes for a long time.
Improve Tradeships.lua
Preparations:
Ship:GetCargo
Ship:GetDurationForDistance
Ship:Create
ui.treeNode & ui.treePop
LuaObject::CreateInLua
ui.Format.Number
LuaEvent::Emit
immediately after exiting hyperspaceTradeships.lua
into 5 modulesTradeships.lua
For current system, calculate all possible routes of tradeships, durations, flows; arrange ships in space in such equilibrium state, as if the have been flying about their business for a long time.
Calculate the average spawn interval for new ships, and parking intervals, so that the stations are not overcrowded or empty.
Сreate a tab in the debug window with full information on routes, ships, stations, remote systems.
Fix some bugs appeared
SystemView
object.m_colliding
parameter of the ship during deserialization.Reduce the flow of tradeships
This is to improve the performance. although these parameters are independent, it is better to change them synchronously. For example, if you just reduce the allowable number of ships, in all systems this number can become the same. If the load on the station is not reduced, the ships will stay there for too long.
Details on the forum: https://pioneerspacesim.net/forum/viewtopic.php?f=3&t=650