@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,192 +0,0 @@
|
|
|
1
|
-
import type { GameState } from '../../sdk/types.js';
|
|
2
|
-
import { Action } from '../../sdk/action.js';
|
|
3
|
-
import {
|
|
4
|
-
dist,
|
|
5
|
-
firstAvailableTask,
|
|
6
|
-
isTargetAlive,
|
|
7
|
-
matchesTarget,
|
|
8
|
-
PROGRESS_INTERVAL_MS,
|
|
9
|
-
reportCorpseDecision,
|
|
10
|
-
setStrategyIntent,
|
|
11
|
-
strategyDecision,
|
|
12
|
-
strategyPlayerLabel,
|
|
13
|
-
taskMoveDecision,
|
|
14
|
-
} from '../game-utils.js';
|
|
15
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
16
|
-
import { Goal } from './goal.js';
|
|
17
|
-
|
|
18
|
-
export interface SocialTarget {
|
|
19
|
-
target: number;
|
|
20
|
-
greeting: string | null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
interface SocialTargetState {
|
|
24
|
-
greetingSent: boolean;
|
|
25
|
-
lastSpeechTime: number;
|
|
26
|
-
silenceNotified: boolean;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const GREETING_DISTANCE = 200;
|
|
30
|
-
const SILENCE_TIMEOUT_MS = 10_000;
|
|
31
|
-
|
|
32
|
-
export class SocialTaskTop extends Goal {
|
|
33
|
-
private readonly socialTargets: SocialTarget[];
|
|
34
|
-
private readonly targetStates = new Map<number, SocialTargetState>();
|
|
35
|
-
|
|
36
|
-
constructor(socialTargets: SocialTarget[]) {
|
|
37
|
-
super();
|
|
38
|
-
this.socialTargets = socialTargets;
|
|
39
|
-
for (const st of socialTargets) {
|
|
40
|
-
this.targetStates.set(st.target, {
|
|
41
|
-
greetingSent: false,
|
|
42
|
-
lastSpeechTime: 0,
|
|
43
|
-
silenceNotified: false,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
49
|
-
const decisions: BehaviorDecision[] = [];
|
|
50
|
-
const now = Date.now();
|
|
51
|
-
|
|
52
|
-
const corpseDecision = reportCorpseDecision(state, ctx);
|
|
53
|
-
if (corpseDecision) {
|
|
54
|
-
this.emitProgress(state, ctx);
|
|
55
|
-
return [corpseDecision];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
for (const st of this.socialTargets) {
|
|
59
|
-
if (!isTargetAlive(state, st.target, ctx)) continue;
|
|
60
|
-
|
|
61
|
-
const visiblePlayer = state.players.find(p => matchesTarget(st.target, p, ctx));
|
|
62
|
-
if (!visiblePlayer) continue;
|
|
63
|
-
|
|
64
|
-
const targetState = this.targetStates.get(st.target)!;
|
|
65
|
-
const d = visiblePlayer.distance ?? dist(state.you.x, state.you.y, visiblePlayer.x, visiblePlayer.y);
|
|
66
|
-
const targetName = visiblePlayer.name || `${st.target}号`;
|
|
67
|
-
const targetLabel = strategyPlayerLabel(visiblePlayer);
|
|
68
|
-
const targetRoom = visiblePlayer.room || state.you.room || '当前位置';
|
|
69
|
-
|
|
70
|
-
const targetSpeechEvent = (state.new_events ?? []).find(
|
|
71
|
-
evt => evt.type === 'wandering_speech' && evt.actor_name === visiblePlayer.name,
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
if (targetSpeechEvent) {
|
|
75
|
-
targetState.lastSpeechTime = now;
|
|
76
|
-
targetState.silenceNotified = false;
|
|
77
|
-
|
|
78
|
-
const speechText = targetSpeechEvent.text ?? targetSpeechEvent.content ?? '';
|
|
79
|
-
const seatNum = visiblePlayer.seat ?? st.target;
|
|
80
|
-
ctx.notifications.push(`${seatNum}号跟我说话了:「${speechText}」`);
|
|
81
|
-
setStrategyIntent(ctx, {
|
|
82
|
-
activity: 'waiting',
|
|
83
|
-
summary: `正在${targetRoom}与${targetLabel}交流,等待下一步反应。`,
|
|
84
|
-
...(visiblePlayer.room ? { room: visiblePlayer.room } : {}),
|
|
85
|
-
targetPlayer: targetName,
|
|
86
|
-
});
|
|
87
|
-
this.emitProgress(state, ctx);
|
|
88
|
-
return decisions;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (st.greeting != null && !targetState.greetingSent) {
|
|
92
|
-
if (d > GREETING_DISTANCE) {
|
|
93
|
-
if (state.you.doing_task) {
|
|
94
|
-
this.emitProgress(state, ctx);
|
|
95
|
-
return decisions;
|
|
96
|
-
}
|
|
97
|
-
decisions.push(strategyDecision(Action.move({ x: visiblePlayer.x, y: visiblePlayer.y }), {
|
|
98
|
-
activity: 'moving',
|
|
99
|
-
summary: `正在前往${targetRoom}接近${targetLabel},准备交流。`,
|
|
100
|
-
...(visiblePlayer.room ? { room: visiblePlayer.room } : {}),
|
|
101
|
-
targetPlayer: targetName,
|
|
102
|
-
}));
|
|
103
|
-
this.emitProgress(state, ctx);
|
|
104
|
-
return decisions;
|
|
105
|
-
}
|
|
106
|
-
decisions.push(strategyDecision(Action.speech(st.greeting), {
|
|
107
|
-
activity: 'acting',
|
|
108
|
-
summary: `正在${targetRoom}向${targetLabel}打招呼。`,
|
|
109
|
-
...(visiblePlayer.room ? { room: visiblePlayer.room } : {}),
|
|
110
|
-
targetPlayer: targetName,
|
|
111
|
-
}));
|
|
112
|
-
targetState.greetingSent = true;
|
|
113
|
-
targetState.lastSpeechTime = now;
|
|
114
|
-
targetState.silenceNotified = false;
|
|
115
|
-
const seatNum = visiblePlayer.seat ?? st.target;
|
|
116
|
-
ctx.notifications.push(`已向${seatNum}号打招呼:「${st.greeting}」`);
|
|
117
|
-
this.emitProgress(state, ctx);
|
|
118
|
-
return decisions;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (targetState.greetingSent && targetState.lastSpeechTime > 0) {
|
|
122
|
-
if (now - targetState.lastSpeechTime >= SILENCE_TIMEOUT_MS) {
|
|
123
|
-
if (!targetState.silenceNotified) {
|
|
124
|
-
targetState.silenceNotified = true;
|
|
125
|
-
const seatNum = visiblePlayer.seat ?? st.target;
|
|
126
|
-
ctx.notifications.push(`${seatNum}号没回话,放弃等待,去做任务。`);
|
|
127
|
-
}
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (targetState.greetingSent) {
|
|
133
|
-
setStrategyIntent(ctx, {
|
|
134
|
-
activity: 'waiting',
|
|
135
|
-
summary: `正在${targetRoom}等待${targetLabel}回复。`,
|
|
136
|
-
...(visiblePlayer.room ? { room: visiblePlayer.room } : {}),
|
|
137
|
-
targetPlayer: targetName,
|
|
138
|
-
});
|
|
139
|
-
this.emitProgress(state, ctx);
|
|
140
|
-
return decisions;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const taskDecision = this.tryTask(state, ctx);
|
|
146
|
-
if (taskDecision) decisions.push(taskDecision);
|
|
147
|
-
else if (!state.you.doing_task) {
|
|
148
|
-
setStrategyIntent(ctx, {
|
|
149
|
-
activity: 'waiting',
|
|
150
|
-
summary: `社交目标暂不在视野内,当前没有可执行任务,正在${state.you.room || '当前位置'}等待。`,
|
|
151
|
-
...(state.you.room ? { room: state.you.room } : {}),
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
this.emitProgress(state, ctx);
|
|
156
|
-
return decisions;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
private tryTask(state: GameState, ctx: StrategyContext): BehaviorDecision | null {
|
|
160
|
-
const task = firstAvailableTask(ctx.taskData, t => t.faction !== 'crab', ctx.emergency, ctx.blockedMoveTarget);
|
|
161
|
-
if (!task) return null;
|
|
162
|
-
|
|
163
|
-
const isEmergencyTask = task === ctx.emergency;
|
|
164
|
-
if (state.you.doing_task && !isEmergencyTask) return null;
|
|
165
|
-
|
|
166
|
-
return taskMoveDecision(state, ctx, task);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
private emitProgress(state: GameState, ctx: StrategyContext): void {
|
|
170
|
-
const now = Date.now();
|
|
171
|
-
if (now - ctx.lastProgressNotifyAt < PROGRESS_INTERVAL_MS) return;
|
|
172
|
-
ctx.lastProgressNotifyAt = now;
|
|
173
|
-
|
|
174
|
-
const room = state.you.room ?? '未知';
|
|
175
|
-
const completed = ctx.taskData.filter(t => t.status === 'completed').length;
|
|
176
|
-
const total = ctx.taskData.filter(t => t.faction !== 'crab').length;
|
|
177
|
-
|
|
178
|
-
const visibleTargetNames = this.socialTargets
|
|
179
|
-
.filter(st => state.players.some(p => matchesTarget(st.target, p, ctx)))
|
|
180
|
-
.map(st => st.target);
|
|
181
|
-
|
|
182
|
-
let msg = `[进度] 当前在${room}。`;
|
|
183
|
-
if (visibleTargetNames.length > 0) {
|
|
184
|
-
msg += `社交目标在视野内: ${visibleTargetNames.join(', ')}。`;
|
|
185
|
-
} else {
|
|
186
|
-
msg += `社交目标不在视野内,正在做任务。`;
|
|
187
|
-
}
|
|
188
|
-
msg += ` 任务进度 ${completed}/${total}。`;
|
|
189
|
-
|
|
190
|
-
ctx.notifications.push(msg);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import type { GameState } from '../../sdk/types.js';
|
|
2
|
-
import { Action } from '../../sdk/action.js';
|
|
3
|
-
import {
|
|
4
|
-
canUseKill,
|
|
5
|
-
dist,
|
|
6
|
-
firstAvailableTask,
|
|
7
|
-
hasKillUseRemaining,
|
|
8
|
-
isTargetAlive,
|
|
9
|
-
killCooldownSecs,
|
|
10
|
-
killCommitRange,
|
|
11
|
-
LONE_FOLLOW_DISTANCE,
|
|
12
|
-
matchesTarget,
|
|
13
|
-
playerStrategyIntent,
|
|
14
|
-
PROGRESS_INTERVAL_MS,
|
|
15
|
-
reportCorpseDecision,
|
|
16
|
-
setStrategyIntent,
|
|
17
|
-
strategyDecision,
|
|
18
|
-
strategyPlayerLabel,
|
|
19
|
-
taskMoveDecision,
|
|
20
|
-
} from '../game-utils.js';
|
|
21
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
22
|
-
import { Goal } from './goal.js';
|
|
23
|
-
import { emitLeaf, URGENT_GOAL_PRIORITY, WANDER_GOAL_PRIORITY } from './leaf-goal.js';
|
|
24
|
-
|
|
25
|
-
type VisibleTargetMatch = {
|
|
26
|
-
player: GameState['players'][number];
|
|
27
|
-
dist: number;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export class TaskKillReportTop extends Goal {
|
|
31
|
-
private readonly targets: number[];
|
|
32
|
-
private readonly targetSpottedNotified = new Set<string>();
|
|
33
|
-
|
|
34
|
-
constructor(targets: number[]) {
|
|
35
|
-
super();
|
|
36
|
-
this.targets = [...targets];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
40
|
-
const allDead = this.targets.every(t => !isTargetAlive(state, t, ctx));
|
|
41
|
-
if (allDead) {
|
|
42
|
-
ctx.notifications.push('所有嫌疑目标都已死亡,策略结束。');
|
|
43
|
-
setStrategyIntent(ctx, {
|
|
44
|
-
activity: 'idle',
|
|
45
|
-
summary: '所有嫌疑目标都已死亡,正在等待下一步指令。',
|
|
46
|
-
});
|
|
47
|
-
this.emitProgress(state, ctx);
|
|
48
|
-
this.clearSub();
|
|
49
|
-
return [];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const visibleMatches = this.visibleTargets(state, ctx);
|
|
53
|
-
const cd = killCooldownSecs(state);
|
|
54
|
-
const hasKill = hasKillUseRemaining(state);
|
|
55
|
-
const killReady = canUseKill(state);
|
|
56
|
-
|
|
57
|
-
if (visibleMatches.length > 0 && hasKill) {
|
|
58
|
-
const nearest = visibleMatches[0];
|
|
59
|
-
|
|
60
|
-
if (!this.targetSpottedNotified.has(nearest.player.name)) {
|
|
61
|
-
this.targetSpottedNotified.add(nearest.player.name);
|
|
62
|
-
ctx.notifications.push(`发现嫌疑目标${nearest.player.name}!`);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (nearest.dist <= killCommitRange(state.you.role) && killReady) {
|
|
66
|
-
ctx.notifications.push(`嫌疑目标${nearest.player.name}在攻击范围内,出刀!`);
|
|
67
|
-
if (nearest.player.seat == null || nearest.player.seat <= 0) return this.emitDecisions(state, ctx, [], URGENT_GOAL_PRIORITY);
|
|
68
|
-
return this.emitDecisions(state, ctx, [strategyDecision(
|
|
69
|
-
Action.kill(nearest.player.seat),
|
|
70
|
-
playerStrategyIntent(nearest.player, '追杀', 'acting'),
|
|
71
|
-
)], URGENT_GOAL_PRIORITY);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (nearest.dist > killCommitRange(state.you.role) && killReady) {
|
|
75
|
-
return this.emitDecisions(
|
|
76
|
-
state,
|
|
77
|
-
ctx,
|
|
78
|
-
[strategyDecision(
|
|
79
|
-
Action.move({ x: nearest.player.x, y: nearest.player.y }),
|
|
80
|
-
playerStrategyIntent(nearest.player, '追杀', 'moving'),
|
|
81
|
-
)],
|
|
82
|
-
URGENT_GOAL_PRIORITY,
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (!killReady) {
|
|
87
|
-
if (nearest.dist > LONE_FOLLOW_DISTANCE) {
|
|
88
|
-
return this.emitDecisions(
|
|
89
|
-
state,
|
|
90
|
-
ctx,
|
|
91
|
-
[strategyDecision(
|
|
92
|
-
Action.move({ x: nearest.player.x, y: nearest.player.y }),
|
|
93
|
-
playerStrategyIntent(nearest.player, '追杀', 'moving'),
|
|
94
|
-
)],
|
|
95
|
-
URGENT_GOAL_PRIORITY,
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
setStrategyIntent(ctx, {
|
|
99
|
-
activity: 'waiting',
|
|
100
|
-
summary: `正在${nearest.player.room || state.you.room || '当前位置'}贴近${strategyPlayerLabel(nearest.player)},等待击杀冷却。`,
|
|
101
|
-
...(nearest.player.room ? { room: nearest.player.room } : {}),
|
|
102
|
-
targetPlayer: nearest.player.name,
|
|
103
|
-
});
|
|
104
|
-
this.emitProgress(state, ctx);
|
|
105
|
-
this.clearSub();
|
|
106
|
-
return [];
|
|
107
|
-
}
|
|
108
|
-
} else {
|
|
109
|
-
this.targetSpottedNotified.clear();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const reportDecision = reportCorpseDecision(state, ctx);
|
|
113
|
-
if (reportDecision) {
|
|
114
|
-
return this.emitDecisions(state, ctx, [reportDecision], URGENT_GOAL_PRIORITY);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const taskDecision = this.tryTask(state, ctx);
|
|
118
|
-
if (taskDecision) {
|
|
119
|
-
return this.emitDecisions(state, ctx, [taskDecision], WANDER_GOAL_PRIORITY);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
setStrategyIntent(ctx, {
|
|
123
|
-
activity: 'waiting',
|
|
124
|
-
summary: `正在${state.you.room || '当前位置'}等待嫌疑目标出现。`,
|
|
125
|
-
...(state.you.room ? { room: state.you.room } : {}),
|
|
126
|
-
});
|
|
127
|
-
this.emitProgress(state, ctx);
|
|
128
|
-
this.clearSub();
|
|
129
|
-
return [];
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
private visibleTargets(state: GameState, ctx: StrategyContext): VisibleTargetMatch[] {
|
|
133
|
-
const aliveTargets = this.targets.filter(t => isTargetAlive(state, t, ctx));
|
|
134
|
-
return state.players
|
|
135
|
-
.map(player => {
|
|
136
|
-
if (!aliveTargets.some(t => matchesTarget(t, player, ctx))) return null;
|
|
137
|
-
const d = player.distance ?? dist(state.you.x, state.you.y, player.x, player.y);
|
|
138
|
-
return { player, dist: d };
|
|
139
|
-
})
|
|
140
|
-
.filter((match): match is VisibleTargetMatch => match !== null)
|
|
141
|
-
.sort((a, b) => a.dist - b.dist);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
private tryTask(state: GameState, ctx: StrategyContext): BehaviorDecision | null {
|
|
145
|
-
if (state.you.doing_task) return null;
|
|
146
|
-
|
|
147
|
-
const task = firstAvailableTask(ctx.taskData, t => t.faction !== 'crab', ctx.emergency, ctx.blockedMoveTarget);
|
|
148
|
-
if (!task) return null;
|
|
149
|
-
return taskMoveDecision(state, ctx, task);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
private emitDecisions(
|
|
153
|
-
state: GameState,
|
|
154
|
-
ctx: StrategyContext,
|
|
155
|
-
decisions: BehaviorDecision[],
|
|
156
|
-
priority: number,
|
|
157
|
-
): BehaviorDecision[] {
|
|
158
|
-
this.emitProgress(state, ctx);
|
|
159
|
-
return emitLeaf(this, decisions, priority);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
private clearSub(): void {
|
|
163
|
-
if (this.subGoal) this.removeSubGoal();
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
private emitProgress(state: GameState, ctx: StrategyContext): void {
|
|
167
|
-
const now = Date.now();
|
|
168
|
-
if (now - ctx.lastProgressNotifyAt < PROGRESS_INTERVAL_MS) return;
|
|
169
|
-
ctx.lastProgressNotifyAt = now;
|
|
170
|
-
|
|
171
|
-
const room = state.you.room ?? '未知';
|
|
172
|
-
const cd = killCooldownSecs(state);
|
|
173
|
-
const killsRemaining = state.you.kills_remaining;
|
|
174
|
-
const targetNames = this.targets.join(', ');
|
|
175
|
-
const aliveCount = this.targets.filter(t => isTargetAlive(state, t, ctx)).length;
|
|
176
|
-
|
|
177
|
-
const completed = ctx.taskData.filter(t => t.status === 'completed').length;
|
|
178
|
-
const total = ctx.taskData.filter(t => t.faction !== 'crab').length;
|
|
179
|
-
|
|
180
|
-
let msg = `[进度] 当前在${room},嫌疑目标: ${targetNames}(存活${aliveCount}/${this.targets.length})。`;
|
|
181
|
-
if (cd > 0) msg += `攻击冷却中(${cd}s)。`;
|
|
182
|
-
if (killsRemaining === 0) msg += '出刀次数已用完。';
|
|
183
|
-
msg += ` 任务进度 ${completed}/${total}。`;
|
|
184
|
-
|
|
185
|
-
ctx.notifications.push(msg);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import type { GameState } from '../../sdk/types.js';
|
|
3
|
-
import type { StrategyContext } from '../types.js';
|
|
4
|
-
import { TaskOnlyTop } from './task-only-top.js';
|
|
5
|
-
|
|
6
|
-
function state(overrides: Partial<GameState> = {}): GameState {
|
|
7
|
-
return {
|
|
8
|
-
phase: 'wandering',
|
|
9
|
-
tick: 1,
|
|
10
|
-
you: {
|
|
11
|
-
name: 'self',
|
|
12
|
-
x: 0,
|
|
13
|
-
y: 0,
|
|
14
|
-
room: 'engine',
|
|
15
|
-
role: 'shrimp_generic',
|
|
16
|
-
faction: 'lobster',
|
|
17
|
-
is_alive: true,
|
|
18
|
-
},
|
|
19
|
-
your_tasks: [],
|
|
20
|
-
players: [],
|
|
21
|
-
corpses: [],
|
|
22
|
-
stale: false,
|
|
23
|
-
...overrides,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function context(overrides: Partial<StrategyContext> = {}): StrategyContext {
|
|
28
|
-
return {
|
|
29
|
-
taskData: [],
|
|
30
|
-
emergency: null,
|
|
31
|
-
taskLocalBlockedUntil: 0,
|
|
32
|
-
reportCorpseTarget: null,
|
|
33
|
-
reportBlockedUntil: 0,
|
|
34
|
-
notifications: [],
|
|
35
|
-
lastProgressNotifyAt: Date.now(),
|
|
36
|
-
teammates: new Set(),
|
|
37
|
-
rooms: [],
|
|
38
|
-
playerNamesBySeat: {},
|
|
39
|
-
forcePatrolAdvance: false,
|
|
40
|
-
blockedMoveTarget: null,
|
|
41
|
-
mySeat: 1,
|
|
42
|
-
speechNotifications: [],
|
|
43
|
-
agentAlerts: [],
|
|
44
|
-
...overrides,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const emergency = {
|
|
49
|
-
task_id: 'emergency-repair',
|
|
50
|
-
task_name: 'repair-engine',
|
|
51
|
-
room: 'engine',
|
|
52
|
-
status: 'normal',
|
|
53
|
-
x: 0,
|
|
54
|
-
y: 0,
|
|
55
|
-
remaining_secs: 60,
|
|
56
|
-
} as const;
|
|
57
|
-
|
|
58
|
-
describe('TaskOnlyTop', () => {
|
|
59
|
-
it('does not resubmit the emergency task already in progress', () => {
|
|
60
|
-
const decisions = new TaskOnlyTop().tick(state({
|
|
61
|
-
emergency,
|
|
62
|
-
you: {
|
|
63
|
-
...state().you,
|
|
64
|
-
doing_task: true,
|
|
65
|
-
task_name: emergency.task_name,
|
|
66
|
-
},
|
|
67
|
-
}), context({ emergency }));
|
|
68
|
-
|
|
69
|
-
expect(decisions).toEqual([]);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('still lets an emergency interrupt a different task', () => {
|
|
73
|
-
const decisions = new TaskOnlyTop().tick(state({
|
|
74
|
-
emergency,
|
|
75
|
-
you: {
|
|
76
|
-
...state().you,
|
|
77
|
-
doing_task: true,
|
|
78
|
-
task_name: 'ordinary-task',
|
|
79
|
-
},
|
|
80
|
-
}), context({
|
|
81
|
-
emergency: { ...emergency, x: 100 },
|
|
82
|
-
}));
|
|
83
|
-
|
|
84
|
-
expect(decisions).toHaveLength(1);
|
|
85
|
-
expect(decisions[0].action.type).toBe('move');
|
|
86
|
-
expect(decisions[0].action.payload).toMatchObject({ target_x: 100, target_y: 0 });
|
|
87
|
-
});
|
|
88
|
-
});
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { GameState } from '../../sdk/types.js';
|
|
2
|
-
import { firstAvailableTask, PROGRESS_INTERVAL_MS, setStrategyIntent, taskMoveDecision } from '../game-utils.js';
|
|
3
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
4
|
-
import { Goal } from './goal.js';
|
|
5
|
-
|
|
6
|
-
export class TaskOnlyTop extends Goal {
|
|
7
|
-
private lastEmergencyNotified = false;
|
|
8
|
-
|
|
9
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
10
|
-
if (state.emergency && !this.lastEmergencyNotified) {
|
|
11
|
-
this.lastEmergencyNotified = true;
|
|
12
|
-
ctx.notifications.push(`紧急任务出现!优先处理。`);
|
|
13
|
-
} else if (!state.emergency) {
|
|
14
|
-
this.lastEmergencyNotified = false;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const task = firstAvailableTask(ctx.taskData, () => true, ctx.emergency, ctx.blockedMoveTarget);
|
|
18
|
-
if (!task) {
|
|
19
|
-
setStrategyIntent(ctx, {
|
|
20
|
-
activity: 'waiting',
|
|
21
|
-
summary: `当前没有可用任务,正在${state.you.room || '当前位置'}等待。`,
|
|
22
|
-
...(state.you.room ? { room: state.you.room } : {}),
|
|
23
|
-
});
|
|
24
|
-
this.emitProgress(state, ctx);
|
|
25
|
-
return [];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Keep an in-flight task stable. An emergency may interrupt a different
|
|
29
|
-
// task, but must not be resubmitted while that same repair is running.
|
|
30
|
-
if (state.you.doing_task && (task !== ctx.emergency || state.you.task_name === task.task_name)) {
|
|
31
|
-
this.emitProgress(state, ctx);
|
|
32
|
-
return [];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const decisions = [taskMoveDecision(state, ctx, task)];
|
|
36
|
-
this.emitProgress(state, ctx);
|
|
37
|
-
return decisions;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
private emitProgress(state: GameState, ctx: StrategyContext): void {
|
|
41
|
-
const now = Date.now();
|
|
42
|
-
if (now - ctx.lastProgressNotifyAt < PROGRESS_INTERVAL_MS) return;
|
|
43
|
-
ctx.lastProgressNotifyAt = now;
|
|
44
|
-
|
|
45
|
-
const room = state.you.room ?? '未知';
|
|
46
|
-
const completed = ctx.taskData.filter(t => t.status === 'completed').length;
|
|
47
|
-
const total = ctx.taskData.length;
|
|
48
|
-
const current = firstAvailableTask(ctx.taskData, () => true, ctx.emergency);
|
|
49
|
-
|
|
50
|
-
let msg = `[进度] 当前在${room}`;
|
|
51
|
-
if (current) {
|
|
52
|
-
msg += `,正在前往${current.room}做任务「${current.task_name}」`;
|
|
53
|
-
} else {
|
|
54
|
-
msg += `,没有可用任务`;
|
|
55
|
-
}
|
|
56
|
-
msg += `。已完成 ${completed}/${total} 个任务。`;
|
|
57
|
-
|
|
58
|
-
if (state.emergency) {
|
|
59
|
-
msg += ` 紧急任务进行中!`;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
ctx.notifications.push(msg);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { GameState, TaskInfo } from '../../sdk/types.js';
|
|
2
|
-
import { Action } from '../../sdk/action.js';
|
|
3
|
-
import {
|
|
4
|
-
dist,
|
|
5
|
-
firstAvailableTask,
|
|
6
|
-
patrolStrategyIntent,
|
|
7
|
-
PATROL_REACHED_DISTANCE,
|
|
8
|
-
PatrolState,
|
|
9
|
-
setStrategyIntent,
|
|
10
|
-
strategyDecision,
|
|
11
|
-
taskMoveDecision,
|
|
12
|
-
} from '../game-utils.js';
|
|
13
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
14
|
-
import { Goal } from './goal.js';
|
|
15
|
-
|
|
16
|
-
export type TaskPredicate = (task: TaskInfo) => boolean;
|
|
17
|
-
const NON_CRAB: TaskPredicate = t => t.faction !== 'crab';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 好人虾的默认劳作循环:有可做任务(含紧急任务,由 firstAvailableTask 自动优先)就去做,
|
|
21
|
-
* 没任务就按房间顺序巡逻。抽自 task-report.tryTask,供 task-report / 武士虾共用
|
|
22
|
-
* (进阶普通虾用其安全选任务变体 SafeTaskOrPatrolGoal)。
|
|
23
|
-
*
|
|
24
|
-
* 直接产出 move/doTask 决策、不挂子目标,因此既能作为子目标接入 GoalManager,
|
|
25
|
-
* 也能被编排型 Goal 持有并直接 tick(见 WarriorShrimpTop)。
|
|
26
|
-
* 自身不发进度通知,进度由调用方按场景统一播报。
|
|
27
|
-
*/
|
|
28
|
-
export class TaskOrPatrolGoal extends Goal {
|
|
29
|
-
private readonly patrol = new PatrolState();
|
|
30
|
-
|
|
31
|
-
constructor(private readonly predicate: TaskPredicate = NON_CRAB) {
|
|
32
|
-
super();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
36
|
-
if (state.you.doing_task) return [];
|
|
37
|
-
|
|
38
|
-
const task = firstAvailableTask(ctx.taskData, this.predicate, ctx.emergency, ctx.blockedMoveTarget);
|
|
39
|
-
if (task) return [taskMoveDecision(state, ctx, task)];
|
|
40
|
-
|
|
41
|
-
let room = this.patrol.nextRoom(ctx);
|
|
42
|
-
if (!room) {
|
|
43
|
-
setStrategyIntent(ctx, {
|
|
44
|
-
activity: 'waiting',
|
|
45
|
-
summary: `当前没有可执行任务或可巡逻房间,正在${state.you.room || '当前位置'}等待。`,
|
|
46
|
-
...(state.you.room ? { room: state.you.room } : {}),
|
|
47
|
-
});
|
|
48
|
-
return [];
|
|
49
|
-
}
|
|
50
|
-
if (dist(state.you.x, state.you.y, room.x, room.y) <= PATROL_REACHED_DISTANCE) {
|
|
51
|
-
this.patrol.advance(ctx);
|
|
52
|
-
const next = this.patrol.nextRoom(ctx);
|
|
53
|
-
if (next) room = next;
|
|
54
|
-
}
|
|
55
|
-
const intent = patrolStrategyIntent(room);
|
|
56
|
-
setStrategyIntent(ctx, intent);
|
|
57
|
-
return [strategyDecision(Action.move({ x: room.x, y: room.y }), intent)];
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { GameState } from '../../sdk/types.js';
|
|
2
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
3
|
-
import { firstAvailableTask, reportCorpseDecision, PROGRESS_INTERVAL_MS } from '../game-utils.js';
|
|
4
|
-
import { GreetingTracker } from '../greeting.js';
|
|
5
|
-
import { Goal } from './goal.js';
|
|
6
|
-
import { TaskOrPatrolGoal } from './task-or-patrol-goal.js';
|
|
7
|
-
|
|
8
|
-
export class TaskReportTop extends Goal {
|
|
9
|
-
private readonly taskGoal = new TaskOrPatrolGoal();
|
|
10
|
-
private readonly greeting: GreetingTracker;
|
|
11
|
-
|
|
12
|
-
constructor(greetingPhrases: string[]) {
|
|
13
|
-
super();
|
|
14
|
-
this.greeting = new GreetingTracker(greetingPhrases);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
18
|
-
const decisions: BehaviorDecision[] = [];
|
|
19
|
-
|
|
20
|
-
const greetingDecision = this.greeting.tryGreeting(state);
|
|
21
|
-
if (greetingDecision) decisions.push(greetingDecision);
|
|
22
|
-
|
|
23
|
-
const reportDecision = reportCorpseDecision(state, ctx, { respectBlock: true });
|
|
24
|
-
if (reportDecision) {
|
|
25
|
-
decisions.unshift(reportDecision);
|
|
26
|
-
return decisions;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
decisions.push(...this.taskGoal.tick(state, ctx));
|
|
30
|
-
|
|
31
|
-
this.emitProgress(state, ctx);
|
|
32
|
-
return decisions;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
private emitProgress(state: GameState, ctx: StrategyContext): void {
|
|
36
|
-
const now = Date.now();
|
|
37
|
-
if (now - ctx.lastProgressNotifyAt < PROGRESS_INTERVAL_MS) return;
|
|
38
|
-
ctx.lastProgressNotifyAt = now;
|
|
39
|
-
|
|
40
|
-
const completed = ctx.taskData.filter(t => t.status === 'completed').length;
|
|
41
|
-
const total = ctx.taskData.filter(t => t.faction !== 'crab').length;
|
|
42
|
-
const current = firstAvailableTask(ctx.taskData, t => t.faction !== 'crab', ctx.emergency, ctx.blockedMoveTarget);
|
|
43
|
-
const room = state.you.room ?? '未知';
|
|
44
|
-
|
|
45
|
-
let msg = `[进度] 当前在${room}`;
|
|
46
|
-
if (current) {
|
|
47
|
-
msg += `,正在前往${current.room}做任务「${current.task_name}」`;
|
|
48
|
-
}
|
|
49
|
-
msg += `。已完成 ${completed}/${total} 个任务。`;
|
|
50
|
-
|
|
51
|
-
if (state.emergency) {
|
|
52
|
-
msg += ` 紧急任务进行中!`;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
ctx.notifications.push(msg);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { GameState, TaskInfo } from '../../sdk/types.js';
|
|
2
|
-
import { approachOrDoTaskStep, patrolStep, PatrolState } from '../game-utils.js';
|
|
3
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
4
|
-
import { Goal } from './goal.js';
|
|
5
|
-
|
|
6
|
-
export type TaskPicker = (state: GameState, ctx: StrategyContext) => TaskInfo | null;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 任务伪装 + 巡逻子目标(叶子,由上层以 WANDER 优先级挂载):先按 pickTask 取一个任务靠近 / 提交,
|
|
10
|
-
* 没有可做任务、或到点暂不可提交,就按房间巡逻,绝不停在原地。供 lone-kill-task / crab-sabotage 复用,
|
|
11
|
-
* pickTask 决定做哪类任务,stopOnPlayer 通常接 LoneKillCore.patrolStopOnPlayer(),patrol 由上层注入以共享巡逻进度。
|
|
12
|
-
*/
|
|
13
|
-
export class WanderTaskGoal extends Goal {
|
|
14
|
-
constructor(
|
|
15
|
-
private readonly pickTask: TaskPicker,
|
|
16
|
-
private readonly stopOnPlayer: () => boolean,
|
|
17
|
-
private readonly patrol: PatrolState,
|
|
18
|
-
) {
|
|
19
|
-
super();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
23
|
-
if (state.you.doing_task) return [];
|
|
24
|
-
|
|
25
|
-
const task = this.pickTask(state, ctx);
|
|
26
|
-
if (task) {
|
|
27
|
-
const decision = approachOrDoTaskStep(state, ctx, task, this.stopOnPlayer());
|
|
28
|
-
if (decision) return decision;
|
|
29
|
-
// 到点却暂时无法提交 → 转巡逻,避免卡在任务点
|
|
30
|
-
}
|
|
31
|
-
return patrolStep(state, ctx, this.patrol, this.stopOnPlayer());
|
|
32
|
-
}
|
|
33
|
-
}
|