@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,130 +0,0 @@
|
|
|
1
|
-
import type { GameState, PlayerInfo, Position } from '../../sdk/types.js';
|
|
2
|
-
import { Action } from '../../sdk/action.js';
|
|
3
|
-
import {
|
|
4
|
-
dist,
|
|
5
|
-
nearestPlayerByDistance,
|
|
6
|
-
playerStrategyIntent,
|
|
7
|
-
setStrategyIntent,
|
|
8
|
-
strategyDecision,
|
|
9
|
-
strategyPlayerLabel,
|
|
10
|
-
} from '../game-utils.js';
|
|
11
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
12
|
-
import { AnchorLinger } from './anchor-linger.js';
|
|
13
|
-
import { Goal } from './goal.js';
|
|
14
|
-
|
|
15
|
-
/** 同伴移动时跟到这么近(px)就停手,不再补发移动,免得贴身打转;停住后改在锚点附近 40-100 游走。 */
|
|
16
|
-
const FOLLOW_STOP = 80;
|
|
17
|
-
/** 同伴本帧位置离上次记下的停留点小于这么多(px)就算「没动」。走路一步上百 px,远大于此。 */
|
|
18
|
-
const STILL_EPS = 30;
|
|
19
|
-
/** 同伴「没动」持续这么久(ms)就当作在做任务,切到在其停留点假装做任务(≈ 一个轮询间隔的余量)。 */
|
|
20
|
-
const PARKED_MS = 1500;
|
|
21
|
-
/** 距上次 tick 超过这么久(ms,被开会/高优先级行为打断)就重置跟踪,避免拿陈旧停留点误判同伴已停住。 */
|
|
22
|
-
const STALE_MS = 5000;
|
|
23
|
-
/** 同伴停留点离某个真实任务站点这么近(px)就以站点为晃荡中心,否则就地在停留点附近晃。 */
|
|
24
|
-
const TASK_ANCHOR_RANGE = 100;
|
|
25
|
-
|
|
26
|
-
type CompanionResolver = (state: GameState, ctx: StrategyContext) => PlayerInfo[];
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* 跟随可信同伴:同伴走动时跟在其身后,同伴停下(推断在做任务)时就在其停留点附近 40-100 px 游走
|
|
30
|
-
* 「假装做任务」,融入人群躲投票——天堂鱼无刀、不做任务,靠贴着可信同伴显得正常。无法直接观测他人
|
|
31
|
-
* 是否在做任务(PlayerInfo 不含 doing_task),故以「同伴位置连续 PARKED_MS 没动」作为代理判据。
|
|
32
|
-
* 任务点游走复用 AnchorLinger(与贴尸 LingerCorpseGoal 同一套粘性游走)。优先级由调用方(天堂鱼
|
|
33
|
-
* tick 的 if 链顺序)控制:排在贴尸游走之后,故跟随天然低于在尸体上晃荡。
|
|
34
|
-
*/
|
|
35
|
-
export class FollowCompanionGoal extends Goal {
|
|
36
|
-
private readonly wander = new AnchorLinger();
|
|
37
|
-
private mateKey = '';
|
|
38
|
-
private mateAnchor: Position | null = null;
|
|
39
|
-
private stillSince = 0;
|
|
40
|
-
private lastTickAt = 0;
|
|
41
|
-
|
|
42
|
-
constructor(
|
|
43
|
-
private readonly resolveCompanions: CompanionResolver,
|
|
44
|
-
private readonly resolveAvoid?: CompanionResolver,
|
|
45
|
-
) {
|
|
46
|
-
super();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
50
|
-
const now = Date.now();
|
|
51
|
-
const stale = now - this.lastTickAt > STALE_MS;
|
|
52
|
-
this.lastTickAt = now;
|
|
53
|
-
|
|
54
|
-
const mate = nearestPlayerByDistance(state, this.resolveCompanions(state, ctx));
|
|
55
|
-
if (!mate) {
|
|
56
|
-
this.resetTracking();
|
|
57
|
-
return [];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const key = this.mateKeyOf(mate);
|
|
61
|
-
const moved = this.mateAnchor == null
|
|
62
|
-
|| dist(mate.x, mate.y, this.mateAnchor.x, this.mateAnchor.y) > STILL_EPS;
|
|
63
|
-
if (stale || this.mateKey !== key || moved) {
|
|
64
|
-
this.mateKey = key;
|
|
65
|
-
this.mateAnchor = { x: mate.x, y: mate.y };
|
|
66
|
-
this.stillSince = now;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (now - this.stillSince >= PARKED_MS) {
|
|
70
|
-
// 同伴停住够久(多半在做任务):优先以其附近真实任务站点为晃荡中心——更像在做任务、坐标也比同伴
|
|
71
|
-
// 上报位置稳;附近没有任务站点(如只是站着闲聊)就退回在停留点附近晃。旁边有要避开的人就偏到对侧。
|
|
72
|
-
const avoid = this.resolveAvoid?.(state, ctx) ?? [];
|
|
73
|
-
const spot = this.taskAnchorNear(ctx, this.mateAnchor!)
|
|
74
|
-
?? { x: this.mateAnchor!.x, y: this.mateAnchor!.y, key: `mate:${key}` };
|
|
75
|
-
return [strategyDecision(Action.move(this.wander.step(state, spot.key, spot, avoid)), {
|
|
76
|
-
activity: 'moving',
|
|
77
|
-
summary: `正在${mate.room || state.you.room || '当前位置'}陪同${strategyPlayerLabel(mate)}并伪装做任务。`,
|
|
78
|
-
...(mate.room ? { room: mate.room } : {}),
|
|
79
|
-
targetPlayer: mate.name,
|
|
80
|
-
})];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// 同伴在移动:跟上去,跟到 FOLLOW_STOP 内就不再补发移动。
|
|
84
|
-
this.wander.reset();
|
|
85
|
-
const d = mate.distance ?? dist(state.you.x, state.you.y, mate.x, mate.y);
|
|
86
|
-
if (d > FOLLOW_STOP) {
|
|
87
|
-
return [strategyDecision(
|
|
88
|
-
Action.move({ x: mate.x, y: mate.y }),
|
|
89
|
-
playerStrategyIntent(mate, '跟随', 'moving'),
|
|
90
|
-
)];
|
|
91
|
-
}
|
|
92
|
-
setStrategyIntent(ctx, {
|
|
93
|
-
activity: 'waiting',
|
|
94
|
-
summary: `正在${mate.room || state.you.room || '当前位置'}陪同${strategyPlayerLabel(mate)}。`,
|
|
95
|
-
...(mate.room ? { room: mate.room } : {}),
|
|
96
|
-
targetPlayer: mate.name,
|
|
97
|
-
});
|
|
98
|
-
return [];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
isFinish(state: GameState, ctx: StrategyContext): boolean {
|
|
102
|
-
return this.resolveCompanions(state, ctx).length === 0;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
private mateKeyOf(mate: PlayerInfo): string {
|
|
106
|
-
return mate.name || (mate.seat != null ? String(mate.seat) : `${Math.round(mate.x)},${Math.round(mate.y)}`);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/** 同伴停留点附近最近的真实任务站点(蟹的破坏点除外),带稳定 key 供 AnchorLinger 粘住游走。 */
|
|
110
|
-
private taskAnchorNear(ctx: StrategyContext, near: Position): { x: number; y: number; key: string } | null {
|
|
111
|
-
let best: { x: number; y: number; key: string } | null = null;
|
|
112
|
-
let bestD = TASK_ANCHOR_RANGE;
|
|
113
|
-
for (const t of ctx.taskLocations ?? []) {
|
|
114
|
-
if (t.faction === 'crab') continue;
|
|
115
|
-
const d = dist(near.x, near.y, t.x, t.y);
|
|
116
|
-
if (d <= bestD) {
|
|
117
|
-
best = { x: t.x, y: t.y, key: `task:${t.name}` };
|
|
118
|
-
bestD = d;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return best;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
private resetTracking(): void {
|
|
125
|
-
this.wander.reset();
|
|
126
|
-
this.mateKey = '';
|
|
127
|
-
this.mateAnchor = null;
|
|
128
|
-
this.stillSince = 0;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { GameState } from '../../sdk/types.js';
|
|
2
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
3
|
-
import { Goal } from './goal.js';
|
|
4
|
-
|
|
5
|
-
export class GoalManager {
|
|
6
|
-
private top: Goal | null = null;
|
|
7
|
-
|
|
8
|
-
setTop(goal: Goal): void {
|
|
9
|
-
this.top = goal;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
getTop(): Goal | null {
|
|
13
|
-
return this.top;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
clear(): void {
|
|
17
|
-
this.top = null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
21
|
-
const decisions: BehaviorDecision[] = [];
|
|
22
|
-
let parent: Goal | null = null;
|
|
23
|
-
let node: Goal | null = this.top;
|
|
24
|
-
|
|
25
|
-
while (node !== null) {
|
|
26
|
-
if (node.isFinish(state, ctx)) {
|
|
27
|
-
if (parent === null) {
|
|
28
|
-
this.top = null;
|
|
29
|
-
} else {
|
|
30
|
-
parent.removeSubGoal();
|
|
31
|
-
}
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
decisions.push(...node.tick(state, ctx));
|
|
35
|
-
parent = node;
|
|
36
|
-
node = node.subGoal;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return decisions;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { GameState } from '../../sdk/types.js';
|
|
2
|
-
import type { BehaviorDecision, CustomModule, Strategy, StrategyContext } from '../types.js';
|
|
3
|
-
import type { Goal } from './goal.js';
|
|
4
|
-
import { GoalManager } from './goal-manager.js';
|
|
5
|
-
|
|
6
|
-
export interface GoalRootStrategyOptions {
|
|
7
|
-
resetOnMeetingResume?: boolean;
|
|
8
|
-
customModules?: CustomModule[];
|
|
9
|
-
onUpdateRole?: (role: string) => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class GoalRootStrategy implements Strategy {
|
|
13
|
-
readonly name: string;
|
|
14
|
-
private readonly mgr = new GoalManager();
|
|
15
|
-
private readonly makeTop: () => Goal;
|
|
16
|
-
private readonly resetOnMeetingResume: boolean;
|
|
17
|
-
private readonly modules: CustomModule[];
|
|
18
|
-
private readonly onUpdateRole?: (role: string) => void;
|
|
19
|
-
|
|
20
|
-
constructor(name: string, makeTop: () => Goal, options?: GoalRootStrategyOptions) {
|
|
21
|
-
this.name = name;
|
|
22
|
-
this.makeTop = makeTop;
|
|
23
|
-
this.resetOnMeetingResume = options?.resetOnMeetingResume ?? true;
|
|
24
|
-
this.modules = options?.customModules ?? [];
|
|
25
|
-
this.onUpdateRole = options?.onUpdateRole;
|
|
26
|
-
this.mgr.setTop(makeTop());
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
decide(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
30
|
-
if (this.mgr.getTop() === null) this.mgr.setTop(this.makeTop());
|
|
31
|
-
return this.mgr.tick(state, ctx);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
onMeetingResume(): void {
|
|
35
|
-
if (this.resetOnMeetingResume) {
|
|
36
|
-
this.mgr.setTop(this.makeTop());
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
this.mgr.getTop()?.onMeetingResume();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
customModules(): CustomModule[] {
|
|
43
|
-
return this.modules;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
updateRole(role: string): void {
|
|
47
|
-
this.onUpdateRole?.(role);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { GameState } from '../../sdk/types.js';
|
|
2
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
3
|
-
|
|
4
|
-
export abstract class Goal {
|
|
5
|
-
subGoal: Goal | null = null;
|
|
6
|
-
priority = 0;
|
|
7
|
-
|
|
8
|
-
abstract tick(state: GameState, ctx: StrategyContext): BehaviorDecision[];
|
|
9
|
-
|
|
10
|
-
isFinish(_state: GameState, _ctx: StrategyContext): boolean {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
onMeetingResume(): void {}
|
|
15
|
-
|
|
16
|
-
setSubGoal(child: Goal, priority: number): boolean {
|
|
17
|
-
if (this.subGoal !== null && this.subGoal.priority >= priority) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
child.priority = priority;
|
|
21
|
-
this.subGoal = child;
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
removeSubGoal(): void {
|
|
26
|
-
this.subGoal = null;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import type { GameState, PlayerInfo, Position } from '../../sdk/types.js';
|
|
2
|
-
import { Action } from '../../sdk/action.js';
|
|
3
|
-
import {
|
|
4
|
-
canUseKill,
|
|
5
|
-
dist,
|
|
6
|
-
killCommitRange,
|
|
7
|
-
nonTeammatesVisible,
|
|
8
|
-
PROGRESS_INTERVAL_MS,
|
|
9
|
-
setStrategyIntent,
|
|
10
|
-
SHRIMP_KILL_RANGE,
|
|
11
|
-
strategyDecision,
|
|
12
|
-
strategyPlayerLabel,
|
|
13
|
-
} from '../game-utils.js';
|
|
14
|
-
import { nearestSafeHideSpot, type HideSpot } from '../hide-spots.js';
|
|
15
|
-
import { planEscape, type EscapeOptions } from '../pathfind/escape-planner.js';
|
|
16
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
17
|
-
import { Goal } from './goal.js';
|
|
18
|
-
import { KeepAwayGoal } from './keep-away-goal.js';
|
|
19
|
-
|
|
20
|
-
const SUB_PRIORITY = 0.5;
|
|
21
|
-
const FLEE_KEY = 'hide-flee';
|
|
22
|
-
/** 走到躲藏点这个距离内就算到位,原地潜伏不动。 */
|
|
23
|
-
const REACHED_DISTANCE = 40;
|
|
24
|
-
/** 威胁离开视野后,其位置仍在选点时被回避这么久——逃完不会立刻又选回威胁刚待过的点。 */
|
|
25
|
-
const THREAT_MEMORY_MS = 5_000;
|
|
26
|
-
/**
|
|
27
|
-
* 「无处可逃」用的逃跑推演参数:与 KeepAwayGoal 同款保守模型(killRange=160,按枪虾/武士虾兜底)。
|
|
28
|
-
* 理由是「连我自己用来逃跑的同一套推演都判定必被追上,逃就没意义,才出刀自保」,判据自洽。
|
|
29
|
-
*/
|
|
30
|
-
const ESCAPE_OPTS: EscapeOptions = { killRange: SHRIMP_KILL_RANGE, steps: 7, beamWidth: 8, directions: 16, fieldRadius: 900 };
|
|
31
|
-
|
|
32
|
-
type ProgressTier = 'flee' | 'relocate' | 'hidden';
|
|
33
|
-
type ThreatPointResolver = () => Position[];
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 躲藏点劳作循环:与 SafeTaskOrPatrolGoal 同构——planSpot 边逃边预重算(粘性、威胁硬排除),
|
|
37
|
-
* tick 执行(走向躲藏点;到位则原地不动)。没有可用点时不动。
|
|
38
|
-
*/
|
|
39
|
-
class HideSpotGoal extends Goal {
|
|
40
|
-
private current: HideSpot | null = null;
|
|
41
|
-
|
|
42
|
-
constructor(private readonly threatPoints: ThreatPointResolver) {
|
|
43
|
-
super();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
get currentSpot(): HideSpot | null {
|
|
47
|
-
return this.current;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
reset(): void {
|
|
51
|
-
this.current = null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** 重算并记住安全躲藏点,不发移动指令(逃跑期间可安全调用)。 */
|
|
55
|
-
planSpot(state: GameState, ctx: StrategyContext): HideSpot | null {
|
|
56
|
-
const spot = nearestSafeHideSpot(
|
|
57
|
-
{ x: state.you.x, y: state.you.y },
|
|
58
|
-
this.threatPoints(),
|
|
59
|
-
{
|
|
60
|
-
stickyTo: this.current,
|
|
61
|
-
blockedTarget: ctx.blockedMoveTarget,
|
|
62
|
-
routeEvidence: ctx.routeEvidence,
|
|
63
|
-
},
|
|
64
|
-
);
|
|
65
|
-
this.current = spot;
|
|
66
|
-
return spot;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
70
|
-
const spot = this.planSpot(state, ctx);
|
|
71
|
-
if (!spot) {
|
|
72
|
-
setStrategyIntent(ctx, {
|
|
73
|
-
activity: 'waiting',
|
|
74
|
-
summary: `暂无安全躲藏点,正在${state.you.room || '当前位置'}观察。`,
|
|
75
|
-
...(state.you.room ? { room: state.you.room } : {}),
|
|
76
|
-
});
|
|
77
|
-
return [];
|
|
78
|
-
}
|
|
79
|
-
if (dist(state.you.x, state.you.y, spot.x, spot.y) <= REACHED_DISTANCE) {
|
|
80
|
-
setStrategyIntent(ctx, {
|
|
81
|
-
activity: 'waiting',
|
|
82
|
-
summary: `正在${spot.room}潜伏。`,
|
|
83
|
-
room: spot.room,
|
|
84
|
-
});
|
|
85
|
-
return [];
|
|
86
|
-
}
|
|
87
|
-
return [strategyDecision(
|
|
88
|
-
Action.move({ x: spot.x, y: spot.y }).withThinking(`前往躲藏点${spot.room}潜伏`),
|
|
89
|
-
{
|
|
90
|
-
activity: 'moving',
|
|
91
|
-
summary: `正在前往${spot.room}潜伏。`,
|
|
92
|
-
room: spot.room,
|
|
93
|
-
},
|
|
94
|
-
)];
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* 躲藏策略顶层:在离线算好的藏身角落里选测地最近且不挨威胁的一个潜伏不动,直到有人进入视野。
|
|
100
|
-
* 有人来就 ① 用 KeepAwayGoal 保持距离甩开,② 边逃边重算排除该威胁的新躲藏点——与 shrimp-memory 的
|
|
101
|
-
* 「躲人 + 重选任务」同构,只是把任务换成躲藏点。蟹不躲队友(威胁统一用 nonTeammatesVisible 过滤队友)。
|
|
102
|
-
*
|
|
103
|
-
* killWhenCornered:被**单个**对手逼进出刀距离、且 planEscape 判定无路可逃时才出刀自保。
|
|
104
|
-
* null = 按角色默认:蟹 / 章鱼开,武士虾 / 枪虾(及无刀角色)关。
|
|
105
|
-
*/
|
|
106
|
-
export class HideTop extends Goal {
|
|
107
|
-
private readonly spotGoal = new HideSpotGoal(() => this.threatPointsFor());
|
|
108
|
-
private readonly recentThreats = new Map<string, { x: number; y: number; until: number }>();
|
|
109
|
-
|
|
110
|
-
constructor(private readonly killWhenCornered: boolean | null = null) {
|
|
111
|
-
super();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
onMeetingResume(): void {
|
|
115
|
-
this.spotGoal.reset();
|
|
116
|
-
this.recentThreats.clear();
|
|
117
|
-
if (this.subGoal) this.removeSubGoal();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
121
|
-
const visible = nonTeammatesVisible(state, ctx);
|
|
122
|
-
this.rememberThreats(visible);
|
|
123
|
-
|
|
124
|
-
// ── 被单个对手逼到死角且刀好 → 出刀自保(按角色 / 参数开关) ──
|
|
125
|
-
if (this.killEnabled(state) && canUseKill(state)) {
|
|
126
|
-
const victim = this.corneredVictim(state, visible);
|
|
127
|
-
if (victim) {
|
|
128
|
-
if (this.subGoal) this.removeSubGoal();
|
|
129
|
-
if (victim.seat == null || victim.seat <= 0) return [];
|
|
130
|
-
ctx.notifications.push(`被${victim.name}逼到无处可逃,出刀自保!`);
|
|
131
|
-
return [strategyDecision(
|
|
132
|
-
Action.kill(victim.seat).withThinking(`被${victim.name}逼进出刀距离又逃不掉,先下手自保。`),
|
|
133
|
-
{
|
|
134
|
-
activity: 'acting',
|
|
135
|
-
summary: `被${strategyPlayerLabel(victim)}逼到无处可逃,正在出刀自保。`,
|
|
136
|
-
...(victim.room ? { room: victim.room } : {}),
|
|
137
|
-
targetPlayer: victim.name,
|
|
138
|
-
},
|
|
139
|
-
)];
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// ── 视野里有人 → 保持距离甩开 + 边逃边重算安全躲藏点 ──
|
|
144
|
-
if (visible.length > 0) {
|
|
145
|
-
this.spotGoal.planSpot(state, ctx); // 重算(排除威胁),逃完落到新点
|
|
146
|
-
this.setFlee();
|
|
147
|
-
setStrategyIntent(ctx, {
|
|
148
|
-
activity: 'moving',
|
|
149
|
-
summary: `正在${state.you.room || '当前位置'}躲避${visible.map(strategyPlayerLabel).join('、')},寻找新的藏身处。`,
|
|
150
|
-
...(state.you.room ? { room: state.you.room } : {}),
|
|
151
|
-
targetPlayer: visible[0].name,
|
|
152
|
-
});
|
|
153
|
-
this.emitProgress(state, ctx, visible, 'flee');
|
|
154
|
-
return [];
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// ── 无人 → 走向最近安全躲藏点并潜伏 ──
|
|
158
|
-
if (this.subGoal) this.removeSubGoal();
|
|
159
|
-
const decisions = this.spotGoal.tick(state, ctx);
|
|
160
|
-
this.emitProgress(state, ctx, visible, decisions.length === 0 ? 'hidden' : 'relocate');
|
|
161
|
-
return decisions;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
private killEnabled(state: GameState): boolean {
|
|
165
|
-
if (!roleHasKnife(state)) return false; // 无刀角色(普通虾)永不出刀,传 kill 参数也不行
|
|
166
|
-
return this.killWhenCornered ?? defaultKillWhenCornered(state);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/** 单个对手、进入出刀距离、且 planEscape 判定必被追上 → 返回该对手,否则 null。 */
|
|
170
|
-
private corneredVictim(state: GameState, visible: PlayerInfo[]): PlayerInfo | null {
|
|
171
|
-
// 只在单个追兵时自保:2 人以上当众动手仍会被另一人举报,逃跑(推演偏悲观,真人有视野盲区)反而更优。
|
|
172
|
-
if (visible.length !== 1) return null;
|
|
173
|
-
const target = visible[0];
|
|
174
|
-
const d = target.distance ?? dist(state.you.x, state.you.y, target.x, target.y);
|
|
175
|
-
if (d > killCommitRange(state.you.role)) return null;
|
|
176
|
-
const plan = planEscape({ x: state.you.x, y: state.you.y }, [{ x: target.x, y: target.y }], ESCAPE_OPTS);
|
|
177
|
-
return plan.caught ? target : null;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
private setFlee(): void {
|
|
181
|
-
const worker = this.subGoal;
|
|
182
|
-
if (worker instanceof KeepAwayGoal && worker.key === FLEE_KEY) return;
|
|
183
|
-
if (this.subGoal) this.removeSubGoal();
|
|
184
|
-
this.setSubGoal(new KeepAwayGoal(FLEE_KEY, (s, c) => nonTeammatesVisible(s, c), {
|
|
185
|
-
threatRadius: Infinity,
|
|
186
|
-
noun: '靠近的人',
|
|
187
|
-
}), SUB_PRIORITY);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/** 记住近期见过的非队友位置(按名字去重 + TTL),供威胁离开视野后选点继续回避。 */
|
|
191
|
-
private rememberThreats(visible: PlayerInfo[]): void {
|
|
192
|
-
const now = Date.now();
|
|
193
|
-
for (const p of visible) {
|
|
194
|
-
const key = p.name || String(p.seat ?? '');
|
|
195
|
-
if (key) this.recentThreats.set(key, { x: p.x, y: p.y, until: now + THREAT_MEMORY_MS });
|
|
196
|
-
}
|
|
197
|
-
for (const [key, v] of this.recentThreats) if (v.until <= now) this.recentThreats.delete(key);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
private threatPointsFor(): Position[] {
|
|
201
|
-
const now = Date.now();
|
|
202
|
-
const out: Position[] = [];
|
|
203
|
-
for (const v of this.recentThreats.values()) if (v.until > now) out.push({ x: v.x, y: v.y });
|
|
204
|
-
return out;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
private emitProgress(state: GameState, ctx: StrategyContext, visible: PlayerInfo[], tier: ProgressTier): void {
|
|
208
|
-
const now = Date.now();
|
|
209
|
-
if (now - ctx.lastProgressNotifyAt < PROGRESS_INTERVAL_MS) return;
|
|
210
|
-
ctx.lastProgressNotifyAt = now;
|
|
211
|
-
|
|
212
|
-
const room = state.you.room ?? '未知';
|
|
213
|
-
const spot = this.spotGoal.currentSpot;
|
|
214
|
-
let msg = `[进度] 当前在${room}`;
|
|
215
|
-
if (tier === 'flee') {
|
|
216
|
-
const names = visible.map(p => p.name).join('、');
|
|
217
|
-
msg += `,${names}靠近,保持距离甩开${spot ? `,改藏到${spot.room}` : ''}。`;
|
|
218
|
-
} else if (tier === 'relocate') {
|
|
219
|
-
msg += spot ? `,前往躲藏点${spot.room}潜伏。` : ',寻找躲藏点。';
|
|
220
|
-
} else {
|
|
221
|
-
msg += spot ? `,已在${spot.room}潜伏,按兵不动。` : ',附近无可用躲藏点,原地待命。';
|
|
222
|
-
}
|
|
223
|
-
ctx.notifications.push(msg);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/** 是否带刀(有击杀能力):蟹 / 章鱼 / 武士虾 / 枪虾。普通虾无刀。 */
|
|
228
|
-
function roleHasKnife(state: GameState): boolean {
|
|
229
|
-
const role = state.you.role ?? '';
|
|
230
|
-
const faction = state.you.faction ?? '';
|
|
231
|
-
return faction === 'crab' || role.includes('crab') || role.includes('octopus')
|
|
232
|
-
|| role === 'shrimp_warrior' || role === 'shrimp_pistol';
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/** 角色默认是否「死角自保出刀」:蟹 / 章鱼开;武士虾 / 枪虾及其余关。 */
|
|
236
|
-
function defaultKillWhenCornered(state: GameState): boolean {
|
|
237
|
-
const role = state.you.role ?? '';
|
|
238
|
-
const faction = state.you.faction ?? '';
|
|
239
|
-
return faction === 'crab' || role.includes('crab') || role.includes('octopus');
|
|
240
|
-
}
|