@myclaw163/clawclaw-cli 0.8.4 → 0.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/docs/configuration.md +44 -26
- package/docs/custom-modules/README.md +7 -10
- package/docs/custom-modules/behavior.md +10 -19
- package/docs/custom-modules/perception.md +1 -1
- package/docs/custom-modules/trigger.md +1 -1
- package/docs/runtime/README.md +4 -4
- package/docs/runtime/official-perception-modules.md +2 -2
- package/docs/runtime/owner-lifecycle-and-observability.md +1 -1
- package/package.json +15 -2
- package/scripts/enable_ccl_permissions.cjs +4 -2
- package/scripts/find-hide-spots.py +2 -2
- package/scripts/postinstall.mjs +1 -4
- package/scripts/sync-bundled-skill.mjs +12 -159
- package/skills/clawclaw/SKILL.md +25 -18
- package/skills/clawclaw/references/BEHAVIORS.md +15 -11
- package/skills/clawclaw/references/COMMANDS.md +45 -41
- package/skills/clawclaw/references/HUB.md +25 -38
- package/skills/clawclaw/references/TACTICS.md +1 -1
- package/src/commands/account.ts +58 -14
- package/src/commands/behavior.ts +116 -38
- package/src/commands/hub.ts +110 -153
- package/src/commands/load.ts +138 -33
- package/src/commands/perception.ts +55 -24
- package/src/commands/persona.ts +66 -20
- package/src/commands/skill.ts +12 -48
- package/src/commands/trigger.ts +68 -40
- package/src/lib/account-guidance.ts +54 -9
- package/src/lib/agent-workspace-client.ts +135 -0
- package/src/lib/agent-workspace-runtime.ts +154 -0
- package/src/lib/agent-workspace-skills.ts +177 -0
- package/src/lib/agent-workspace-sync.ts +852 -0
- package/src/lib/gameplay-config.ts +29 -15
- package/src/lib/hub-client.ts +252 -34
- package/src/lib/hub-reminder.ts +24 -11
- package/src/lib/init-command.ts +0 -6
- package/src/lib/load-context.ts +12 -6
- package/src/lib/persona.ts +141 -69
- package/src/lib/server-status.ts +78 -0
- package/src/lib/skill-host.ts +160 -0
- package/src/lib/user-data.ts +197 -4
- package/src/runtime/clawclaw/behavior-read-api.ts +1 -1
- package/src/{strategies/pathfind → runtime/clawclaw/navigation}/astar-path.ts +1 -1
- package/src/{strategies/pathfind → runtime/clawclaw/navigation}/escape-planner.ts +1 -1
- package/src/{strategies → runtime/clawclaw/navigation}/hide-spots.ts +2 -2
- package/src/{strategies → runtime/clawclaw/navigation}/off-route-points.ts +6 -3
- package/src/{strategies/pathfind → runtime/clawclaw/navigation}/walkable-grid.ts +1 -1
- package/src/runtime/clawclaw/owner.ts +63 -19
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.ts +8 -2
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +2 -2
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +1 -1
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +4 -1
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +11 -5
- package/src/runtime/clawclaw/plugins/perception/replay.ts +0 -2
- package/src/runtime/framework/modules/runtime-module-loader.ts +0 -54
- package/src/sdk/behavior-toolkit/escape.ts +2 -2
- package/personas//345/217/243/346/230/257/345/277/203/351/235/236.md +0 -50
- package/personas//345/277/240/345/277/203/350/200/201/344/273/206.md +0 -51
- package/personas//346/227/240/344/272/272/350/256/276.md +0 -1
- package/personas//350/264/253/345/230/264/346/215/237/345/217/213.md +0 -48
- package/personas//350/275/257/350/220/214/350/205/271/351/273/221.md +0 -51
- package/scripts/compare-perception-replays.test.ts +0 -188
- package/scripts/enable_ccl_permissions.test.mjs +0 -163
- package/scripts/enable_monitor.test.mjs +0 -201
- package/scripts/sync-bundled-skill.test.mjs +0 -152
- package/scripts/watch-perception-events.test.ts +0 -43
- package/src/behaviors/official-finite/do-task.ts +0 -211
- package/src/behaviors/official-finite/evade.ts +0 -78
- package/src/behaviors/official-finite/find-player.ts +0 -50
- package/src/behaviors/official-finite/follow-player.ts +0 -70
- package/src/behaviors/official-finite/go-to.ts +0 -69
- package/src/behaviors/official-finite/hide-temporarily.ts +0 -77
- package/src/behaviors/official-finite/hold-position.ts +0 -48
- package/src/behaviors/official-finite/hunt-player.ts +0 -47
- package/src/behaviors/official-finite/index.test.ts +0 -249
- package/src/behaviors/official-finite/index.ts +0 -44
- package/src/behaviors/official-finite/inspect-corpse.ts +0 -64
- package/src/behaviors/official-finite/patrol-area.ts +0 -80
- package/src/behaviors/official-finite/report-corpse.ts +0 -73
- package/src/behaviors/official-finite/seek-kill-opportunity.ts +0 -152
- package/src/behaviors/official-finite/shared.ts +0 -27
- package/src/channel/claude-channel-server.test.ts +0 -202
- package/src/commands/account.test.ts +0 -570
- package/src/commands/behavior.test.ts +0 -158
- package/src/commands/communication.test.ts +0 -282
- package/src/commands/competition.test.ts +0 -116
- package/src/commands/data.test.ts +0 -89
- package/src/commands/events-canonical-state.test.ts +0 -406
- package/src/commands/events.test.ts +0 -58
- package/src/commands/game/index.test.ts +0 -1251
- package/src/commands/game-map.test.ts +0 -69
- package/src/commands/hub.test.ts +0 -124
- package/src/commands/load.test.ts +0 -440
- package/src/commands/perception.test.ts +0 -75
- package/src/commands/setup/hermes.test.ts +0 -96
- package/src/commands/setup/openclaw.test.ts +0 -124
- package/src/commands/trigger.test.ts +0 -140
- package/src/commands/upgrade.test.ts +0 -82
- package/src/lib/account-guidance.test.ts +0 -36
- package/src/lib/auth.test.ts +0 -151
- package/src/lib/behavior-export.test.ts +0 -326
- package/src/lib/behavior-export.ts +0 -537
- package/src/lib/clawclaw-skill-spectate-guidance.test.ts +0 -21
- package/src/lib/custom-tts.test.ts +0 -387
- package/src/lib/diagnostics-config.test.ts +0 -59
- package/src/lib/game-client-tts.test.ts +0 -151
- package/src/lib/game-client.test.ts +0 -250
- package/src/lib/gameplay-config.test.ts +0 -301
- package/src/lib/host-config-patcher.test.ts +0 -130
- package/src/lib/http-transport.test.ts +0 -124
- package/src/lib/hub-client.test.ts +0 -57
- package/src/lib/hub-install.test.ts +0 -135
- package/src/lib/hub-install.ts +0 -185
- package/src/lib/hub-unzip.test.ts +0 -69
- package/src/lib/init-command.test.ts +0 -103
- package/src/lib/load-context.test.ts +0 -62
- package/src/lib/match-state.test.ts +0 -134
- package/src/lib/official-resource-sync.test.ts +0 -199
- package/src/lib/official-resource-sync.ts +0 -221
- package/src/lib/perception-config.test.ts +0 -143
- package/src/lib/perception-export.test.ts +0 -145
- package/src/lib/perception-export.ts +0 -178
- package/src/lib/persona.test.ts +0 -84
- package/src/lib/room.test.ts +0 -88
- package/src/lib/server-registry.test.ts +0 -64
- package/src/lib/service-status.test.ts +0 -81
- package/src/lib/skill-version.test.ts +0 -48
- package/src/lib/trigger-config.test.ts +0 -102
- package/src/lib/trigger-export.test.ts +0 -80
- package/src/lib/trigger-export.ts +0 -210
- package/src/lib/user-data.test.ts +0 -121
- package/src/lib/workspace-argv.test.ts +0 -49
- package/src/pipeline/canonical-event-presentation.test.ts +0 -257
- package/src/pipeline/event-format.test.ts +0 -879
- package/src/pipeline/event-hints.test.ts +0 -337
- package/src/pipeline/game-sync-event-normalization.test.ts +0 -419
- package/src/pipeline/player-projection.test.ts +0 -247
- package/src/runtime/auto-upgrade.test.ts +0 -66
- package/src/runtime/canonical-event-emitter.test.ts +0 -70
- package/src/runtime/canonical-monitor.test.ts +0 -577
- package/src/runtime/clawclaw/agent-event-policy.test.ts +0 -60
- package/src/runtime/clawclaw/behavior-decision.test.ts +0 -43
- package/src/runtime/clawclaw/behavior-input-fields.test.ts +0 -175
- package/src/runtime/clawclaw/behavior-input.test.ts +0 -173
- package/src/runtime/clawclaw/behavior-observation-memory.test.ts +0 -59
- package/src/runtime/clawclaw/behavior-read-api.test.ts +0 -123
- package/src/runtime/clawclaw/notifications.test.ts +0 -47
- package/src/runtime/clawclaw/owner-lock.test.ts +0 -221
- package/src/runtime/clawclaw/owner.test.ts +0 -203
- package/src/runtime/clawclaw/plugins/action/action-plugin.test.ts +0 -328
- package/src/runtime/clawclaw/plugins/assembly.test.ts +0 -200
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.test.ts +0 -180
- package/src/runtime/clawclaw/plugins/behavior/behavior-action.test.ts +0 -43
- package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.test.ts +0 -156
- package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.test.ts +0 -182
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.test.ts +0 -1094
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.test.ts +0 -174
- package/src/runtime/clawclaw/plugins/behavior/control-driver.test.ts +0 -195
- package/src/runtime/clawclaw/plugins/behavior/official-goal-behavior.ts +0 -757
- package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.test.ts +0 -283
- package/src/runtime/clawclaw/plugins/behavior-input-source.test.ts +0 -80
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.test.ts +0 -267
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.test.ts +0 -226
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.test.ts +0 -239
- package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.test.ts +0 -407
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-push.integration.test.ts +0 -397
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.test.ts +0 -270
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-agent-event-batch.test.ts +0 -166
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.test.ts +0 -194
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.test.ts +0 -87
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +0 -2012
- package/src/runtime/clawclaw/plugins/perception/module-runner.test.ts +0 -214
- package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +0 -347
- package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.test.ts +0 -92
- package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.ts +0 -248
- package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +0 -389
- package/src/runtime/clawclaw/plugins/perception/modules/index.ts +0 -8
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.test.ts +0 -342
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +0 -475
- package/src/runtime/clawclaw/plugins/perception/modules/parallel-module-test-helpers.ts +0 -30
- package/src/runtime/clawclaw/plugins/perception/modules/relation-stability.test.ts +0 -304
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.test.ts +0 -179
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +0 -364
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.test.ts +0 -81
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +0 -200
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.test.ts +0 -216
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +0 -284
- package/src/runtime/clawclaw/plugins/perception/modules/temporal-evidence.test.ts +0 -120
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.test.ts +0 -105
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +0 -269
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.test.ts +0 -865
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +0 -1878
- package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +0 -278
- package/src/runtime/clawclaw/plugins/perception/replay.test.ts +0 -77
- package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +0 -853
- package/src/runtime/clawclaw/plugins/source/game-transport.test.ts +0 -287
- package/src/runtime/clawclaw/plugins/source/player-change-tracker.test.ts +0 -321
- package/src/runtime/clawclaw/plugins/source/room-transport.test.ts +0 -307
- package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +0 -2646
- package/src/runtime/clawclaw/plugins/source/task-change-tracker.test.ts +0 -212
- package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.test.ts +0 -548
- package/src/runtime/clawclaw/plugins/trigger/trigger-source.test.ts +0 -169
- package/src/runtime/clawclaw/runtime-data-export.test.ts +0 -249
- package/src/runtime/clawclaw-event-catalog.test.ts +0 -128
- package/src/runtime/framework/action-diagnostics.test.ts +0 -81
- package/src/runtime/framework/capability-registry.test.ts +0 -423
- package/src/runtime/framework/control-coordinator.test.ts +0 -675
- package/src/runtime/framework/events/event-delivery-service.test.ts +0 -84
- package/src/runtime/framework/events/event-ingress.test.ts +0 -203
- package/src/runtime/framework/events/mailbox-event-repositories.test.ts +0 -710
- package/src/runtime/framework/events/sqlite-event-repository.test.ts +0 -802
- package/src/runtime/framework/mailbox/coalescer.test.ts +0 -55
- package/src/runtime/framework/mailbox/identity.test.ts +0 -38
- package/src/runtime/framework/mailbox/mailbox-dispatcher.test.ts +0 -513
- package/src/runtime/framework/mailbox/notification-projector.test.ts +0 -77
- package/src/runtime/framework/modules/runtime-module-loader.test.ts +0 -435
- package/src/runtime/framework/participation-manager.test.ts +0 -108
- package/src/runtime/framework/plugins/runtime-input-journal.test.ts +0 -179
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.test.ts +0 -2040
- package/src/runtime/framework/state/durable-agent-state-snapshot.test.ts +0 -144
- package/src/runtime/framework/state/history/sqlite-state-history-repository.test.ts +0 -157
- package/src/runtime/framework/state/history/state-history.test.ts +0 -251
- package/src/runtime/framework/state/state-core.test.ts +0 -197
- package/src/runtime/game-sync-protocol.test.ts +0 -123
- package/src/runtime/host-monitor-rate-gate.test.ts +0 -73
- package/src/runtime/mailbox-host-relay.test.ts +0 -293
- package/src/runtime/observability/observability.test.ts +0 -583
- package/src/runtime/owner-control.test.ts +0 -153
- package/src/runtime/parent-process-watch.test.ts +0 -27
- package/src/runtime/pending-event-handoff.test.ts +0 -29
- package/src/runtime/raw-ws-log.test.ts +0 -102
- package/src/runtime/runtime-logger.test.ts +0 -58
- package/src/runtime/runtime-persistence.test.ts +0 -26
- package/src/runtime/runtime.test.ts +0 -1770
- package/src/runtime/ws-client.test.ts +0 -562
- package/src/sdk/action.test.ts +0 -8
- package/src/sdk/behavior-plugin/index.test.ts +0 -74
- package/src/sdk/index.test.ts +0 -45
- package/src/sdk/module-input/index.test.ts +0 -49
- package/src/sdk/perception-plugin/index.test.ts +0 -22
- package/src/sdk/resource-metadata.test.ts +0 -40
- package/src/sdk/trigger-plugin/index.test.ts +0 -41
- package/src/short-command/classifier.test.ts +0 -107
- package/src/short-command/presenter.test.ts +0 -119
- package/src/short-command/runner.test.ts +0 -78
- package/src/short-command/sensitive-data-filter.test.ts +0 -56
- package/src/short-command/transport-response.test.ts +0 -39
- package/src/strategies/avoid-lone.ts +0 -32
- package/src/strategies/avoid-players.ts +0 -43
- package/src/strategies/corpse-patrol.ts +0 -50
- package/src/strategies/crab-sabotage.ts +0 -48
- package/src/strategies/custom-module.test.ts +0 -267
- package/src/strategies/find-player.ts +0 -49
- package/src/strategies/game-utils.test.ts +0 -305
- package/src/strategies/game-utils.ts +0 -927
- package/src/strategies/goals/anchor-linger.ts +0 -77
- package/src/strategies/goals/avoid-lone-top.ts +0 -189
- package/src/strategies/goals/avoid-players-top.test.ts +0 -95
- package/src/strategies/goals/avoid-players-top.ts +0 -122
- package/src/strategies/goals/conversation-goal.ts +0 -51
- package/src/strategies/goals/corpse-patrol-top.ts +0 -120
- package/src/strategies/goals/crab-octopus-reflexes.ts +0 -109
- package/src/strategies/goals/crab-sabotage-top.test.ts +0 -131
- package/src/strategies/goals/crab-sabotage-top.ts +0 -139
- package/src/strategies/goals/emergency-hunt-goal.ts +0 -40
- package/src/strategies/goals/find-player-top.ts +0 -136
- package/src/strategies/goals/flee-players-goal.ts +0 -55
- package/src/strategies/goals/follow-companion-goal.ts +0 -130
- package/src/strategies/goals/goal-manager.ts +0 -41
- package/src/strategies/goals/goal-root-strategy.ts +0 -49
- package/src/strategies/goals/goal.ts +0 -28
- package/src/strategies/goals/hide-top.ts +0 -240
- package/src/strategies/goals/keep-away-goal.ts +0 -243
- package/src/strategies/goals/kill-frenzy-top.ts +0 -90
- package/src/strategies/goals/kill-lone-top.test.ts +0 -96
- package/src/strategies/goals/kill-lone-top.ts +0 -166
- package/src/strategies/goals/kill-target-goal.ts +0 -69
- package/src/strategies/goals/kill-target-top.test.ts +0 -65
- package/src/strategies/goals/kill-target-top.ts +0 -121
- package/src/strategies/goals/leaf-goal.ts +0 -27
- package/src/strategies/goals/linger-corpse-goal.ts +0 -43
- package/src/strategies/goals/lone-kill-core.ts +0 -86
- package/src/strategies/goals/lone-kill-goal.ts +0 -24
- package/src/strategies/goals/lone-kill-task-top.test.ts +0 -84
- package/src/strategies/goals/lone-kill-task-top.ts +0 -133
- package/src/strategies/goals/move-room-goal.ts +0 -102
- package/src/strategies/goals/normal-shrimp-top.test.ts +0 -112
- package/src/strategies/goals/normal-shrimp-top.ts +0 -248
- package/src/strategies/goals/paradise-fish-top.test.ts +0 -203
- package/src/strategies/goals/paradise-fish-top.ts +0 -234
- package/src/strategies/goals/patrol-top.ts +0 -68
- package/src/strategies/goals/report-patrol-top.ts +0 -97
- package/src/strategies/goals/safe-task-goal.ts +0 -130
- package/src/strategies/goals/social-task-top.ts +0 -192
- package/src/strategies/goals/task-kill-report-top.ts +0 -187
- package/src/strategies/goals/task-only-top.test.ts +0 -88
- package/src/strategies/goals/task-only-top.ts +0 -64
- package/src/strategies/goals/task-or-patrol-goal.ts +0 -59
- package/src/strategies/goals/task-report-top.ts +0 -57
- package/src/strategies/goals/wander-task-goal.ts +0 -33
- package/src/strategies/goals/warrior-shrimp-top.test.ts +0 -138
- package/src/strategies/goals/warrior-shrimp-top.ts +0 -293
- package/src/strategies/greeting.ts +0 -60
- package/src/strategies/hide.ts +0 -51
- package/src/strategies/kill-frenzy.ts +0 -32
- package/src/strategies/kill-lone.ts +0 -52
- package/src/strategies/kill-target.ts +0 -48
- package/src/strategies/lone-kill-task.ts +0 -48
- package/src/strategies/meeting-gate.test.ts +0 -59
- package/src/strategies/meeting-gate.ts +0 -28
- package/src/strategies/move-room.ts +0 -46
- package/src/strategies/official-long-behavior.test.ts +0 -89
- package/src/strategies/paradise-fish.ts +0 -70
- package/src/strategies/pathfind/astar-path.test.ts +0 -198
- package/src/strategies/pathfind/escape-planner.test.ts +0 -223
- package/src/strategies/patrol.ts +0 -32
- package/src/strategies/player-targets.test.ts +0 -10
- package/src/strategies/player-targets.ts +0 -18
- package/src/strategies/report-patrol.ts +0 -32
- package/src/strategies/shrimp-memory.ts +0 -87
- package/src/strategies/social-task.ts +0 -67
- package/src/strategies/speech-module.ts +0 -123
- package/src/strategies/task-kill-report.ts +0 -49
- package/src/strategies/task-only.test.ts +0 -138
- package/src/strategies/task-only.ts +0 -34
- package/src/strategies/task-report.ts +0 -50
- package/src/strategies/types.ts +0 -116
- package/src/strategies/warrior-memory.ts +0 -54
- /package/src/{strategies/pathfind → runtime/clawclaw/navigation}/clawclaw-walkable.bin +0 -0
- /package/src/{strategies/pathfind → runtime/clawclaw/navigation}/distance-field.ts +0 -0
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import type { GameState, PlayerInfo } from '../../sdk/types.js';
|
|
2
|
-
import { Action } from '../../sdk/action.js';
|
|
3
|
-
import {
|
|
4
|
-
canUseKill,
|
|
5
|
-
corpseAtScene,
|
|
6
|
-
dist,
|
|
7
|
-
killCommitRange,
|
|
8
|
-
nearestReportableCorpse,
|
|
9
|
-
nonTeammatesVisible,
|
|
10
|
-
reportCorpseDecision,
|
|
11
|
-
playerStrategyIntent,
|
|
12
|
-
strategyDecision,
|
|
13
|
-
} from '../game-utils.js';
|
|
14
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 蟹(坏人)/ 章鱼(中立带刀)默认策略共享的「反射动作」——由 CrabSabotageTop 与 LoneKillTaskTop
|
|
18
|
-
* 在各自 tick() 的**最前面**调用,抢在破坏/任务/落单猎杀编排之前先处理两类即时机会:
|
|
19
|
-
*
|
|
20
|
-
* - immediateLoneKillDecision:唯一一个落单非队友就贴在脸上(出刀范围内)且刀好 → 立刻出刀。它无视
|
|
21
|
-
* LoneKillCore 的「暂停窗口」,也不管自己是否正在做破坏任务——只要能原地一刀就先杀。
|
|
22
|
-
* - corpseReportWithNonTeammate:地上有尸体且附近有非队友 → 报警(够不着先靠近)。不管尸体是谁
|
|
23
|
-
* 造成的(含队友的杀),靠主动报警伪装好人 / 把嫌疑栽到在场者身上。
|
|
24
|
-
*
|
|
25
|
-
* 调用方按「能贴脸杀就杀,否则报警」的次序:先 immediateLoneKillDecision 再 corpseReportWithNonTeammate。
|
|
26
|
-
* 两者都不读取玩家分类参数,与默认蟹/章鱼对任意落单非队友照杀的设定一致;蟹/章鱼目前
|
|
27
|
-
* 没有记忆版策略,故没有「点名/保护」入口。
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/** 有尸体且附近有非队友 → 报警/靠近报警;否则 null。respectBlock 防止 5s 内重复报。 */
|
|
31
|
-
export function corpseReportWithNonTeammate(state: GameState, ctx: StrategyContext): BehaviorDecision[] | null {
|
|
32
|
-
// 报尸自证/嫁祸是「此刻就在尸体旁、有人撞见」的现场反射,必须用当帧视野的尸体;用持久记忆会让
|
|
33
|
-
// 蟹/章鱼在地图别处随便撞见一个人就生成错误的栽赃简报。
|
|
34
|
-
if (!corpseAtScene(state)) return null;
|
|
35
|
-
const witnesses = nonTeammatesVisible(state, ctx);
|
|
36
|
-
if (witnesses.length === 0) return null;
|
|
37
|
-
|
|
38
|
-
const report = reportCorpseDecision(state, ctx, { respectBlock: true });
|
|
39
|
-
if (!report) return null;
|
|
40
|
-
|
|
41
|
-
const witnessNames = witnesses.map(p => p.name).join('、');
|
|
42
|
-
if (report.action.type === 'report') {
|
|
43
|
-
// 实时给 Agent 一条「为什么是我报的尸」简报:报尸=召集会议,是高风险自证动作。
|
|
44
|
-
// 若尸体很可能是自己刚才下的那一刀,必须显式提醒,免得 Agent 之后发言露馅。
|
|
45
|
-
const corpse = nearestReportableCorpse(state);
|
|
46
|
-
const corpseName = corpse?.name ?? '';
|
|
47
|
-
ctx.agentAlerts.push(
|
|
48
|
-
isRecentOwnKill(ctx, corpse)
|
|
49
|
-
? `我刚下手的目标${corpseName ? `(${corpseName})` : ''}尸体被${witnessNames}撞见,我抢先报尸召集会议、把自己装成发现者并把嫌疑引向在场者。接下来发言/投票要顺着「我是主动报告的人」走,绝不能承认是自己动的手。`
|
|
50
|
-
: `尸体旁有${witnessNames}在场,我抢先报尸召集会议、伪装成主动报告的好人。发言时按「主动报告的发现者」立场走。`,
|
|
51
|
-
);
|
|
52
|
-
ctx.notifications.push(`尸体旁有${witnessNames}在场,立刻报告自证。`);
|
|
53
|
-
const base = report.action.thinkingContent ?? '发现尸体,报告召开会议';
|
|
54
|
-
return [{
|
|
55
|
-
action: report.action.withThinking(`${base};尸体旁有${witnessNames}在场,立刻报告自证。`),
|
|
56
|
-
intent: report.intent,
|
|
57
|
-
}];
|
|
58
|
-
}
|
|
59
|
-
ctx.notifications.push(`尸体旁有${witnessNames}在场,靠近尸体准备报告自证。`);
|
|
60
|
-
return [{
|
|
61
|
-
action: report.action.withThinking(`尸体旁有${witnessNames}在场,靠近尸体准备报告自证。`),
|
|
62
|
-
intent: report.intent,
|
|
63
|
-
}];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* 唯一一个落单非队友贴脸(出刀范围内)且刀好 → 立刻出刀;否则 null。无视暂停窗口、不管在做什么任务。
|
|
68
|
-
* 可选 skipTarget:返回 true 的目标本帧不出刀(章鱼残局抢修期用它放过紧挨紧急维修点的目标)。
|
|
69
|
-
*/
|
|
70
|
-
export function immediateLoneKillDecision(
|
|
71
|
-
state: GameState,
|
|
72
|
-
ctx: StrategyContext,
|
|
73
|
-
skipTarget?: (target: PlayerInfo) => boolean,
|
|
74
|
-
): BehaviorDecision[] | null {
|
|
75
|
-
if (!canUseKill(state)) return null;
|
|
76
|
-
|
|
77
|
-
const targets = nonTeammatesVisible(state, ctx);
|
|
78
|
-
if (targets.length !== 1) return null;
|
|
79
|
-
|
|
80
|
-
const target = targets[0];
|
|
81
|
-
const distance = target.distance ?? dist(state.you.x, state.you.y, target.x, target.y);
|
|
82
|
-
if (distance > killCommitRange(state.you.role)) return null;
|
|
83
|
-
if (skipTarget?.(target)) return null;
|
|
84
|
-
|
|
85
|
-
ctx.notifications.push(`发现落单目标${target.name}就在身边,立刻出刀!`);
|
|
86
|
-
if (target.seat == null || target.seat <= 0) return null;
|
|
87
|
-
return [strategyDecision(Action.kill(target.seat), playerStrategyIntent(target, '追杀', 'acting'))];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* 这具尸体是不是「自己刚才下的那一刀」。先按尸体座位号精确匹配 recentlyKilledTargets(刚杀过且未过期),
|
|
92
|
-
* 座位对不上但近期确实杀过人时,冒出的尸体大概率也是自己造成的,按 true 处理(宁可多提醒一次)。
|
|
93
|
-
*/
|
|
94
|
-
function isRecentOwnKill(
|
|
95
|
-
ctx: StrategyContext,
|
|
96
|
-
corpse: { seat?: number } | null,
|
|
97
|
-
): boolean {
|
|
98
|
-
const map = ctx.recentlyKilledTargets;
|
|
99
|
-
if (!map || map.size === 0) return false;
|
|
100
|
-
const now = Date.now();
|
|
101
|
-
if (corpse?.seat != null) {
|
|
102
|
-
const until = map.get(String(corpse.seat));
|
|
103
|
-
if (until != null && until > now) return true;
|
|
104
|
-
}
|
|
105
|
-
for (const until of map.values()) {
|
|
106
|
-
if (until > now) return true;
|
|
107
|
-
}
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import type { GameState, TaskInfo } from '../../sdk/types.js';
|
|
3
|
-
import type { StrategyContext } from '../types.js';
|
|
4
|
-
import { CrabSabotageTop } from './crab-sabotage-top.js';
|
|
5
|
-
|
|
6
|
-
type SabotageStatus = 'ready' | 'cooldown_charged' | 'emergency_active';
|
|
7
|
-
|
|
8
|
-
function state(status: SabotageStatus): GameState {
|
|
9
|
-
return {
|
|
10
|
-
phase: 'wandering',
|
|
11
|
-
tick: 1,
|
|
12
|
-
you: {
|
|
13
|
-
name: 'crab',
|
|
14
|
-
x: 0,
|
|
15
|
-
y: 0,
|
|
16
|
-
room: 'control',
|
|
17
|
-
role: 'crab_generic',
|
|
18
|
-
faction: 'crab',
|
|
19
|
-
is_alive: true,
|
|
20
|
-
kill_cooldown_secs: 5,
|
|
21
|
-
},
|
|
22
|
-
your_tasks: [],
|
|
23
|
-
players: [],
|
|
24
|
-
all_players: [],
|
|
25
|
-
corpses: [],
|
|
26
|
-
crab_sabotage: { status },
|
|
27
|
-
stale: false,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function task(overrides: Partial<TaskInfo> = {}): TaskInfo {
|
|
32
|
-
return {
|
|
33
|
-
task_id: 'sabotage-task',
|
|
34
|
-
task_name: 'charge-alarm',
|
|
35
|
-
room: 'lab',
|
|
36
|
-
status: 'pending',
|
|
37
|
-
x: 100,
|
|
38
|
-
y: 0,
|
|
39
|
-
faction: 'crab',
|
|
40
|
-
is_fake_shrimp: false,
|
|
41
|
-
...overrides,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function context(tasks: TaskInfo[] = []): StrategyContext {
|
|
46
|
-
return {
|
|
47
|
-
taskData: tasks,
|
|
48
|
-
emergency: null,
|
|
49
|
-
taskLocalBlockedUntil: 0,
|
|
50
|
-
reportCorpseTarget: null,
|
|
51
|
-
reportBlockedUntil: 0,
|
|
52
|
-
notifications: [],
|
|
53
|
-
lastProgressNotifyAt: Date.now(),
|
|
54
|
-
teammates: new Set(),
|
|
55
|
-
rooms: [{ name: 'patrol', x: 500, y: 0 }],
|
|
56
|
-
playerNamesBySeat: {},
|
|
57
|
-
forcePatrolAdvance: false,
|
|
58
|
-
blockedMoveTarget: null,
|
|
59
|
-
mySeat: 1,
|
|
60
|
-
speechNotifications: [],
|
|
61
|
-
agentAlerts: [],
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function selectedAction(top: CrabSabotageTop, game: GameState, ctx: StrategyContext) {
|
|
66
|
-
const direct = top.tick(game, ctx);
|
|
67
|
-
if (direct.length > 0) return direct[0]?.action;
|
|
68
|
-
return top.subGoal?.tick(game, ctx)[0]?.action;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
describe('CrabSabotageTop shared sabotage state', () => {
|
|
72
|
-
it('moves toward an assigned sabotage task while authoritative state is ready', () => {
|
|
73
|
-
const top = new CrabSabotageTop();
|
|
74
|
-
const game = state('ready');
|
|
75
|
-
const ctx = context([task()]);
|
|
76
|
-
|
|
77
|
-
const action = selectedAction(top, game, ctx);
|
|
78
|
-
|
|
79
|
-
expect(action?.type).toBe('move');
|
|
80
|
-
expect(action?.payload).toMatchObject({ target_x: 100, target_y: 0 });
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('submits the existing task action at a sabotage point and never emits trigger_alarm', () => {
|
|
84
|
-
const top = new CrabSabotageTop();
|
|
85
|
-
const game = state('ready');
|
|
86
|
-
const ctx = context([task({ x: 5 })]);
|
|
87
|
-
|
|
88
|
-
const action = selectedAction(top, game, ctx);
|
|
89
|
-
expect(action?.type).toBe('task');
|
|
90
|
-
expect(action?.payload).toMatchObject({ task_name: 'charge-alarm' });
|
|
91
|
-
expect(action?.type).not.toBe('trigger_alarm');
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('skips personal sabotage work while shared charge is waiting on cooldown', () => {
|
|
95
|
-
const top = new CrabSabotageTop();
|
|
96
|
-
const game = state('cooldown_charged');
|
|
97
|
-
const ctx = context([
|
|
98
|
-
task(),
|
|
99
|
-
task({
|
|
100
|
-
task_id: 'fake-task',
|
|
101
|
-
task_name: 'fake-task',
|
|
102
|
-
x: 200,
|
|
103
|
-
is_fake_shrimp: true,
|
|
104
|
-
}),
|
|
105
|
-
]);
|
|
106
|
-
|
|
107
|
-
const action = selectedAction(top, game, ctx);
|
|
108
|
-
|
|
109
|
-
expect(action?.type).toBe('move');
|
|
110
|
-
expect(action?.payload).toMatchObject({ target_x: 200, target_y: 0 });
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('does not trigger or prepare sabotage while an emergency is active', () => {
|
|
114
|
-
const top = new CrabSabotageTop();
|
|
115
|
-
const game = state('emergency_active');
|
|
116
|
-
const ctx = context([task()]);
|
|
117
|
-
ctx.emergency = {
|
|
118
|
-
task_id: 'repair',
|
|
119
|
-
task_name: 'repair',
|
|
120
|
-
room: 'lab',
|
|
121
|
-
status: 'pending',
|
|
122
|
-
x: 100,
|
|
123
|
-
y: 0,
|
|
124
|
-
remaining_secs: 30,
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
const action = selectedAction(top, game, ctx);
|
|
128
|
-
|
|
129
|
-
expect(action?.type).not.toBe('task');
|
|
130
|
-
});
|
|
131
|
-
});
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import type { GameState, TaskInfo } from '../../sdk/types.js';
|
|
2
|
-
import {
|
|
3
|
-
approachOrDoTaskStep,
|
|
4
|
-
firstAvailableTask,
|
|
5
|
-
killCooldownSecs,
|
|
6
|
-
nonTeammatesVisible,
|
|
7
|
-
PatrolState,
|
|
8
|
-
PROGRESS_INTERVAL_MS,
|
|
9
|
-
} from '../game-utils.js';
|
|
10
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
11
|
-
import { Goal } from './goal.js';
|
|
12
|
-
import { LoneKillCore } from './lone-kill-core.js';
|
|
13
|
-
import { LoneKillGoal } from './lone-kill-goal.js';
|
|
14
|
-
import { WanderTaskGoal } from './wander-task-goal.js';
|
|
15
|
-
import { EmergencyHuntGoal } from './emergency-hunt-goal.js';
|
|
16
|
-
import { emitLeaf, setBehavior, URGENT_GOAL_PRIORITY, WANDER_GOAL_PRIORITY } from './leaf-goal.js';
|
|
17
|
-
import { corpseReportWithNonTeammate, immediateLoneKillDecision } from './crab-octopus-reflexes.js';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 蟹的「破坏 + 落单猎杀 + 任务伪装」编排 top。本身不产决策,每 tick 自上而下判定该走哪条分支、
|
|
21
|
-
* 把对应**叶子子目标**挂为唯一子目标(产出动作的是叶子;URGENT/WANDER 优先级供 ConversationGoal 判断):
|
|
22
|
-
*
|
|
23
|
-
* 0a. 反射·立刻出刀(crab-octopus-reflexes,URGENT):落单非队友贴脸(出刀范围内)且刀好 → 立刻出刀,
|
|
24
|
-
* 无视暂停窗口、不管自己是否正在做破坏任务。
|
|
25
|
-
* 0b. 反射·报尸(crab-octopus-reflexes,URGENT):有尸体且附近有非队友 → 报警/靠近报警,不管尸体是谁造成的。
|
|
26
|
-
* 1a. 服务端状态 ready → 去做真实破坏任务;完成后服务端自动触发一一对应的紧急任务。
|
|
27
|
-
* 1b. 正在做任务(doing_task)→ 本 tick 不产决策,不撇下任务去猎杀(0a 的贴脸反射刀仍生效)。
|
|
28
|
-
* 2. 落单猎杀(LoneKillGoal,URGENT):assess 判 hunt(刀好且有落单目标)→ 叶子 pursue;
|
|
29
|
-
* 刀在冷却时 assess 返回 idle,不追不等,直接下沉到破坏/任务/巡逻。
|
|
30
|
-
* 3. 紧急期搜猎(EmergencyHuntGoal,URGENT):往人少处找真正落单的,永远有动作(不在人前乱杀)。
|
|
31
|
-
* 4. 任务伪装 / 巡逻(WanderTaskGoal,WANDER):先真实任务再虾的伪装任务,跳过紧挨已知尸体的任务,没任务就巡逻。
|
|
32
|
-
*/
|
|
33
|
-
export class CrabSabotageTop extends Goal {
|
|
34
|
-
private readonly killCore = new LoneKillCore();
|
|
35
|
-
private readonly patrol = new PatrolState();
|
|
36
|
-
private readonly loneKillGoal = new LoneKillGoal(this.killCore);
|
|
37
|
-
private readonly emergencyHuntGoal = new EmergencyHuntGoal(this.killCore, this.patrol);
|
|
38
|
-
private readonly wanderGoal = new WanderTaskGoal(
|
|
39
|
-
(state, ctx) => {
|
|
40
|
-
const sabotageTask = this.shouldPrepareSabotage(state)
|
|
41
|
-
? firstAvailableTask(ctx.taskData, t => this.isWorkableTask(t) && !t.is_fake_shrimp, undefined, ctx.blockedMoveTarget, ctx.knownCorpses)
|
|
42
|
-
: null;
|
|
43
|
-
return sabotageTask
|
|
44
|
-
?? firstAvailableTask(ctx.taskData, t => this.isWorkableTask(t) && !!t.is_fake_shrimp, undefined, ctx.blockedMoveTarget, ctx.knownCorpses);
|
|
45
|
-
},
|
|
46
|
-
() => this.killCore.patrolStopOnPlayer(),
|
|
47
|
-
this.patrol,
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
onMeetingResume(): void {
|
|
51
|
-
this.killCore.reset();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
55
|
-
this.emitProgress(state, ctx);
|
|
56
|
-
|
|
57
|
-
const immediateKill = immediateLoneKillDecision(state, ctx);
|
|
58
|
-
if (immediateKill) return emitLeaf(this, immediateKill, URGENT_GOAL_PRIORITY);
|
|
59
|
-
|
|
60
|
-
const corpseReport = corpseReportWithNonTeammate(state, ctx);
|
|
61
|
-
if (corpseReport) return emitLeaf(this, corpseReport, URGENT_GOAL_PRIORITY);
|
|
62
|
-
|
|
63
|
-
// 1a. ready 表示当前可执行蟹破坏任务;任务完成后服务端自动触发紧急任务。
|
|
64
|
-
const crabTask = this.tryCrabTask(state, ctx);
|
|
65
|
-
if (crabTask) return emitLeaf(this, crabTask, WANDER_GOAL_PRIORITY);
|
|
66
|
-
|
|
67
|
-
if (state.you.doing_task) {
|
|
68
|
-
if (this.subGoal) this.removeSubGoal();
|
|
69
|
-
return [];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// 2. 落单猎杀(紧急;紧急期 bypass 暂停窗口持续盯防)
|
|
73
|
-
const target = this.killCore.assess(state, ctx, { bypassIgnoreWindow: !!ctx.emergency });
|
|
74
|
-
if (target.kind === 'hunt') {
|
|
75
|
-
this.loneKillGoal.setTarget(target.target);
|
|
76
|
-
return setBehavior(this, this.loneKillGoal, URGENT_GOAL_PRIORITY);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// 3. 紧急期搜猎(紧急):虾群涌向维修点,蟹不做任务,往人少处找真正落单的(警报期照样会被举报,不在人前乱杀)
|
|
80
|
-
if (ctx.emergency) return setBehavior(this, this.emergencyHuntGoal, URGENT_GOAL_PRIORITY);
|
|
81
|
-
|
|
82
|
-
// 4. 任务伪装 / 巡逻(游走)
|
|
83
|
-
return setBehavior(this, this.wanderGoal, WANDER_GOAL_PRIORITY);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// ── 1a. 去做真实破坏任务(破坏点紧挨已知尸体时跳过;到点遇阻返回 null,让上层回退去猎杀)──
|
|
87
|
-
private tryCrabTask(state: GameState, ctx: StrategyContext): BehaviorDecision[] | null {
|
|
88
|
-
if (state.you.faction !== 'crab') return null;
|
|
89
|
-
if (ctx.emergency) return null;
|
|
90
|
-
if (state.you.doing_task) return null;
|
|
91
|
-
if (!this.shouldPrepareSabotage(state)) return null;
|
|
92
|
-
|
|
93
|
-
const task = firstAvailableTask(
|
|
94
|
-
ctx.taskData,
|
|
95
|
-
t => t.faction === 'crab' && !t.is_fake_shrimp,
|
|
96
|
-
undefined,
|
|
97
|
-
ctx.blockedMoveTarget,
|
|
98
|
-
ctx.knownCorpses,
|
|
99
|
-
);
|
|
100
|
-
if (task) return approachOrDoTaskStep(state, ctx, task, false);
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
private isWorkableTask(task: TaskInfo): boolean {
|
|
105
|
-
return task.status !== 'emergency';
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
private shouldPrepareSabotage(state: GameState): boolean {
|
|
109
|
-
return state.crab_sabotage?.status === 'ready';
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
private emitProgress(state: GameState, ctx: StrategyContext): void {
|
|
113
|
-
const now = Date.now();
|
|
114
|
-
if (now - ctx.lastProgressNotifyAt < PROGRESS_INTERVAL_MS) return;
|
|
115
|
-
ctx.lastProgressNotifyAt = now;
|
|
116
|
-
|
|
117
|
-
const room = state.you.room ?? '未知';
|
|
118
|
-
const cd = killCooldownSecs(state);
|
|
119
|
-
const killsRemaining = state.you.kills_remaining;
|
|
120
|
-
const nonTeammates = nonTeammatesVisible(state, ctx);
|
|
121
|
-
|
|
122
|
-
let msg = `[进度] 当前在${room}`;
|
|
123
|
-
if (nonTeammates.length === 0) {
|
|
124
|
-
msg += ',视野内没有落单目标,继续巡逻做任务。';
|
|
125
|
-
} else if (nonTeammates.length === 1) {
|
|
126
|
-
msg += `,视野内发现落单目标${nonTeammates[0].name}。`;
|
|
127
|
-
if (cd > 0) msg += `攻击冷却中(${cd}s),先做任务、冷却好再下手。`;
|
|
128
|
-
if (killsRemaining === 0) msg += '出刀次数已用完,继续巡逻做任务。';
|
|
129
|
-
} else {
|
|
130
|
-
msg += `,视野内有${nonTeammates.length}人,不适合动手。`;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (state.emergency) {
|
|
134
|
-
msg += ' 紧急警报进行中,往人少处找真正落单的目标,别在人前动手。';
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
ctx.notifications.push(msg);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { GameState } from '../../sdk/types.js';
|
|
2
|
-
import { Action } from '../../sdk/action.js';
|
|
3
|
-
import {
|
|
4
|
-
nonTeammatesVisible,
|
|
5
|
-
patrolStep,
|
|
6
|
-
PatrolState,
|
|
7
|
-
patrolStrategyIntent,
|
|
8
|
-
roomAwayFromPlayers,
|
|
9
|
-
strategyDecision,
|
|
10
|
-
} from '../game-utils.js';
|
|
11
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
12
|
-
import { Goal } from './goal.js';
|
|
13
|
-
import type { LoneKillCore } from './lone-kill-core.js';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 紧急(自己触发破坏警报)期间的搜猎子目标(叶子,由上层以 URGENT 优先级挂载):虾群涌向维修点,
|
|
17
|
-
* 蟹不做任务,朝人少方向走去抓真正掉队的——警报期杀人照样会被举报,所以不在人前乱杀、只清落单;
|
|
18
|
-
* 看不到非队友就按房间游走搜寻。永远有动作。
|
|
19
|
-
* stop_on_player 复用 core.patrolStopOnPlayer()(身边只有队友时别撞着队友停下)。
|
|
20
|
-
*/
|
|
21
|
-
export class EmergencyHuntGoal extends Goal {
|
|
22
|
-
constructor(
|
|
23
|
-
private readonly core: LoneKillCore,
|
|
24
|
-
private readonly patrol: PatrolState,
|
|
25
|
-
) {
|
|
26
|
-
super();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
30
|
-
const crowd = nonTeammatesVisible(state, ctx);
|
|
31
|
-
const room = roomAwayFromPlayers(state, ctx, crowd);
|
|
32
|
-
if (room) {
|
|
33
|
-
return [strategyDecision(
|
|
34
|
-
Action.move({ x: room.x, y: room.y }, false),
|
|
35
|
-
patrolStrategyIntent(room, '寻找落单目标'),
|
|
36
|
-
)];
|
|
37
|
-
}
|
|
38
|
-
return patrolStep(state, ctx, this.patrol, this.core.patrolStopOnPlayer(), '巡逻寻找落单目标');
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import type { GameState } from '../../sdk/types.js';
|
|
2
|
-
import { Action } from '../../sdk/action.js';
|
|
3
|
-
import {
|
|
4
|
-
dist,
|
|
5
|
-
isTargetAlive,
|
|
6
|
-
nearestVisibleTarget,
|
|
7
|
-
PatrolState,
|
|
8
|
-
PATROL_REACHED_DISTANCE,
|
|
9
|
-
PROGRESS_INTERVAL_MS,
|
|
10
|
-
pursueVisibleTarget,
|
|
11
|
-
patrolStrategyIntent,
|
|
12
|
-
setStrategyIntent,
|
|
13
|
-
strategyDecision,
|
|
14
|
-
strategyPlayerLabel,
|
|
15
|
-
} from '../game-utils.js';
|
|
16
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
17
|
-
import { Goal } from './goal.js';
|
|
18
|
-
|
|
19
|
-
const DEFAULT_TRACK_DISTANCE = 40;
|
|
20
|
-
const LAST_SEEN_ARRIVE = 20;
|
|
21
|
-
|
|
22
|
-
export class FindPlayerTop extends Goal {
|
|
23
|
-
private readonly patrol = new PatrolState();
|
|
24
|
-
private lastSeenX: number | null = null;
|
|
25
|
-
private lastSeenY: number | null = null;
|
|
26
|
-
private lastSeenRoom: string | null = null;
|
|
27
|
-
private foundNotified = false;
|
|
28
|
-
|
|
29
|
-
constructor(
|
|
30
|
-
private readonly target: number,
|
|
31
|
-
private readonly trackDistance: number = DEFAULT_TRACK_DISTANCE,
|
|
32
|
-
) {
|
|
33
|
-
super();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
37
|
-
if (!isTargetAlive(state, this.target, ctx)) {
|
|
38
|
-
ctx.notifications.push('目标已死亡');
|
|
39
|
-
setStrategyIntent(ctx, {
|
|
40
|
-
activity: 'idle',
|
|
41
|
-
summary: `${this.targetLabel(ctx)}已死亡,正在等待下一步指令。`,
|
|
42
|
-
targetPlayer: this.targetLabel(ctx),
|
|
43
|
-
});
|
|
44
|
-
this.emitProgress(state, ctx);
|
|
45
|
-
return [];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const target = nearestVisibleTarget(state, ctx, [this.target]);
|
|
49
|
-
if (target) {
|
|
50
|
-
this.lastSeenX = target.x;
|
|
51
|
-
this.lastSeenY = target.y;
|
|
52
|
-
this.lastSeenRoom = target.room || null;
|
|
53
|
-
if (!this.foundNotified) {
|
|
54
|
-
this.foundNotified = true;
|
|
55
|
-
ctx.notifications.push('我已经牢牢跟住他了!');
|
|
56
|
-
}
|
|
57
|
-
const decision = pursueVisibleTarget(state, target, { kill: false, followDistance: this.trackDistance });
|
|
58
|
-
if (!decision) {
|
|
59
|
-
setStrategyIntent(ctx, {
|
|
60
|
-
activity: 'waiting',
|
|
61
|
-
summary: `正在${target.room || state.you.room || '当前位置'}贴近跟踪${strategyPlayerLabel(target)}。`,
|
|
62
|
-
...(target.room ? { room: target.room } : {}),
|
|
63
|
-
targetPlayer: target.name,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
this.emitProgress(state, ctx);
|
|
67
|
-
return decision ? [decision] : [];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
this.foundNotified = false;
|
|
71
|
-
|
|
72
|
-
if (this.lastSeenX != null && this.lastSeenY != null) {
|
|
73
|
-
if (dist(state.you.x, state.you.y, this.lastSeenX, this.lastSeenY) > LAST_SEEN_ARRIVE) {
|
|
74
|
-
this.emitProgress(state, ctx);
|
|
75
|
-
return [strategyDecision(Action.move({ x: this.lastSeenX, y: this.lastSeenY }), {
|
|
76
|
-
activity: 'moving',
|
|
77
|
-
summary: `正在前往${this.lastSeenRoom || '最后目击区域'}寻找${this.targetLabel(ctx)}。`,
|
|
78
|
-
...(this.lastSeenRoom ? { room: this.lastSeenRoom } : {}),
|
|
79
|
-
targetPlayer: this.targetLabel(ctx),
|
|
80
|
-
})];
|
|
81
|
-
}
|
|
82
|
-
this.lastSeenX = null;
|
|
83
|
-
this.lastSeenY = null;
|
|
84
|
-
this.lastSeenRoom = null;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
this.emitProgress(state, ctx);
|
|
88
|
-
return this.patrolDecision(state, ctx);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
private patrolDecision(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
92
|
-
let room = this.patrol.nextRoom(ctx);
|
|
93
|
-
if (!room) {
|
|
94
|
-
setStrategyIntent(ctx, {
|
|
95
|
-
activity: 'waiting',
|
|
96
|
-
summary: `暂无可巡逻房间,正在等待${this.targetLabel(ctx)}出现。`,
|
|
97
|
-
targetPlayer: this.targetLabel(ctx),
|
|
98
|
-
});
|
|
99
|
-
return [];
|
|
100
|
-
}
|
|
101
|
-
if (dist(state.you.x, state.you.y, room.x, room.y) <= PATROL_REACHED_DISTANCE) {
|
|
102
|
-
this.patrol.advance(ctx);
|
|
103
|
-
const next = this.patrol.nextRoom(ctx);
|
|
104
|
-
if (next) room = next;
|
|
105
|
-
}
|
|
106
|
-
return [strategyDecision(
|
|
107
|
-
Action.move({ x: room.x, y: room.y }),
|
|
108
|
-
{
|
|
109
|
-
...patrolStrategyIntent(room, `巡逻寻找${this.targetLabel(ctx)}`),
|
|
110
|
-
targetPlayer: this.targetLabel(ctx),
|
|
111
|
-
},
|
|
112
|
-
)];
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
private targetLabel(ctx: StrategyContext): string {
|
|
116
|
-
const name = ctx.playerNamesBySeat[String(this.target)];
|
|
117
|
-
return name ? `${this.target}号${name}` : `${this.target}号`;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
private emitProgress(state: GameState, ctx: StrategyContext): void {
|
|
121
|
-
const now = Date.now();
|
|
122
|
-
if (now - ctx.lastProgressNotifyAt < PROGRESS_INTERVAL_MS) return;
|
|
123
|
-
ctx.lastProgressNotifyAt = now;
|
|
124
|
-
|
|
125
|
-
const room = state.you.room ?? '未知';
|
|
126
|
-
if (this.foundNotified) {
|
|
127
|
-
const t = nearestVisibleTarget(state, ctx, [this.target]);
|
|
128
|
-
const d = t ? (t.distance ?? dist(state.you.x, state.you.y, t.x, t.y)) : 0;
|
|
129
|
-
ctx.notifications.push(`[进度] 当前在${room},正在跟踪目标${this.target},距离${Math.round(d)}px。`);
|
|
130
|
-
} else if (this.lastSeenX != null) {
|
|
131
|
-
ctx.notifications.push(`[进度] 当前在${room},跟丢了,正赶往${this.target}最后出现的位置。`);
|
|
132
|
-
} else {
|
|
133
|
-
ctx.notifications.push(`[进度] 当前在${room},正在巡逻寻找${this.target}。`);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { GameState, PlayerInfo } from '../../sdk/types.js';
|
|
2
|
-
import { dist, hasReachedRoomTarget, resolveRoom, roomAwayFromPlayers } from '../game-utils.js';
|
|
3
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
4
|
-
import { Goal } from './goal.js';
|
|
5
|
-
import { MoveRoomGoal } from './move-room-goal.js';
|
|
6
|
-
|
|
7
|
-
export type FleePlayerResolver = (state: GameState, ctx: StrategyContext) => PlayerInfo[];
|
|
8
|
-
|
|
9
|
-
export interface FleePlayersGoalOptions {
|
|
10
|
-
emitProgress?: boolean;
|
|
11
|
-
finishWhenEmpty?: boolean;
|
|
12
|
-
stopOnPlayer?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class FleePlayersGoal extends Goal {
|
|
16
|
-
constructor(
|
|
17
|
-
public readonly key: string,
|
|
18
|
-
private readonly resolvePlayers: FleePlayerResolver,
|
|
19
|
-
private readonly options: FleePlayersGoalOptions = {},
|
|
20
|
-
) {
|
|
21
|
-
super();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
25
|
-
const players = this.resolvePlayers(state, ctx);
|
|
26
|
-
const worker = this.subGoal;
|
|
27
|
-
if (worker instanceof MoveRoomGoal && this.canKeepTarget(worker, state, ctx, players)) return [];
|
|
28
|
-
|
|
29
|
-
const room = roomAwayFromPlayers(state, ctx, players);
|
|
30
|
-
if (!room) return [];
|
|
31
|
-
|
|
32
|
-
if (!(worker instanceof MoveRoomGoal) || worker.room !== room.name) {
|
|
33
|
-
if (this.subGoal) this.removeSubGoal();
|
|
34
|
-
const names = players.map(player => player.seat != null ? `${player.seat}号${player.name}` : player.name).join('、');
|
|
35
|
-
this.setSubGoal(new MoveRoomGoal(room.name, hasReachedRoomTarget, {
|
|
36
|
-
emitProgress: this.options.emitProgress ?? false,
|
|
37
|
-
stopOnPlayer: this.options.stopOnPlayer ?? false,
|
|
38
|
-
purpose: names ? `躲避${names}` : '躲避附近玩家',
|
|
39
|
-
}), 0.2);
|
|
40
|
-
}
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
isFinish(state: GameState, ctx: StrategyContext): boolean {
|
|
45
|
-
return (this.options.finishWhenEmpty ?? true) && this.resolvePlayers(state, ctx).length === 0;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
private canKeepTarget(worker: MoveRoomGoal, state: GameState, ctx: StrategyContext, players: PlayerInfo[]): boolean {
|
|
49
|
-
const target = resolveRoom(worker.room, ctx);
|
|
50
|
-
if (!target) return false;
|
|
51
|
-
if (hasReachedRoomTarget(state, target)) return true;
|
|
52
|
-
if (ctx.blockedMoveTarget && dist(target.x, target.y, ctx.blockedMoveTarget.x, ctx.blockedMoveTarget.y) <= 10) return false;
|
|
53
|
-
return !players.some(player => player.room?.toLowerCase() === target.name.toLowerCase());
|
|
54
|
-
}
|
|
55
|
-
}
|