@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,65 +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 { KillTargetTop } from './kill-target-top.js';
|
|
5
|
-
|
|
6
|
-
function state(): GameState {
|
|
7
|
-
return {
|
|
8
|
-
phase: 'wandering',
|
|
9
|
-
tick: 1,
|
|
10
|
-
you: {
|
|
11
|
-
name: 'hunter',
|
|
12
|
-
x: 0,
|
|
13
|
-
y: 0,
|
|
14
|
-
room: 'control',
|
|
15
|
-
role: 'neutral_octopus',
|
|
16
|
-
faction: 'neutral',
|
|
17
|
-
is_alive: true,
|
|
18
|
-
kill_cooldown_secs: 0,
|
|
19
|
-
},
|
|
20
|
-
your_tasks: [],
|
|
21
|
-
players: [],
|
|
22
|
-
all_players: [
|
|
23
|
-
{ name: '木桩机器虾', seat: 1, role: 'unknown', is_alive: false },
|
|
24
|
-
{ name: '木桩机器虾', seat: 3, role: 'unknown', is_alive: true },
|
|
25
|
-
],
|
|
26
|
-
corpses: [],
|
|
27
|
-
stale: false,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function context(): StrategyContext {
|
|
32
|
-
return {
|
|
33
|
-
taskData: [],
|
|
34
|
-
emergency: null,
|
|
35
|
-
taskLocalBlockedUntil: 0,
|
|
36
|
-
reportCorpseTarget: null,
|
|
37
|
-
reportBlockedUntil: 0,
|
|
38
|
-
notifications: [],
|
|
39
|
-
lastProgressNotifyAt: Date.now(),
|
|
40
|
-
teammates: new Set(),
|
|
41
|
-
rooms: [{ name: 'patrol', x: 500, y: 0 }],
|
|
42
|
-
playerNamesBySeat: {
|
|
43
|
-
'1': '木桩机器虾',
|
|
44
|
-
'3': '木桩机器虾',
|
|
45
|
-
},
|
|
46
|
-
forcePatrolAdvance: false,
|
|
47
|
-
blockedMoveTarget: null,
|
|
48
|
-
mySeat: 4,
|
|
49
|
-
speechNotifications: [],
|
|
50
|
-
agentAlerts: [],
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
describe('KillTargetTop seat targeting', () => {
|
|
55
|
-
it('does not complete seat 3 when a different player with the same name is dead', () => {
|
|
56
|
-
const top = new KillTargetTop([3]);
|
|
57
|
-
const ctx = context();
|
|
58
|
-
|
|
59
|
-
const decisions = top.tick(state(), ctx);
|
|
60
|
-
|
|
61
|
-
expect(decisions[0]?.intent?.summary).toContain('巡逻寻找追杀目标');
|
|
62
|
-
expect(decisions[0]?.intent?.summary).not.toContain('离开现场巡逻');
|
|
63
|
-
expect(ctx.notifications).not.toContain('击杀目标已完成,切换巡逻离开现场。');
|
|
64
|
-
});
|
|
65
|
-
});
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import type { GameState } from '../../sdk/types.js';
|
|
2
|
-
import {
|
|
3
|
-
dist,
|
|
4
|
-
killCooldownSecs,
|
|
5
|
-
isTargetAlive,
|
|
6
|
-
isRecentlyKilledTarget,
|
|
7
|
-
killCommitRange,
|
|
8
|
-
LONE_FOLLOW_DISTANCE,
|
|
9
|
-
LONE_IGNORE_MS,
|
|
10
|
-
matchesTarget,
|
|
11
|
-
nearestVisibleTarget,
|
|
12
|
-
patrolStep,
|
|
13
|
-
PatrolState,
|
|
14
|
-
PROGRESS_INTERVAL_MS,
|
|
15
|
-
pursueVisibleTarget,
|
|
16
|
-
setStrategyIntent,
|
|
17
|
-
strategyPlayerLabel,
|
|
18
|
-
} from '../game-utils.js';
|
|
19
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
20
|
-
import { Goal } from './goal.js';
|
|
21
|
-
|
|
22
|
-
export class KillTargetTop extends Goal {
|
|
23
|
-
private readonly patrol = new PatrolState();
|
|
24
|
-
private skipStopUntil = 0;
|
|
25
|
-
private completedAfterKill = false;
|
|
26
|
-
private completedNotified = false;
|
|
27
|
-
|
|
28
|
-
constructor(private readonly targets: number[]) {
|
|
29
|
-
super();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
onMeetingResume(): void {
|
|
33
|
-
this.skipStopUntil = Date.now() + LONE_IGNORE_MS;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
37
|
-
if (this.completedAfterKill) return this.completedPatrol(state, ctx);
|
|
38
|
-
|
|
39
|
-
const recentlyKilledAnyTarget = this.targets.some(t => isRecentlyKilledTarget(t, ctx));
|
|
40
|
-
const allTargetsDead = this.allTargetsDeadInState(state, ctx);
|
|
41
|
-
const validTargets = this.targets.filter(t => this.isValidTarget(t, state, ctx));
|
|
42
|
-
if (validTargets.length === 0) {
|
|
43
|
-
if (recentlyKilledAnyTarget || allTargetsDead || this.completedAfterKill) {
|
|
44
|
-
this.completedAfterKill = true;
|
|
45
|
-
return this.completedPatrol(state, ctx);
|
|
46
|
-
}
|
|
47
|
-
ctx.notifications.push('所有目标都已死亡或为队友');
|
|
48
|
-
setStrategyIntent(ctx, {
|
|
49
|
-
activity: 'idle',
|
|
50
|
-
summary: '没有可追杀的目标,正在等待下一步指令。',
|
|
51
|
-
});
|
|
52
|
-
this.emitProgress(state, ctx);
|
|
53
|
-
return [];
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const target = nearestVisibleTarget(state, ctx, validTargets);
|
|
57
|
-
if (target) {
|
|
58
|
-
const decision = pursueVisibleTarget(state, target, { kill: true, followDistance: LONE_FOLLOW_DISTANCE });
|
|
59
|
-
if (decision?.action.type === 'kill') {
|
|
60
|
-
ctx.notifications.push(`发现目标${target.name}在攻击范围内,出刀!`);
|
|
61
|
-
} else {
|
|
62
|
-
const d = target.distance ?? dist(state.you.x, state.you.y, target.x, target.y);
|
|
63
|
-
if (d > killCommitRange(state.you.role)) ctx.notifications.push(`发现目标${target.name},正在靠近!`);
|
|
64
|
-
}
|
|
65
|
-
if (!decision) {
|
|
66
|
-
setStrategyIntent(ctx, {
|
|
67
|
-
activity: 'waiting',
|
|
68
|
-
summary: `正在${target.room || state.you.room || '当前位置'}贴近${strategyPlayerLabel(target)},等待击杀冷却。`,
|
|
69
|
-
...(target.room ? { room: target.room } : {}),
|
|
70
|
-
targetPlayer: target.name,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
this.emitProgress(state, ctx);
|
|
74
|
-
return decision ? [decision] : [];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (state.players.length > 0 || ctx.emergency) {
|
|
78
|
-
this.skipStopUntil = Date.now() + LONE_IGNORE_MS;
|
|
79
|
-
}
|
|
80
|
-
this.emitProgress(state, ctx);
|
|
81
|
-
return patrolStep(state, ctx, this.patrol, Date.now() >= this.skipStopUntil, '巡逻寻找追杀目标');
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
private completedPatrol(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
85
|
-
if (!this.completedNotified) {
|
|
86
|
-
ctx.notifications.push('击杀目标已完成,切换巡逻离开现场。');
|
|
87
|
-
ctx.forcePatrolAdvance = true;
|
|
88
|
-
this.completedNotified = true;
|
|
89
|
-
}
|
|
90
|
-
return patrolStep(state, ctx, this.patrol, false, '离开现场巡逻');
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
private isValidTarget(t: number, state: GameState, ctx: StrategyContext): boolean {
|
|
94
|
-
if (!isTargetAlive(state, t, ctx)) return false;
|
|
95
|
-
return !ctx.teammates.has(String(t));
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
private allTargetsDeadInState(state: GameState, ctx: StrategyContext): boolean {
|
|
99
|
-
return this.targets.length > 0 && this.targets.every(target => this.targetDeadInState(target, state, ctx));
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
private targetDeadInState(target: number, state: GameState, ctx: StrategyContext): boolean {
|
|
103
|
-
const player = state.all_players?.find(p => matchesTarget(target, p, ctx));
|
|
104
|
-
if (player) return player.is_alive === false;
|
|
105
|
-
return (ctx.knownCorpses ?? []).some(corpse => matchesTarget(target, corpse, ctx));
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
private emitProgress(state: GameState, ctx: StrategyContext): void {
|
|
109
|
-
const now = Date.now();
|
|
110
|
-
if (now - ctx.lastProgressNotifyAt < PROGRESS_INTERVAL_MS) return;
|
|
111
|
-
ctx.lastProgressNotifyAt = now;
|
|
112
|
-
|
|
113
|
-
const room = state.you.room ?? '未知';
|
|
114
|
-
const cd = killCooldownSecs(state);
|
|
115
|
-
const killsRemaining = state.you.kills_remaining;
|
|
116
|
-
let msg = `[进度] 当前在${room},正在寻找目标: ${this.targets.join(', ')}。`;
|
|
117
|
-
if (cd > 0) msg += `攻击冷却中(${cd}s)。`;
|
|
118
|
-
if (killsRemaining === 0) msg += '出刀次数已用完。';
|
|
119
|
-
ctx.notifications.push(msg);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { BehaviorDecision } from '../types.js';
|
|
2
|
-
import { Goal } from './goal.js';
|
|
3
|
-
|
|
4
|
-
export const URGENT_GOAL_PRIORITY = 1;
|
|
5
|
-
/** 残局抢修紧急任务:高于游走任务、低于落单猎杀/反射(URGENT),故对发言仍可被打断(< URGENT)。 */
|
|
6
|
-
export const EMERGENCY_GOAL_PRIORITY = 0.6;
|
|
7
|
-
export const WANDER_GOAL_PRIORITY = 0.2;
|
|
8
|
-
|
|
9
|
-
export class LeafGoal extends Goal {
|
|
10
|
-
constructor(private readonly decisions: BehaviorDecision[]) {
|
|
11
|
-
super();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
tick(): BehaviorDecision[] {
|
|
15
|
-
return this.decisions;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function setBehavior(parent: Goal, child: Goal, priority: number): BehaviorDecision[] {
|
|
20
|
-
if (parent.subGoal) parent.removeSubGoal();
|
|
21
|
-
parent.setSubGoal(child, priority);
|
|
22
|
-
return [];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function emitLeaf(parent: Goal, decisions: BehaviorDecision[], priority: number): BehaviorDecision[] {
|
|
26
|
-
return setBehavior(parent, new LeafGoal(decisions), priority);
|
|
27
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { GameState, PlayerInfo } from '../../sdk/types.js';
|
|
2
|
-
import { Action } from '../../sdk/action.js';
|
|
3
|
-
import { nearestKnownCorpse, nearestKnownCorpseNav, strategyDecision } from '../game-utils.js';
|
|
4
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
5
|
-
import { AnchorLinger } from './anchor-linger.js';
|
|
6
|
-
import { Goal } from './goal.js';
|
|
7
|
-
|
|
8
|
-
export class LingerCorpseGoal extends Goal {
|
|
9
|
-
private readonly wander = new AnchorLinger();
|
|
10
|
-
|
|
11
|
-
constructor(private readonly avoidResolver?: (state: GameState, ctx: StrategyContext) => PlayerInfo[]) {
|
|
12
|
-
super();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
16
|
-
const body = nearestKnownCorpse(state, ctx);
|
|
17
|
-
if (!body) {
|
|
18
|
-
// 还没拿到尸体坐标:朝尸体所在房间靠近,人进视野后坐标自然补全,再切到下面的贴尸游走。
|
|
19
|
-
this.wander.reset();
|
|
20
|
-
const nav = nearestKnownCorpseNav(state, ctx);
|
|
21
|
-
return nav ? [strategyDecision(Action.move({ x: nav.x, y: nav.y }), {
|
|
22
|
-
activity: 'moving',
|
|
23
|
-
summary: `正在前往${nav.room || '尸体所在区域'}寻找${nav.name ? `${nav.name}的尸体` : '尸体'}。`,
|
|
24
|
-
...(nav.room ? { room: nav.room } : {}),
|
|
25
|
-
})] : [];
|
|
26
|
-
}
|
|
27
|
-
// 有坐标:在尸体周围 40-100 粘性徘徊(AnchorLinger 负责粘住游走点、按 avoid 偏到对侧)。
|
|
28
|
-
const key = body.name ?? `${Math.round(body.x)},${Math.round(body.y)}`;
|
|
29
|
-
const avoid = this.avoidResolver?.(state, ctx) ?? [];
|
|
30
|
-
return [strategyDecision(Action.move(this.wander.step(state, key, body, avoid)), {
|
|
31
|
-
activity: 'moving',
|
|
32
|
-
summary: `正在${body.room || state.you.room || '当前位置'}的${body.name ? `${body.name}的尸体` : '尸体'}附近徘徊。`,
|
|
33
|
-
...(body.room ? { room: body.room } : {}),
|
|
34
|
-
})];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Nav / 非 Nav 的不对称是有意的:tick 取坐标用严格的 nearestKnownCorpse(没坐标无法定点游走),
|
|
38
|
-
// 但只要还记得尸体在某房间(nearestKnownCorpseNav 非空)就不该 finish——此时应继续走向房间锚点,
|
|
39
|
-
// 等人进视野把坐标补全,否则尸体一离开视野就提前结束、再也走不回去。
|
|
40
|
-
isFinish(state: GameState, ctx: StrategyContext): boolean {
|
|
41
|
-
return nearestKnownCorpseNav(state, ctx) == null;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import type { GameState, PlayerInfo } from '../../sdk/types.js';
|
|
2
|
-
import { Action } from '../../sdk/action.js';
|
|
3
|
-
import {
|
|
4
|
-
canUseKill,
|
|
5
|
-
dist,
|
|
6
|
-
killCommitRange,
|
|
7
|
-
LONE_IGNORE_MS,
|
|
8
|
-
nonTeammatesVisible,
|
|
9
|
-
playerStrategyIntent,
|
|
10
|
-
strategyDecision,
|
|
11
|
-
} from '../game-utils.js';
|
|
12
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
13
|
-
|
|
14
|
-
export interface LoneKillOptions {
|
|
15
|
-
/** 紧急期调用方可无视「刚遇到人群」后的短暂停手窗口。 */
|
|
16
|
-
bypassIgnoreWindow?: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type LoneKillAssessment =
|
|
20
|
-
| { kind: 'hunt'; target: PlayerInfo }
|
|
21
|
-
| { kind: 'idle' };
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* crab-sabotage 与 lone-kill-task 共享的落单猎杀状态机。
|
|
25
|
-
* 刀在冷却(或出刀用完)时一律返回 idle,让上层下沉去做低优先级任务,而不是追/原地等刀。
|
|
26
|
-
*/
|
|
27
|
-
export class LoneKillCore {
|
|
28
|
-
private loneIgnoreUntil = 0;
|
|
29
|
-
private suppressStop = false;
|
|
30
|
-
|
|
31
|
-
reset(): void {
|
|
32
|
-
this.loneIgnoreUntil = 0;
|
|
33
|
-
this.suppressStop = false;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** 兜底任务/巡逻移动是否应 stop_on_player。 */
|
|
37
|
-
patrolStopOnPlayer(): boolean {
|
|
38
|
-
return !this.suppressStop;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
assess(state: GameState, ctx: StrategyContext, opts: LoneKillOptions = {}): LoneKillAssessment {
|
|
42
|
-
const now = Date.now();
|
|
43
|
-
this.suppressStop = false;
|
|
44
|
-
const nonTeammates = nonTeammatesVisible(state, ctx);
|
|
45
|
-
|
|
46
|
-
if (nonTeammates.length === 0) {
|
|
47
|
-
if (state.players.length > 0) {
|
|
48
|
-
this.loneIgnoreUntil = now + LONE_IGNORE_MS;
|
|
49
|
-
this.suppressStop = true;
|
|
50
|
-
}
|
|
51
|
-
return { kind: 'idle' };
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (nonTeammates.length > 1) {
|
|
55
|
-
this.loneIgnoreUntil = now + LONE_IGNORE_MS;
|
|
56
|
-
this.suppressStop = true;
|
|
57
|
-
return { kind: 'idle' };
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (!opts.bypassIgnoreWindow && now < this.loneIgnoreUntil) {
|
|
61
|
-
this.suppressStop = true;
|
|
62
|
-
return { kind: 'idle' };
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (!canUseKill(state)) {
|
|
66
|
-
// 刀在冷却或出刀已用完:不追不等,下沉做低优先级伪装任务,冷却好再下手
|
|
67
|
-
//(贴脸反射刀 immediateLoneKillDecision 仍会在冷却结束瞬间生效,不丢顺手的杀)。
|
|
68
|
-
this.suppressStop = true;
|
|
69
|
-
return { kind: 'idle' };
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return { kind: 'hunt', target: nonTeammates[0] };
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
pursue(state: GameState, ctx: StrategyContext, target: PlayerInfo): BehaviorDecision {
|
|
76
|
-
const d = target.distance ?? dist(state.you.x, state.you.y, target.x, target.y);
|
|
77
|
-
if (d <= killCommitRange(state.you.role) && canUseKill(state)) {
|
|
78
|
-
ctx.notifications.push(`发现落单目标${target.name},出刀!`);
|
|
79
|
-
if (target.seat != null && target.seat > 0) {
|
|
80
|
-
return strategyDecision(Action.kill(target.seat), playerStrategyIntent(target, '追杀', 'acting'));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (d > killCommitRange(state.you.role)) ctx.notifications.push(`发现落单目标${target.name},正在靠近!`);
|
|
84
|
-
return strategyDecision(Action.move({ x: target.x, y: target.y }), playerStrategyIntent(target, '追杀', 'moving'));
|
|
85
|
-
}
|
|
86
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { GameState, PlayerInfo } from '../../sdk/types.js';
|
|
2
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
3
|
-
import { Goal } from './goal.js';
|
|
4
|
-
import type { LoneKillCore } from './lone-kill-core.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 落单猎杀子目标(叶子,由上层以 URGENT 优先级挂载):对上层经 {@link LoneKillCore.assess} 选中、
|
|
8
|
-
* 并经 setTarget() 注入的目标产出追击 / 出刀决策。判定逻辑在 core/上层,本叶子只负责产出动作。
|
|
9
|
-
*/
|
|
10
|
-
export class LoneKillGoal extends Goal {
|
|
11
|
-
private target: PlayerInfo | null = null;
|
|
12
|
-
|
|
13
|
-
constructor(private readonly core: LoneKillCore) {
|
|
14
|
-
super();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
setTarget(target: PlayerInfo): void {
|
|
18
|
-
this.target = target;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
22
|
-
return this.target ? [this.core.pursue(state, ctx, this.target)] : [];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,84 +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 { LoneKillTaskTop } from './lone-kill-task-top.js';
|
|
5
|
-
|
|
6
|
-
function state(overrides: Partial<GameState> = {}): GameState {
|
|
7
|
-
return {
|
|
8
|
-
phase: 'wandering',
|
|
9
|
-
tick: 1,
|
|
10
|
-
you: {
|
|
11
|
-
name: 'octopus',
|
|
12
|
-
x: 0,
|
|
13
|
-
y: 0,
|
|
14
|
-
room: 'control',
|
|
15
|
-
role: 'neutral_octopus',
|
|
16
|
-
faction: 'neutral',
|
|
17
|
-
is_alive: true,
|
|
18
|
-
kill_cooldown_secs: 10,
|
|
19
|
-
},
|
|
20
|
-
your_tasks: [],
|
|
21
|
-
players: [],
|
|
22
|
-
corpses: [],
|
|
23
|
-
stale: false,
|
|
24
|
-
...overrides,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function task(task_name: string, x: number, y: number): TaskInfo {
|
|
29
|
-
return {
|
|
30
|
-
task_id: task_name,
|
|
31
|
-
task_name,
|
|
32
|
-
room: 'control',
|
|
33
|
-
status: 'normal',
|
|
34
|
-
x,
|
|
35
|
-
y,
|
|
36
|
-
is_fake_shrimp: true,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function context(overrides: Partial<StrategyContext> = {}): StrategyContext {
|
|
41
|
-
return {
|
|
42
|
-
taskData: [],
|
|
43
|
-
emergency: null,
|
|
44
|
-
taskLocalBlockedUntil: 0,
|
|
45
|
-
reportCorpseTarget: null,
|
|
46
|
-
reportBlockedUntil: 0,
|
|
47
|
-
notifications: [],
|
|
48
|
-
lastProgressNotifyAt: Date.now(),
|
|
49
|
-
teammates: new Set(),
|
|
50
|
-
rooms: [{ name: 'patrol', x: 500, y: 0 }],
|
|
51
|
-
playerNamesBySeat: {},
|
|
52
|
-
forcePatrolAdvance: false,
|
|
53
|
-
blockedMoveTarget: null,
|
|
54
|
-
mySeat: 1,
|
|
55
|
-
speechNotifications: [],
|
|
56
|
-
agentAlerts: [],
|
|
57
|
-
...overrides,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
describe('LoneKillTaskTop', () => {
|
|
62
|
-
it('does not try to repair emergency tasks as octopus', () => {
|
|
63
|
-
const top = new LoneKillTaskTop();
|
|
64
|
-
const ctx = context({
|
|
65
|
-
taskData: [task('fake-clean', 100, 0)],
|
|
66
|
-
emergency: {
|
|
67
|
-
task_id: 'repair',
|
|
68
|
-
task_name: 'repair',
|
|
69
|
-
room: 'control',
|
|
70
|
-
status: 'emergency',
|
|
71
|
-
x: 0,
|
|
72
|
-
y: 0,
|
|
73
|
-
remaining_secs: 60,
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
top.tick(state(), ctx);
|
|
78
|
-
const decisions = top.subGoal?.tick(state(), ctx) ?? [];
|
|
79
|
-
|
|
80
|
-
expect(decisions).toHaveLength(1);
|
|
81
|
-
expect(decisions[0].action.type).toBe('move');
|
|
82
|
-
expect(decisions[0].action.payload).toMatchObject({ target_x: 100, target_y: 0 });
|
|
83
|
-
});
|
|
84
|
-
});
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import type { GameState, PlayerInfo } from '../../sdk/types.js';
|
|
2
|
-
import {
|
|
3
|
-
emergencyRushDecision,
|
|
4
|
-
firstAvailableTask,
|
|
5
|
-
killCooldownSecs,
|
|
6
|
-
killYieldsToEmergencyRepair,
|
|
7
|
-
nonTeammatesVisible,
|
|
8
|
-
PatrolState,
|
|
9
|
-
PROGRESS_INTERVAL_MS,
|
|
10
|
-
} from '../game-utils.js';
|
|
11
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
12
|
-
import { Goal } from './goal.js';
|
|
13
|
-
import { LoneKillCore } from './lone-kill-core.js';
|
|
14
|
-
import { LoneKillGoal } from './lone-kill-goal.js';
|
|
15
|
-
import { WanderTaskGoal } from './wander-task-goal.js';
|
|
16
|
-
import { emitLeaf, EMERGENCY_GOAL_PRIORITY, 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
|
-
* 把对应**叶子子目标**挂为唯一子目标(产出动作的是叶子,优先级标注紧急/游走,供 ConversationGoal 判断):
|
|
22
|
-
*
|
|
23
|
-
* 0. 反射(crab-octopus-reflexes,URGENT,抢在落单猎杀编排之前):落单非队友贴脸(出刀范围内)且刀好 →
|
|
24
|
-
* 立刻出刀;否则有尸体且附近有非队友 → 报警/靠近报警(不管尸体是谁造成的)。
|
|
25
|
-
* 1. 落单猎杀(LoneKillGoal,URGENT):core.assess() 判 hunt(刀好且有落单目标)→ 叶子 pursue() 靠近 / 出刀。
|
|
26
|
-
* 刀在冷却时 assess 返回 idle,不追不等,直接下沉到任务伪装。**残局抢修期例外**:落单目标紧挨紧急维修点
|
|
27
|
-
* (同房间或避尸距离内,killYieldsToEmergencyRepair)时跳过反射刀/落单猎杀,让位给第 2 步去修——虾群都
|
|
28
|
-
* 涌向维修点,在那儿动手必被围观、还会撇下维修把破坏倒计时取胜线让给蟹;远离维修点的目标照常猎杀。
|
|
29
|
-
* 2. 残局抢修紧急任务(EMERGENCY,仅已知存活≤6):低于落单猎杀(击杀优先),高于伪装任务——
|
|
30
|
-
* 紧急任务超时则蟹阵营直接获胜,中立章鱼靠活到最后取胜,故残局抢着把维修做掉、掐断蟹的破坏取胜线。
|
|
31
|
-
* 3. 任务伪装 / 巡逻(WanderTaskGoal,WANDER):做已分配的伪装任务(排除当前紧急任务,那个走第 2 步),
|
|
32
|
-
* 跳过紧挨已知尸体(含看见过、已离开视野的)的任务,没任务就按房间巡逻,绝不停在原地。
|
|
33
|
-
*/
|
|
34
|
-
export class LoneKillTaskTop extends Goal {
|
|
35
|
-
private readonly killCore = new LoneKillCore();
|
|
36
|
-
private readonly patrol = new PatrolState();
|
|
37
|
-
private readonly loneKillGoal = new LoneKillGoal(this.killCore);
|
|
38
|
-
private readonly wanderGoal = new WanderTaskGoal(
|
|
39
|
-
// 排除当前紧急任务:它由 tick 里的残局抢修分支按 EMERGENCY 优先级处理,不在此当普通伪装任务做。
|
|
40
|
-
(state, ctx) => firstAvailableTask(
|
|
41
|
-
ctx.taskData,
|
|
42
|
-
t => t.task_name !== ctx.emergency?.task_name,
|
|
43
|
-
undefined,
|
|
44
|
-
ctx.blockedMoveTarget,
|
|
45
|
-
ctx.knownCorpses,
|
|
46
|
-
),
|
|
47
|
-
() => this.killCore.patrolStopOnPlayer(),
|
|
48
|
-
this.patrol,
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
onMeetingResume(): void {
|
|
52
|
-
this.killCore.reset();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
56
|
-
// 残局抢修期:紧急维修点附近不杀人。虾群都涌向维修点,在那儿动手必被围观、还会撇下维修把破坏
|
|
57
|
-
// 倒计时取胜线让给蟹。落单目标紧挨维修点(同房间或避尸距离内)时跳过反射刀与落单猎杀,让位给下面
|
|
58
|
-
// 的抢修分支;远离维修点的目标照常猎杀(抢修仍低于猎杀的设定不变)。
|
|
59
|
-
const yieldsToRepair = (t: PlayerInfo) => killYieldsToEmergencyRepair(state, ctx, t);
|
|
60
|
-
|
|
61
|
-
const immediateKill = immediateLoneKillDecision(state, ctx, yieldsToRepair);
|
|
62
|
-
if (immediateKill) {
|
|
63
|
-
this.emitProgress(state, ctx, false);
|
|
64
|
-
return emitLeaf(this, immediateKill, URGENT_GOAL_PRIORITY);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const corpseReport = corpseReportWithNonTeammate(state, ctx);
|
|
68
|
-
if (corpseReport) {
|
|
69
|
-
this.emitProgress(state, ctx, false);
|
|
70
|
-
return emitLeaf(this, corpseReport, URGENT_GOAL_PRIORITY);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const target = this.killCore.assess(state, ctx);
|
|
74
|
-
const sparedNearRepair = target.kind === 'hunt' && yieldsToRepair(target.target);
|
|
75
|
-
if (target.kind === 'hunt' && !sparedNearRepair) {
|
|
76
|
-
this.emitProgress(state, ctx, false);
|
|
77
|
-
this.loneKillGoal.setTarget(target.target);
|
|
78
|
-
return setBehavior(this, this.loneKillGoal, URGENT_GOAL_PRIORITY);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// 残局抢修紧急任务(已知存活≤6):高于伪装任务,低于上面的落单猎杀/反射。
|
|
82
|
-
const emergency = emergencyRushDecision(state, ctx);
|
|
83
|
-
if (emergency) {
|
|
84
|
-
this.emitProgress(state, ctx, true, sparedNearRepair ? target.target.name : null);
|
|
85
|
-
return emitLeaf(this, [emergency], EMERGENCY_GOAL_PRIORITY);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
this.emitProgress(state, ctx, false);
|
|
89
|
-
return setBehavior(this, this.wanderGoal, WANDER_GOAL_PRIORITY);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
private emitProgress(
|
|
93
|
-
state: GameState,
|
|
94
|
-
ctx: StrategyContext,
|
|
95
|
-
emergencyRush: boolean,
|
|
96
|
-
sparedNearRepair: string | null = null,
|
|
97
|
-
): void {
|
|
98
|
-
const now = Date.now();
|
|
99
|
-
if (now - ctx.lastProgressNotifyAt < PROGRESS_INTERVAL_MS) return;
|
|
100
|
-
ctx.lastProgressNotifyAt = now;
|
|
101
|
-
|
|
102
|
-
const room = state.you.room ?? '未知';
|
|
103
|
-
if (emergencyRush) {
|
|
104
|
-
const name = ctx.emergency?.task_name ?? '紧急维修';
|
|
105
|
-
let msg = `[进度] 当前在${room},残局仅剩${state.alive_count}人,抢着去做紧急任务「${name}」,阻止蟹靠破坏倒计时取胜。`;
|
|
106
|
-
if (sparedNearRepair) {
|
|
107
|
-
msg += ` 落单目标${sparedNearRepair}就在维修点附近,先修不杀,免得在虾群涌入的维修点暴露自己。`;
|
|
108
|
-
}
|
|
109
|
-
ctx.notifications.push(msg);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
const cd = killCooldownSecs(state);
|
|
113
|
-
const killsRemaining = state.you.kills_remaining;
|
|
114
|
-
const nonTeammates = nonTeammatesVisible(state, ctx);
|
|
115
|
-
|
|
116
|
-
let msg = `[进度] 当前在${room}`;
|
|
117
|
-
if (nonTeammates.length === 0) {
|
|
118
|
-
msg += ',视野内没有落单目标,继续做任务伪装。';
|
|
119
|
-
} else if (nonTeammates.length === 1) {
|
|
120
|
-
msg += `,视野内发现落单目标${nonTeammates[0].name}。`;
|
|
121
|
-
if (cd > 0) msg += `攻击冷却中(${cd}s),先做任务、冷却好再下手。`;
|
|
122
|
-
if (killsRemaining === 0) msg += '出刀次数已用完,继续做任务伪装。';
|
|
123
|
-
} else {
|
|
124
|
-
msg += `,视野内有${nonTeammates.length}人,不适合动手。`;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const completed = ctx.taskData.filter(t => t.status === 'completed').length;
|
|
128
|
-
const total = ctx.taskData.length;
|
|
129
|
-
msg += ` 任务进度 ${completed}/${total}。`;
|
|
130
|
-
|
|
131
|
-
ctx.notifications.push(msg);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import type { GameState } from '../../sdk/types.js';
|
|
2
|
-
import { Action } from '../../sdk/action.js';
|
|
3
|
-
import {
|
|
4
|
-
isInRoom,
|
|
5
|
-
patrolStrategyIntent,
|
|
6
|
-
PROGRESS_INTERVAL_MS,
|
|
7
|
-
resolveRoom,
|
|
8
|
-
setStrategyIntent,
|
|
9
|
-
strategyDecision,
|
|
10
|
-
} from '../game-utils.js';
|
|
11
|
-
import type { BehaviorDecision, RoomTarget, StrategyContext } from '../types.js';
|
|
12
|
-
import { Goal } from './goal.js';
|
|
13
|
-
|
|
14
|
-
export type RoomArrival = (state: GameState, target: RoomTarget) => boolean;
|
|
15
|
-
|
|
16
|
-
const arrivedByRoomName: RoomArrival = (state, target) => isInRoom(target.name, state);
|
|
17
|
-
|
|
18
|
-
export interface MoveRoomGoalOptions {
|
|
19
|
-
emitProgress?: boolean;
|
|
20
|
-
stopOnPlayer?: boolean;
|
|
21
|
-
/** Human-readable purpose such as "巡逻" or "巡逻寻找人群". */
|
|
22
|
-
purpose?: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export class MoveRoomGoal extends Goal {
|
|
26
|
-
constructor(
|
|
27
|
-
public readonly room: string,
|
|
28
|
-
private readonly hasArrived: RoomArrival = arrivedByRoomName,
|
|
29
|
-
private readonly options: MoveRoomGoalOptions = {},
|
|
30
|
-
) {
|
|
31
|
-
super();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
35
|
-
const target = resolveRoom(this.room, ctx);
|
|
36
|
-
this.emitProgress(state, ctx, target);
|
|
37
|
-
if (!target) {
|
|
38
|
-
setStrategyIntent(ctx, {
|
|
39
|
-
activity: 'waiting',
|
|
40
|
-
summary: `暂时找不到目标房间“${this.room}”,正在${state.you.room || '当前位置'}等待地图信息。`,
|
|
41
|
-
...(state.you.room ? { room: state.you.room } : {}),
|
|
42
|
-
});
|
|
43
|
-
return [];
|
|
44
|
-
}
|
|
45
|
-
if (this.hasArrived(state, target)) {
|
|
46
|
-
setStrategyIntent(ctx, {
|
|
47
|
-
activity: 'idle',
|
|
48
|
-
summary: `已到达${target.name},等待下一步指令。`,
|
|
49
|
-
room: target.name,
|
|
50
|
-
});
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
const intent = this.options.purpose
|
|
54
|
-
? patrolStrategyIntent(target, this.options.purpose)
|
|
55
|
-
: {
|
|
56
|
-
activity: 'moving' as const,
|
|
57
|
-
summary: `正在前往${target.name}。`,
|
|
58
|
-
room: target.name,
|
|
59
|
-
};
|
|
60
|
-
setStrategyIntent(ctx, intent);
|
|
61
|
-
return [strategyDecision(
|
|
62
|
-
Action.move({ x: target.x, y: target.y }, this.options.stopOnPlayer ?? false),
|
|
63
|
-
intent,
|
|
64
|
-
)];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
isFinish(state: GameState, ctx: StrategyContext): boolean {
|
|
68
|
-
const target = resolveRoom(this.room, ctx);
|
|
69
|
-
if (target == null) return false;
|
|
70
|
-
const finished = this.hasArrived(state, target);
|
|
71
|
-
if (finished) {
|
|
72
|
-
this.emitProgress(state, ctx, target);
|
|
73
|
-
setStrategyIntent(ctx, {
|
|
74
|
-
activity: 'idle',
|
|
75
|
-
summary: `已到达${target.name},等待下一步指令。`,
|
|
76
|
-
room: target.name,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
return finished;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
private emitProgress(state: GameState, ctx: StrategyContext, target: RoomTarget | null): void {
|
|
83
|
-
if (this.options.emitProgress === false) return;
|
|
84
|
-
|
|
85
|
-
const now = Date.now();
|
|
86
|
-
if (now - ctx.lastProgressNotifyAt < PROGRESS_INTERVAL_MS) return;
|
|
87
|
-
ctx.lastProgressNotifyAt = now;
|
|
88
|
-
|
|
89
|
-
const room = state.you.room ?? '未知房间';
|
|
90
|
-
if (!target) {
|
|
91
|
-
const available = ctx.rooms.map(room => room.name).join(', ') || '地图尚未加载';
|
|
92
|
-
ctx.notifications.push(`[进度] 当前在${room},找不到目标房间「${this.room}」。可用房间: ${available}。`);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (state.you.room === target.name) {
|
|
97
|
-
ctx.notifications.push(`[进度] 已到达目标房间「${target.name}」,当前位置${room}。`);
|
|
98
|
-
} else {
|
|
99
|
-
ctx.notifications.push(`[进度] 当前在${room},正在前往目标房间「${target.name}」。`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|