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

Simplify and consolidate how a Worker is impacted by doing a Task/Activity #1285

Open
bevans2000 opened this issue Apr 13, 2024 · 2 comments
Assignees
Labels
design change A change to the code to improve performance or reusability improvement
Milestone

Comments

@bevans2000
Copy link
Member

Is your feature request related to a problem? Please describe.
The Task class and it's subclasses have numerous places where the Task impacts the properties of a Worker, e.g. skill improvement, fatgiue, stress.
This is complex and hard to understand and has very low encapsulation. Also sometimes there is double counting occurring and no consistency.
Also the new GroupActivity class needs a means of defining the benefits of a Person attending an activity (see #971)

Describe the goal(s) you have in mind
Capture the impact of doing "something" for a period of time as a single class. This would update all the relevant properties of a Worker as one action based on a set of properties.
This class will be stateless allowing it to be shared by multiple Tasks/activities or in future Missions as well.
It will also provide a singular means to defining impact.
This could be loaded from a configuration file as well.

Describe the solution you desire to see
Create a new stateless class called ExperienceImpact. This will have a method apply that Workers call for a time period to update their properties. This represents them experiencing this activity for a certain time duration.
The experience class will be created a a static for most Task/GroupActivity instances allowing it to be centralised and shared by all instances of that Task type.
Formula to assess the impact can be centralised based on a single set of parameters. There needs to be the ability to enhance the calculations based on any external factors the Work is experiencing such as teaching.
The Task fatigue, stress, skill & emotion modifications can be centralised into a single logic flow.

@bevans2000 bevans2000 self-assigned this Apr 13, 2024
@bevans2000 bevans2000 added this to the 3.8.0 milestone Apr 13, 2024
@bevans2000 bevans2000 added improvement design change A change to the code to improve performance or reusability labels Apr 13, 2024
bevans2000 added a commit that referenced this issue Apr 13, 2024
ExperienceImpact represents the impact on a Worker of experiencing an activity for a time period. The activity could
be anything but initially is focused on Task.
The benefit is to simplify the Task logic plus the new ExperienceImpact is stateless and can be shared.

Changes:
- Create ExperienceImpact class with an apply method for a Worker
- Apply method will modified Skills considering a NaturalAttribute rating, experience ratio & any external factors, e.g. teaching
- For Persons the apply will also modify stress rating
- For Person the fatigue will be reduced according to the effortRatio
- For Robots the power will be reduce according to the effortRatio.
- Removed existing effort logic
- The skills assigned can be weighted so some are more impprtant than others
- Fit the ExperienceImpact to the Task class. Use it within the addExperience method
- Remove the direct modificiation of stress during perform method as now handled by the impact class
- Task is a partial transition as the original approach of seperate stress and skills are still supported
- Convert the basic Tasks to use the new constructor of ExperienceImpact.
- Move the executeTask method into the base TaskManager out of the Person & Robot subclass. This is possible because effort is now centralised
- GroupActivity provides a shared ExperienceImpact that comes from the associated info class
- Add and update numerous UnitTests

Close #971 & #1285
bevans2000 added a commit that referenced this issue Apr 20, 2024
Impact of a WorkActivity is defined in the settlement.xml

Changes:
- settlement.xml change the definition of the GroupActivityInfo to define EventSchedule and ExperienceImpact
- EventSchedule is a new classes that defines a repeating future event in terms of a schedule
- UnitTest for EventSchedule
- GroupActivity replace local logic with first event logic of the Event Schedule
- ConfigHelper has new shared methods to parse EventSchedule and ExperienceImpact
- ExperienceImpact definition can be defined in terms of skill weights and stress and experience ratio
- Update UnitTest for use of EventSchedule
- SettlementConfigtest now checks that the GroupActivitySchedule has correct GroupActivitys
- Correct typo in settlement.xml

Part of #971 & #1285
bevans2000 added a commit that referenced this issue Apr 27, 2024
Changes:
- Move remaing Task concerning ScientificStudy to the new package
- Convert Tasks to ExperienceImpact
- Move associated MetaTask classes
- InviteStudyCollaborator sends invites one at a time instead of all at the same time
- Add a new Skill Organisation that represents how organised a person is
- InviteStudyCollaborator, RespondToStudyInvite uses the new Organisation skill
- Convert Scientific Tasks to ExperienceImpact
- Create UnitTests for each Scientific Task
- UnitTest use a Chain of Responsibility pattern to create the Study in the correct phase
- MarsSimContext is a new interface for UnitTests to provide context to create simualtion entities
- Mars sim unit test has method to execute a Task for a maximum duration of time
- LabTask provides a centralised determineStudy method
- Remove unused methods from ChainOfCommand class
- Change method in BuildingManager to use ScienceType instead of ScientificStudy
- AssistScientificStudyResearch task does not use computing resource as it provides assistance to main Task

Part of #1285 & #1286
@bevans2000 bevans2000 removed this from the 3.8.0 milestone May 2, 2024
bevans2000 added a commit that referenced this issue May 4, 2024
Changes:
- Create a new ComputingJob class that manages a Task using a Computation function
- ComputingJob calculates requirements at the constructor
- The consumeProcessing method is a varient of the duplicates in Task but centralised
- consumeProcessing method only schedules the task in the Computation Function once to avoid over allocating
- Computing need is reduce on each call as long as a compute task is scheduled
- Create new UnitTest to check ComputingJob
- Update any Task using Computation to use the new job class

Part of #1285
bevans2000 added a commit that referenced this issue May 4, 2024
Changes:
- Change the approach to create the function to Building map
- Drop maintaining the building type to id count. It can be calculated on demand when building a Building
- Move some single use methods from BuildingManager to the calling class
	- Move method getLivingAccommodationNeedingReview to BudgetResource class
	- Move method findStorageBuildings to DigLocal class
	- Move method displayComputingResources to the SettlementTableModel class
- Remove unused methods
- Convert BudgetResource class to ExperienceImpact
- Move BudgetResource & associated Meta to the settlements/task package

Part of #1285
@bevans2000
Copy link
Member Author

This needs to be further expanded so TaskPhase can define a specific ExperienceImpact that override the default one for the Task. This would allow different impacts fir different phases. For example, in the EVA Operation where the actual onsite working phase needs extra skills.

bevans2000 added a commit that referenced this issue May 6, 2024
Goal is to simplify the EVAOperation and define the mandatories in the constructor.

Changes:
- EVAOperation takes the on site Phase in the constructor instead of the abstract getOnSitePhase method
- EVAOperation uses ExperienceImpact for the Task impact on Workers. Default is based on standard EVA skill.
- TaskPhase supports an optional ExperienceImpact that overrides the Task impact when the phase is active
- Task getImpact method will use the impact of the currnt TaskPhase if one exists
- Drop addAdditionalSkill in Task as it is no longer used
- EVAOperation provides a createSkilImpact method that creates an impact for the in site phase. It uses the normal EVAOperation impact but adds in additional skills
- In Task drop recording the possible phases as it servers no purpose.
- Task setPhase does not check the phase against knowns
- ToggleFuelPowerSource is not EVA based anymore. Current logic would never get to EVA phases

Part of #1285
bevans2000 added a commit that referenced this issue May 12, 2024
Changes:
- Goal of BudgetResource task is defined as an enum.
- Constructor can define the review goal as optional argument
- Create BudgetResource UnitTest
	- Test for each of the 3 Review Goals
- ExperienceImpact now supports the overriding of the experience modifier
	- BudgetResource uses a special experience calculation
- Reduce too many BudgetResources Tasks
	- Review of essential resources is reset every 2 days based on ScheduledFutureEvent not every 50 msols
	- Reduce based score in metatask
	- Create seperate SettlemetnTasks for each Review Goal with the 'demand' used to capture how many needed instead of the score
- Correct problem in Task so teacher benefit is correctly passed to ExperienceImpact
- EVAOperationTest checks the isSunlightAboveLevel method

Part of #679, #1285
@bevans2000
Copy link
Member Author

As a follow on action the Task.getTeachingModifier should return between zero and a value. Currently it always returns at least 1 which is confusing; the new ExperienceImpact would be clearer if that method return the increase/boost due to teaching.
However the getTeachingModifier is used in other places outside of the base Task class in custom addExperience methods. These need replacing with the base version; then the behaviour of the teaching method can be changed.

@bevans2000 bevans2000 added this to the 3.8.0 milestone May 18, 2024
bevans2000 added a commit that referenced this issue May 18, 2024
Changes:
- Move operating Tasks
- Move MaintainGarageVehicle task
- Move LoadingControllet and LoadVehicleGarage tasks
- Update references to Tasks

Part of #1285
bevans2000 added a commit that referenced this issue May 19, 2024
Changes:
- Convert UnloadVehicleGarage Task to use the new UnloadHelper and ExperienceImpact classes
- UnloadHelper nw unloads Equipment as well
- Create UnloadVehicleGarage UnitTest
- Add single SkillType constructor to the ExperienceImpact to reflect the very common use case
- Convert MaintainVehicelGarage to ExperienceImpact and create UnitTest
- Add new buildPerson method to Abstract unit test helper that automatically places a Person in correct building

Part of #1285
bevans2000 added a commit that referenced this issue May 19, 2024
Changes:
- Remove VehicleMission dependency from LoadVehicleGarage Task
- Change constructor to use LoadingController instead of Mission
- Create LoadVehicleGarage UnitTest

Part of #1285
bevans2000 added a commit that referenced this issue May 19, 2024
Changes:
- Drop the need to create a Set of one SkillType by using simplified constructor
- Task remove unused methods

Part of #1285
bevans2000 added a commit that referenced this issue May 26, 2024
Changes:
- Convert PilotDrone & DriveGroundVehicle task to use a single constrcutor set based on Worker instead of Robot & Person
- OperateVehicle converted to use ExperienceImpact
- Remove addExperience method from PilotDrone & DriveGroundVehicle as ExperiemceImpact handles logic
- Avoid obstacle TaskPhases have a specialised Impact class to increase skill improvement due to extra difficulty
- Create DriveGroundVehicle & PilotDrone UnitTest
- Clean constructor of the DroneMission to remove duplicate code
- Correct typo in ExperiemceImpact class
- Remove unused setExperienceAttribute in Task

Part of #1285
bevans2000 added a commit that referenced this issue May 26, 2024
Changes:
- ExperienceImpact now has 2 constructors
	- One takes a varargs list of SkillType which becomes evently balanced
	- Second takes a Set of weighted SkillType
- Update UnitTest to stop passing empty Collection
- Update creators that use the weighted skills varient

Part of #1285
bevans2000 added a commit that referenced this issue May 27, 2024
Changes:
- Create subpackage 'task' under building and building/function
- Move appropriate Task & MetaTask to the new packages

Part of #1285
bevans2000 added a commit that referenced this issue May 27, 2024
Changes:
- Create 2 new Unit Tests
- Allow MockBuilding to excluded life support
- Simplify buildFunction method in AbstractMarsSimUnitTest; Building id auto generated
- MockBuilding has a maintenance period by default
- MalfunctionManager remove unused methods
- MalfunctionManager exposes the number of completed maintenance

Part of #1285
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design change A change to the code to improve performance or reusability improvement
Projects
None yet
Development

No branches or pull requests

1 participant