Simplify bee harvesting

This commit is contained in:
2026-05-05 09:43:17 +01:00
parent 1ec855c2fc
commit 62a9f34a26
+19 -22
View File
@@ -163,25 +163,12 @@ updateCalmBee cr cid w
, x < 0.5 , x < 0.5
, Just hcr <- gethive , Just hcr <- gethive
, distance (cr ^. crPos . _xy) (hcr ^. crPos . _xy) < 30 , distance (cr ^. crPos . _xy) (hcr ^. crPos . _xy) < 30
, Just ReturnToHive <- cr ^? crActionPlan . apStrategy , Just ReturnToHive <- cr ^? crActionPlan . apStrategy = startsearch
= w & tocr . crActionPlan . apStrategy .~ Search | Just ReturnToHive <- cr ^? crActionPlan . apStrategy = w
& tocr . crActionPlan . apAction .~ NoAction | Just x <- cr ^? crType . beeSlime
| Just hcr <- gethive , x >= 15 = starthivereturn
, Just _ <- cr ^? crStance . carriage . mountID
, Just x <- cr ^? crType . beeSlime
, x >= 15
= w & tocr . crActionPlan . apAction .~ PathTo (hcr ^. crPos . _xy) NoAction
& tocr . crStance . carriage .~ Flying 0
& tocr . crActionPlan . apStrategy .~ ReturnToHive
| Just mid <- cr ^? crStance . carriage . mountID | Just mid <- cr ^? crStance . carriage . mountID
, mountshakeoff mid = w , mountshakeoff mid = startsearch
& tocr . crStance . carriage .~ Flying 0
& tocr . crActionPlan . apStrategy .~ Search
| Just hcr <- gethive
, Just x <- cr ^? crType . beeSlime
, x >= 15
= w & tocr . crActionPlan . apAction .~ PathTo (hcr ^. crPos . _xy) NoAction
& tocr . crActionPlan . apStrategy .~ ReturnToHive
| Nothing <- cr ^? crActionPlan . apStrategy . harvestTarget | Nothing <- cr ^? crActionPlan . apStrategy . harvestTarget
, xs@(_:_) <- IM.elems . IM.filter istarget $ crsNearCirc cxy 100 w , xs@(_:_) <- IM.elems . IM.filter istarget $ crsNearCirc cxy 100 w
, (tcr,g') <- runState (takeOne xs) (w ^. randGen) = , (tcr,g') <- runState (takeOne xs) (w ^. randGen) =
@@ -200,15 +187,25 @@ updateCalmBee cr cid w
& tocr . crActionPlan . apAction .~ NoAction & tocr . crActionPlan . apAction .~ NoAction
| Just (tcr,_) <- gettarg = w | Just (tcr,_) <- gettarg = w
& tocr . crActionPlan . apAction .~ PathTo (tcr ^. crPos . _xy) NoAction & tocr . crActionPlan . apAction .~ PathTo (tcr ^. crPos . _xy) NoAction
| Just (SearchTimed 0) <- cr ^? crActionPlan . apStrategy | Just (SearchTimed 0) <- cr ^? crActionPlan . apStrategy = starthivereturn
= w & tocr . crActionPlan . apStrategy .~ ReturnToHive
| Just PathTo{} <- cr ^? crActionPlan . apAction = w | Just PathTo{} <- cr ^? crActionPlan . apAction = w
& tocr . crActionPlan . apStrategy . searchTimer %~ (max 0 . subtract 1) & tocr . crActionPlan . apStrategy . searchTimer %~ (max 0 . subtract 1)
| otherwise = w | otherwise = startsearch
where
starthivereturn = fromMaybe w $ do
hcr <- gethive
return $ w
& tocr . crActionPlan . apAction .~ PathTo (hcr ^. crPos . _xy) NoAction
& tocr . crActionPlan . apStrategy .~ ReturnToHive
& tocr . crStance . carriage %~ dounmount
dounmount x = case x of
Flying{} -> x
_ -> Flying 0
startsearch = w
& tocr . crActionPlan . apAction .~ PathTo (cxy + p) NoAction & tocr . crActionPlan . apAction .~ PathTo (cxy + p) NoAction
& tocr . crStance . carriage %~ dounmount
& randGen .~ g & randGen .~ g
& tocr . crActionPlan . apStrategy .~ SearchTimed 200 & tocr . crActionPlan . apStrategy .~ SearchTimed 200
where
(p,g) = runState (randOnCirc 200) (w ^. randGen) (p,g) = runState (randOnCirc 200) (w ^. randGen)
cxy = cr ^. crPos . _xy cxy = cr ^. crPos . _xy
mountshakeoff mid = fromMaybe True $ do mountshakeoff mid = fromMaybe True $ do