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

Null Shipment when negotiating trade in CommerceUtil #1118

Open
mokun opened this issue Nov 2, 2023 · 8 comments
Open

Null Shipment when negotiating trade in CommerceUtil #1118

mokun opened this issue Nov 2, 2023 · 8 comments
Assignees
Labels
Milestone

Comments

@mokun
Copy link
Member

mokun commented Nov 2, 2023

Describe the bug

  • On Sol 6, When reloading from a saved sim, it stated that returnLoad was NPE when calling CommerceUtil's negotiateDeal() between the two settlements, namely, Dream City and Heritage.

Expected and unexpected behavior

  • It happens after the trade negotiation has been completed.

Discuss any potential problems you have and have not ruled out

  • Does this NPE have to do with the situation when reloading from saved sim ?

Java classes involved

  • CommerceUtil, NegotiateTrade

Screenshots

  • Both rovers drove 964 km from Heritage to Dream City.

  • Event though they both departed on sol 5 and arrived on sol 6, their start time and arrival time were different.
    image

  • Realistically speaking, the path between the two settlements shouldn't be a straight shot but a curve on a sphere.
    image

  • None of the 6 settlers in Dream City are aware of the arrival of the 2 trading missions.

  • They all stay indoors and are NOT helping to unload cargoes
    image

  • The 2 sleepy head settlers on Rover Ridge Runner from Heritage are still in the vehicle.

  • The 2 sleepy head settlers on Rover Solitude from Heritage are still in the vehicle.

  • These 2 rovers are not being displayed on the Settlement Map of Dream City, since Settlement's getParkedVehicles() includes only vehicles from the ownedVehicles set.
    image

  • Can't find the 2 rovers from Heritage :
    image

  • Nothing has been unloaded yet :
    image

  • Both settlers are healthy and have little fatigue. Why are they sleeping and not unloading cargo ?
    image

  • Why are the sleeping probability score 1000 for both of them ?

  • Why are the base score so high (at 6000) ?
    image

  • It's totally wrong to say that these 4 individuals are still on EVA Airlock 1 or Residential Quarters 1 in Heritage.

  • We should add back the Settlement column to ascertain what base the settlers are in.

  • Other than the trading mission., we should leave provision for them go to other settlement in other future missions such as Diplomatic Exchange missions, etc.
    image

Stacktrace

01-Adir-06:720.499 (Info) NegotiateTrade : [Dream City] Louis Dubois - Trade negotiation completed. Buyer: Heritage. Seller: Dream City. Trade Mod: 1.3
01-Adir-06:720.499 (Info) CreditManager : [Heritage] Account ledger updated for Dream City  Credit: 10718.9
01-Adir-06:720.499 (Severe) PersonTaskManager : [Dream City] Louis Dubois - Trouble calling performTask(): 
java.lang.NullPointerException: Cannot invoke "com.mars_sim.core.goods.Shipment.getCostValue()" because "returnLoad" is null
	at com.mars_sim.core.goods.CommerceUtil.negotiateDeal(CommerceUtil.java:528)
	at com.mars_sim.core.person.ai.task.NegotiateTrade.negotiatingPhase(NegotiateTrade.java:112)
	at com.mars_sim.core.person.ai.task.NegotiateTrade.performMappedPhase(NegotiateTrade.java:218)
	at com.mars_sim.core.person.ai.task.util.Task.executeMappedPhase(Task.java:687)
	at com.mars_sim.core.person.ai.task.util.Task.performTask(Task.java:648)
	at com.mars_sim.core.person.ai.task.util.PersonTaskManager.executeTask(PersonTaskManager.java:101)
	at com.mars_sim.core.person.ai.Mind.takeAction(Mind.java:203)
	at com.mars_sim.core.person.ai.Mind.decideTask(Mind.java:175)
	at com.mars_sim.core.person.ai.Mind.timePassing(Mind.java:118)
	at com.mars_sim.core.person.Person.timePassing(Person.java:850)
	at com.mars_sim.core.structure.Settlement.timePassingCitizens(Settlement.java:1173)
	at com.mars_sim.core.structure.Settlement.timePassing(Settlement.java:904)
	at com.mars_sim.core.UnitManager$SettlementTask.call(UnitManager.java:900)
	at com.mars_sim.core.UnitManager$SettlementTask.call(UnitManager.java:1)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

01-Adir-06:720.499 (Info) NegotiateTrade : [Dream City] Louis Dubois - Trade negotiation completed. Buyer: Heritage. Seller: Dream City. Trade Mod: 1.3
01-Adir-06:720.499 (Info) CreditManager : [Heritage] Account ledger updated for Dream City  Credit: 21437.8
01-Adir-06:722.484 (Info) Sleep : [Starcity] Kathleen Torres - Sleep adjusted for shift starts at 730. Duration: 7
01-Adir-06:722.484 (Info) CookMeal : [New Pompeii] Kabir Narayan - Finished cooking Veggie Burger.
01-Adir-06:722.484 (Info) NegotiateTrade : [Dream City] Louis Dubois - Trade negotiation completed. Buyer: Heritage. Seller: Dream City. Trade Mod: 1.3
01-Adir-06:722.484 (Info) CreditManager : [Heritage] Account ledger updated for Dream City  Credit: 32156.7
01-Adir-06:722.484 (Info) NegotiateTrade : [Dream City] Louis Dubois - Trade negotiation completed. Buyer: Heritage. Seller: Dream City. Trade Mod: 1.3
01-Adir-06:722.484 (Info) CreditManager : [Heritage] Account ledger updated for Dream City  Credit: 42875.6
01-Adir-06:722.484 (Info) NegotiateTrade : [Dream City] Louis Dubois - Trade negotiation completed. Buyer: Heritage. Seller: Dream City. Trade Mod: 1.3
01-Adir-06:722.484 (Info) CreditManager : [Heritage] Account ledger updated for Dream City  Credit: 53594.5
01-Adir-06:724.368 (Info) Crop : [Schiaparelli Point - Inflatable Greenhouse 3] Celery - Now in PLANTING.
01-Adir-06:724.368 (Info) ReviewMissionPlan : [Zvezda] Timofei Afanasyev - Grading Delivery #234 Plan - Rels: 9, Site: 0.0, Review: 2; Subtotal: 11.0
01-Adir-06:724.368 (Info) ReviewMissionPlan : [Zvezda] Timofei Afanasyev - Done reviewing Fyodor Egorov's Delivery #234 mission plan.
01-Adir-06:724.368 (Info) OperateVehicle [x24] : [17.3924 N 23.2615 W] Solitude - Case III: Proceeding to Dream City. dist2Dest: 546.955 km  distanceToCover: 3.967 km  uKPH: 62.661 kph  vKPHProposed: 62.661 kph  hrsTime: 0.018 hrs  Time: 63.307 secs  maxAccel: 1.86 m/s2  skillMod: 1.0  lightMod: 3.84  terrainMod: 1.0  idealSpeedMS: 48.354 m/s  topSpeedKPH: 46.276 kph  idealSpeedKPH: 174.075 kph  nextSpeedKPH: 46.276 kph  
01-Adir-06:724.368 (Info) Converse : [Schiaparelli Point] Lena LaGranda - Chatting with Ronald Collins in Same Settlement.
01-Adir-06:724.368 (Info) AbstractMission [x2] : [5.7524 N 163.8884 E - Shi-Ki] Shota Okamoto - Assigned with 'Collecting Resources' to replace 'Analyzing Map Data'.
01-Adir-06:724.368 (Info) AbstractMission : [39.9261 N 100.0534 W - Chongjin] Sua Pak - Assigned with 'Collecting Resources' to replace 'Eating'.
01-Adir-06:724.368 (Info) Converse : [Schiaparelli Point] Ronald Collins - Responding to Lena LaGranda.
01-Adir-06:724.368 (Info) EVAOperation : [5.7524 N 163.8884 E] Kaito Inoue - EVA Collecting Resources aborted: Samples collected exceeded set limits.
01-Adir-06:724.368 (Info) EVAOperation : [0.2540 S 0.2052 E] Deborah Cook - EVA Collecting Resources aborted: No container available.
01-Adir-06:724.368 (Info) AbstractMission [x10] : [Catarina] Francisco Alves - Assigned with 'Loading Vehicle by EVA' to replace 'Reading'.
01-Adir-06:724.368 (Info) NegotiateTrade : [Dream City] Louis Dubois - Trade negotiation completed. Buyer: Heritage. Seller: Dream City. Trade Mod: 1.3
01-Adir-06:724.368 (Info) CreditManager : [Heritage] Account ledger updated for Dream City  Credit: 64313.5
01-Adir-06:724.368 (Info) NegotiateTrade : [Dream City] Louis Dubois - Trade negotiation completed. Buyer: Heritage. Seller: Dream City. Trade Mod: 1.3
01-Adir-06:724.368 (Info) CreditManager : [Heritage] Account ledger updated for Dream City  Credit: 75032.4
01-Adir-06:724.368 (Info) ReviewMissionPlan : [New Pompeii] Rithvik Raje - Grading Meteorology Field Study #238 Plan - Rels: 9, Site: 0.0, Review: 2; Subtotal: 11.0
01-Adir-06:724.368 (Info) NegotiateTrade : [Dream City] Louis Dubois - Trade negotiation completed. Buyer: Heritage. Seller: Dream City. Trade Mod: 1.3
01-Adir-06:724.368 (Info) ReviewMissionPlan : [New Pompeii] Rithvik Raje - Done reviewing Rithvik Chauhan's Meteorology Field Study #238 mission plan.
01-Adir-06:724.368 (Info) CreditManager : [Heritage] Account ledger updated for Dream City  Credit: 85751.3
01-Adir-06:724.368 (Info) AbstractMission : [Dream City] Oscar Thompson - Responsible for 'Trade Negotiating' Mission Phase.
01-Adir-06:726.149 (Info) ExitAirlock : [39.9261 N 100.0534 W - Chongjin] Sua Pak - Airlock is not in egress mode. Current task: Collecting Resources.
01-Adir-06:726.149 (Info) NegotiateTrade : [Dream City] Louis Dubois - Trade negotiation completed. Buyer: Heritage. Seller: Dream City. Trade Mod: 1.3
01-Adir-06:726.149 (Info) CreditManager : [Heritage] Account ledger updated for Dream City  Credit: 96470.3
01-Adir-06:726.149 (Info) NegotiateTrade : [Dream City] Louis Dubois - Trade negotiation completed. Buyer: Heritage. Seller: Dream City. Trade Mod: 1.3
01-Adir-06:726.149 (Info) CreditManager : [Heritage] Account ledger updated for Dream City  Credit: 107189.3
01-Adir-06:726.149 (Info) NegotiateTrade : [Dream City] Louis Dubois - Trade negotiation completed. Buyer: Heritage. Seller: Dream City. Trade Mod: 1.3
01-Adir-06:726.149 (Info) CreditManager : [Heritage] Account ledger updated for Dream City  Credit: 117908.3
01-Adir-06:726.149 (Info) TendGreenhouse : [Schiaparelli Point - Inflatable Greenhouse 2] Keith Ramirez - Looking into growing tissue cultures.
01-Adir-06:726.149 (Info) Farming : [Schiaparelli Point] Inflatable Greenhouse 2 - selectedTissueName: Cilantro Tissue
01-Adir-06:726.149 (Info) TendGreenhouse : [Schiaparelli Point - Inflatable Greenhouse 2] Keith Ramirez - Sampled Cilantro Tissue and added to incubator for growing tissues.
01-Adir-06:726.149 (Info) Crop : [Schiaparelli Point - Large Greenhouse 1] Spring Onion - Harvested a total of 109.79 kg.
01-Adir-06:726.149 (Info) Crop : [Schiaparelli Point - Large Greenhouse 1] Spring Onion - Closed out the final harvest.
01-Adir-06:727.842 (Info) ExitAirlock : [5.7524 N 163.8884 E - Shi-Ki] Shota Okamoto - Tried to step through inner door. Not fit enough.
01-Adir-06:727.842 (Info) NegotiateTrade : [Dream City] Louis Dubois - Trade negotiation completed. Buyer: Heritage. Seller: Dream City. Trade Mod: 1.3
01-Adir-06:727.842 (Info) CreditManager : [Heritage] Account ledger updated for Dream City  Credit: 128626.1
01-Adir-06:727.842 (Info) NegotiateTrade : [Dream City] Louis Dubois - Trade negotiation completed. Buyer: Heritage. Seller: Dream City. Trade Mod: 1.3
01-Adir-06:727.842 (Info) Converse : [Hong Tian] Tu Guo - Chatting with Enlai Pan in Same Settlement.
01-Adir-06:727.842 (Info) CreditManager : [Heritage] Account ledger updated for Dream City  Credit: 139344.0
01-Adir-06:727.842 (Info) EVAOperation : [19.8000 N 50.9999 W] Jin Mao - EVA Collect Minerals aborted: No more minerals to mine.
01-Adir-06:729.492 (Info) TendGreenhouse : [Kyocera - Inflatable Greenhouse 1] Hinata Hasegawa - Inspecting contamination control.
01-Adir-06:729.492 (Info) NegotiateTrade : [Dream City] Louis Dubois - Trade negotiation completed. Buyer: Heritage. Seller: Dream City. Trade Mod: 1.3
01-Adir-06:729.492 (Info) CreditManager : [Heritage] Account ledger updated for Dream City  Credit: 150061.8
01-Adir-06:729.492 (Severe) PersonTaskManager [x13] : [Dream City] Louis Dubois - Trouble calling performTask(): 
java.lang.NullPointerException: Cannot invoke "com.mars_sim.core.goods.Shipment.getCostValue()" because "returnLoad" is null
	at com.mars_sim.core.goods.CommerceUtil.negotiateDeal(CommerceUtil.java:528)
	at com.mars_sim.core.person.ai.task.NegotiateTrade.negotiatingPhase(NegotiateTrade.java:112)
	at com.mars_sim.core.person.ai.task.NegotiateTrade.performMappedPhase(NegotiateTrade.java:218)
	at com.mars_sim.core.person.ai.task.util.Task.executeMappedPhase(Task.java:687)
	at com.mars_sim.core.person.ai.task.util.Task.performTask(Task.java:648)
	at com.mars_sim.core.person.ai.task.util.PersonTaskManager.executeTask(PersonTaskManager.java:101)
	at com.mars_sim.core.person.ai.Mind.takeAction(Mind.java:203)
	at com.mars_sim.core.person.ai.Mind.decideTask(Mind.java:175)
	at com.mars_sim.core.person.ai.Mind.timePassing(Mind.java:118)
	at com.mars_sim.core.person.Person.timePassing(Person.java:850)
	at com.mars_sim.core.structure.Settlement.timePassingCitizens(Settlement.java:1173)
	at com.mars_sim.core.structure.Settlement.timePassing(Settlement.java:904)
	at com.mars_sim.core.UnitManager$SettlementTask.call(UnitManager.java:900)
	at com.mars_sim.core.UnitManager$SettlementTask.call(UnitManager.java:1)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

Specifications

  • pre 3.7.0 build 8854

Additional context

  • Blue Origin's Dream City has 8 settlers by default.
		<settlement name="Dream City" template="Phase 2-US" persons="8" robots="4" sponsor="BO">
			<location longitude="29.75 W" latitude="10.63 N" />
		</settlement>
@mokun mokun added the bug label Nov 2, 2023
@mokun
Copy link
Member Author

mokun commented Nov 2, 2023

@bevans2000
I just added a few more screenshots above to cover all the issues I've encountered.

EDIT :
A few more new screenshots I'd like to document below :

  • Both Lars and Lili are shown to be at the Dream City.

  • They are ingressing EVA Airlock 1
    image

  • However, they should be exempt from 'digging local regolith' in the trading settlement and stay focus on unloading the sell goods.
    image

  • As a matter of fact, they have got off the Rover solitude already.
    image

  • Looking into their schedules, they are only recently being very busy at digging local regolith/ice. They are also doing other tasks.

  • Somehow, the Mission column is empty when they are still supposed to be on the Trading mission 213.
    image

Q: Why aren't they doing the tasks are they supposed to be doing ?

01-Adir-07:603.025 (Info) EVAOperation : [10.6300 N 29.7500 W] Lars Christensen - EVA Digging Local Regolith aborted: Shift ended
...
01-Adir-07:761.960 (Info) AbstractMission [x65] : [Dream City] Lars Christensen - Responsible for 'Unload Goods' Mission Phase.
...
01-Adir-07:854.830 (Info) EVAOperation : [10.6300 N 29.7500 W] Lars Christensen - EVA Digging Local Regolith aborted: Shift ended
...
01-Adir-08:133.088 (Warning) WalkingSteps : [Dream City] Lars Christensen - No walkable airlock from airlock exterior to building interior in Lander Hab 1
01-Adir-08:133.088 (Info) Task : [Dream City] Lars Christensen - Unable to walk to Residential Quarters 2.
...
01-Adir-08:222.541 (Info) AssistScientificStudyResearcher : [Dream City] Lars Christensen - Assisting Researcher - 0.0 CUs Used.
...
01-Adir-08:341.206 (Warning) WalkingSteps : [Dream City] Lars Christensen - No walkable airlock from airlock exterior to building interior in Lander Hab 1
01-Adir-08:341.206 (Info) Task : [Dream City] Lars Christensen - Unable to walk to Residential Quarters 2.
...
01-Adir-08:672.457 (Info) EVAOperation : [10.6300 N 29.7500 W] Lars Christensen - EVA Digging Local Ice aborted: Shift ended
...

01-Adir-08:869.057 (Info) AbstractMission [x60] : [Dream City] Lars Christensen - Responsible for 'Unload Goods' Mission Phase.
...
01-Adir-08:942.262 (Info) ExitAirlock [x6] : [Dream City - EVA Airlock 1] Lars Christensen - Airlock is not in egress mode. Current task: Digging Local Regolith.
...
01-Adir-09:038.665 (Info) AbstractMission [x49] : [Dream City] Lars Christensen - Responsible for 'Unload Goods' Mission Phase.
...

01-Adir-09:260.608 (Warning) WalkingSteps : [Dream City] Lars Christensen - No walkable airlock from airlock exterior to building interior in Lander Hab 1
01-Adir-09:260.608 (Info) Task : [Dream City] Lars Christensen - Unable to walk to Residential Quarters 2.
...
01-Adir-09:281.660 (Info) Converse : [Dream City] Lars Christensen - Chatting with Scott Davis in Same Settlement.
...
01-Adir-09:340.463 (Info) Sleep : [Dream City] Lars Christensen - Sleep adjusted for shift starts at 382. Duration: 42
...

01-Adir-09:463.690 (Info) ExitAirlock : [Dream City - EVA Airlock 1] Lars Christensen - Can't egress. Other occupant(s) already pre-breathed a quarter of time. Current task: Digging Local Regolith.

...
01-Adir-09:570.231 (Info) EVAOperation : [10.6300 N 29.7500 W] Lili Farkas - EVA Digging Local Regolith aborted: Shift ended
01-Adir-09:571.662 (Info) EVAOperation : [10.6300 N 29.7500 W] Lars Christensen - EVA Digging Local Regolith aborted: Shift ended

@mokun
Copy link
Member Author

mokun commented Nov 3, 2023

Finally, I've fixed the Settlement Map Tool to display trader Lars and others from another settlement. The two trading rovers from another settlement can now be seen :

image

mokun added a commit that referenced this issue Nov 3, 2023
11.02.2023

- fix: rework drawVehicles() in VehicleMapLayer to display all
          vehicles (including trading vehicles) in a settlement
		  coordinate
- fix: rework drawPeople() in PersonMapLayer to display all
          people (including trading guests) in a settlement
		  coordinate
- change: revise isVehicleLoading() in VehicleMapLayer
- fix: correct drawPersonLabels() and drawVehicleLabels()
       in LabelMapLayer
- change: rename and relocate getAssociatedRobotsInSettlementVicinity)
          to CollectionUtils
- change: revise selectVehicleAt() and selectVehicleAsObstacle() in
          SettlemenMapPanel to use CollectionUtils's
		  getVehiclesInSettlementVicinity()

Address #1118

Reverse some code change done in #1057
@bevans2000
Copy link
Member

Nice one

@mokun mokun added this to the 3.8.0 milestone Nov 14, 2023
@mokun
Copy link
Member Author

mokun commented Dec 7, 2023

@bevans2000

Can we create a test scenario in which two settlements are very close to each other and auto-launch a trading mission to see what else is still not well considered once the foreign settlers arrive at a destination settlement ?

The guest beds will need to be ready for them to rest. They should be on the road after recuperating.

What else are they allowed to do there ?

@mokun
Copy link
Member Author

mokun commented Jan 9, 2024

@bevans2000

Q1: Can we at least test to see if the Sleep task works now in foreign settlement ?

Q2: What does it take to prevent them from performing other non-essential tasks (such as digging regolith) in a foreign settlement ?

@bevans2000
Copy link
Member

I want to solve the problem of executing Tasks in a Unit test. Sleep would be a good one lets use this issue to create that.

Stopping the complex Tasks when away should work already. Settlement tasks can be filtered to only Workers in their home Settlement.

@bevans2000 bevans2000 self-assigned this Jan 9, 2024
@mokun
Copy link
Member Author

mokun commented Jan 9, 2024

Stopping the complex Tasks when away should work already. Settlement tasks can be filtered to only Workers in their home Settlement.

That's great !

But what tasks can still be performed in foreign settlement ?

Can we instead have an UI for players or commanders to choose what tasks are allowed or disallowed ?

@mokun
Copy link
Member Author

mokun commented Apr 7, 2024

But what tasks can still be performed in foreign settlement ?

Let's pay attention to what tasks will be allowed to performed in a foreign settlement.

What "rules" should they follow ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants