diff --git a/.tmp-edge-profile/Crashpad/metadata b/.tmp-edge-profile/Crashpad/metadata new file mode 100644 index 0000000..e69de29 diff --git a/.tmp-edge-profile/Crashpad/settings.dat b/.tmp-edge-profile/Crashpad/settings.dat new file mode 100644 index 0000000..e76f11a Binary files /dev/null and b/.tmp-edge-profile/Crashpad/settings.dat differ diff --git a/.tmp-edge-profile/Crashpad/throttle_store.dat b/.tmp-edge-profile/Crashpad/throttle_store.dat new file mode 100644 index 0000000..9639e1b --- /dev/null +++ b/.tmp-edge-profile/Crashpad/throttle_store.dat @@ -0,0 +1 @@ +level=none expiry=0 diff --git a/.tmp-edge-profile/Variations b/.tmp-edge-profile/Variations new file mode 100644 index 0000000..a157215 --- /dev/null +++ b/.tmp-edge-profile/Variations @@ -0,0 +1 @@ +{"user_experience_metrics.stability.exited_cleanly":false,"variations_crash_streak":0} \ No newline at end of file diff --git a/PATCH_NOTES.md b/PATCH_NOTES.md index a18517f..0529b91 100644 --- a/PATCH_NOTES.md +++ b/PATCH_NOTES.md @@ -1,123 +1,23 @@ -# Patch notes +# v15.24.2 needs compliance fix -## 15.20.16 +This patch focuses on making the implementation closer to the need-system prompt. -- Added canonical item visual, food, and disease registries; wired food decay/visual helpers and mystery-drug disease sampling to registry data. -- Generated the tool palette from `TOOL_CATEGORIES` at runtime and removed duplicated category markup from `index.html`. -- Added compact family-tree personality tags, daily personality-change details, and selected-Tarinai rolling recent-change causes for personality, damage, item-effect, disease, and ant-carry changes. -- Added `InputModeManager` for touch-first mobile classification and `WeatherSystem` for weather transitions/rain-water spawning. -- Added central domain events for placement, eating, decay, effects, diseases, damage, death, birth, fights, ants, weather, and rain item drops. -- Moved item-effect modifiers, active summaries, apply/tick behavior callbacks, and food interest class queries into registries. -- Moved explosion-disease base infection chance reads into `DiseaseRegistry` while preserving protein/niterop disease multipliers. -- Moved serving-food nutrition and hunger-relief reads into `FoodRegistry`, including laxative's zero hunger relief. -- Routed direct love/fight/sleep item eating through `EffectRegistry` while preserving the previous bite-specific stress, fear, and sleep-disease chance behavior. -- Routed sleep drug, rain-water item, and water-bowl field visuals through `item_visual_registry.js`; added water-bowl icon-generation support. -- Moved canonical sound gains, sample paths, categories, cooldowns, and ID category mapping out of `audio.js` into `sound_pack.js`. -- Added named ant ecology extension hooks/comments without changing ant balance. -- Bumped cache/version references to `15.20.16`; documented the new source-of-truth rules. +## Fixed -## 15.20.12 +- Kept the six-need system as the behavior driver. +- Kept needs clamped/quantized and displayed as 0-10 values. +- Kept tied top-need random selection and tie reason text. +- Kept StructureRegistry and both buildable structures: grass_bed and plushie. +- Removed remaining mojibake strings in the main need/action implementation file. +- Changed safety fleeing so normal safety behavior no longer directly enters panic. +- Reworked stress so direct stress mutation is removed from the main behavior files. +- Stress is now recalculated from needs or projected needs via calculateStressFromNeeds. +- Added applyNeedShock/applyNeedRelief helpers and converted shock/relief events into need changes. +- Reworked enterPanic as a legacy adapter that converts old calls into need shock first. +- Panic/intimidate are now short reaction states triggered through need shock logic. +- Updated cache/version strings to 15.24.2. -- Updated documentation after inspecting the current game surface: field choices, startup flow, tool groups, chart/family/debug surfaces, localStorage settings, and validation fallback when Node is unavailable. -- Removed unused `css/styles.css` shim and no-op `js/ui_family.js` loader entry; refactored duplicate world initialization and allocation-heavy live-count paths. +## Notes -- Removed the unwanted item-effect speech bubbles listed in `docs/prompt.txt`. -- Reorganized the tool palette into color-coded collapsible groups: operation, food/water/grass, medicine/effects, habitat/living things, hazards/obstacles. -- Changed the tool UI ball icon to a soccer-ball emoji preview. -- Changed time phases: morning 05:00, day 10:00, evening 17:00, night 20:00. -- Increased genkotsu knockback for Tarinai and ants; genkotsu now also blasts zunchi away. -- Genkotsu damage now adds fear/stress and decreases Tarinai openness. -- Rain weather overlay is now diagonal streaks. Fallen rain-water items, zunda juice, and mercury remain horizontal oval item sprites. -- Tightened mobile operation UI visibility to smartphone-class compact touch devices. -- Sleep-disease Tarinai can be moved by ant hauling without snapping back to their sleep anchor. - -## 15.20.12 and earlier summary - -- Consolidated documentation into dense English files; left `docs/prompt.txt` untouched. -- Restored rain, revised water/zunda/mercury item sprites, added zunchi-slave head zunchi, fight win rate, fight defeat chance, and post-wake lock. -- Earlier patches added parameter items, persistent item effects, WebP assets, sound categories, push notifications, ant systems, family tree UI, performance manager, event bus, manifest generation, CSS split, and large-file JS split. - -## Debug patch: panic chain and action reasons - -- Removed the friend-only panic chain that made only a best friend follow a panic target. -- Added general nearby panic contagion: any nearby live tarinai in panic can cause another tarinai to panic. Neuroticism, distance, and current stress affect the probability. -- Added / completed visible action reasons for: - - eating all food and effect items - - eating grass, ant corpses, and zunchi - - drinking / touching water - - resting near stone, bed, and nest box - - sunbathing - - zunchi-slave avoidance - - being pinched / dragged - - firecracker blast panic - - explosion-disease blast panic - - falling object / stone / genkotsu impact - - high-speed ball collision - - high-speed tarinai collision - - intimidation, intimidation escape, fights, birth ritual, and thaw surprise - - fence-blocked path give-up -- Added state labels for `sunbath`, `ant_attack`, `ant_intimidate`, and `frozen`. -- Expanded target labels for all current tool/item target types, including medicine/effect items, ant corpses, ant nests, firecrackers, pushpins, signboards, and fences. -- Verification performed: - - `node --check` over every `js/*.js` - - state-label coverage scan: no uncovered tarinai states - - old friend-panic chain scan: zero matches - - -## おしり鋲・冷凍操作変更パッチ -- ずんちどれい化条件の喧嘩勝率を30%以下に変更。 -- 衰弱死因判定を厳格化。 -- 冷凍手段をクリック式から「つまむで冷凍UIへ運ぶ」方式へ変更。 -- 新アイテム「おしり鋲」を追加。刺さるとずんちを溜め、日光浴不可。抜くと溜まったずんちが高速で飛散。 -- 高速ずんち衝突時の吹き飛び・パニック理由文を追加。 - -## 15.22.0 統合リファクタ - -- `snapshot_system.js` を追加し、セーブ/ロードと冷凍で重複していた `clonePlain` / `copyOwnData` / `applyOwnData` / 参照復元 / スナップショット作成・復元を共通化。 -- `tarinai_action_state.js` を追加し、`setActionState()` / `enterPanic()` / `beginEating()` により、状態変更・パニック化・食事開始の理由文設定を統合。 -- 直接 `state = "panic"` していた処理を `enterPanic()` 経由へ変更。爆竹、爆発病、高速ボール、高速衝突、アリ、画鋲、近傍パニック連鎖、関係者死亡、解凍時の訃報などが対象。 -- 直接 `state = "eat"` していた食事処理を `beginEating()` 経由へ変更。 -- `physics_helpers.js` を追加し、壁反射・摩擦・回転を `TarinaiPhysics.applyKinematicItemMotion()` に共通化。おしり鋲/画鋲/高速ずんちの移動処理に適用。 -- `ITEM_TRAITS` と `PIN_BEHAVIORS` を追加し、アイテム分類と画鋲/おしり鋲の差分挙動をテーブル化。 -- `text_catalog.js` に状態ラベル、対象ラベル、理由文補完を集約。`ui_selected.js` はカタログ参照へ変更。 -- `family_graph.js` を追加し、家系グラフの連結成分探索を共通化。同期家系データと描画側に適用。 -- `relation_event_system.js` を追加し、関係者死亡の即時反応と冷凍個体への遅延通知を共通化。 -- `ui_helpers.js` を追加し、HTMLエスケープ等のUI共通処理を切り出し。 -- 構文チェック: 全 `js/*.js` OK。 -- 重複確認: `clonePlain` / `copyOwnData` / `applyOwnData` は `snapshot_system.js` に集約、直接 `state = "panic"` と直接 `state = "eat"` は除去済み。 - -## 15.23.0 safe duplicate integration pass - -- `registry_base.js` を追加し、`food_registry.js` / `effect_registry.js` / `disease_registry.js` の `get` / `has` / `label` / `color` / `debugSnapshot` 系の共通基盤を統合。 -- `patch_helpers.js` を追加し、後付けの `World.prototype` パッチを `TarinaiPatcher.patchWorld()` 経由に統合。冷凍・関係者死亡通知で利用。 -- `data.js` に `sleepFurniture` / `draggable` trait と、`isPinType()` / `isSleepFurnitureType()` / `lodgedPinFor()` / `hasLodgedPinEffect()` / `normalizedToolSizeFor()` / `toolSizeScaleFor()` を追加。 -- `ui_tools.js` と `world_view.js` のツールサイズ算出を `normalizedToolSizeFor()` / `toolSizeScaleFor()` に統合。 -- `tarinai_action_state.js` に `currentLodgedPin()` / `currentLodgedPinBehavior()` / `hasLodgedPinEffect()` / `goIdle()` / `startSleeping()` / `seekTarget()` を追加。 -- `blockedByOshibyo` 系の重複判定を `hasLodgedPinEffect("blocksZunchi")` に統合。 -- 画鋲/おしり鋲の型判定を `isPinType()` に寄せ、描画・配置・つまみ・削除判定の分岐を整理。 -- 睡眠家具判定を `isSleepFurnitureType()` に寄せ、ベッド/巣箱の直書き判定を削減。 -- 手動アリ近傍探索の一部を `world.nearbyAnts()` に寄せた。 -- `pruneExtinctFamilies()` を `TarinaiFamilyGraph.connectedComponents()` に寄せた。`family_graph.js` 側のデフォルト edge も親子参照を使うようにした。 -- `save_system.js` / `freeze_system.js` / `ui_selected.js` のHTMLエスケープを `TarinaiUIHelpers.htmlEscape()` に統合。 -- `assets.js` のスプライト/汚れオーバーレイ用キャンバス生成を `TarinaiPhysics.createCachedCanvas()` に寄せた。 -- 危険度の高い `render.js` 全体再設計、`Tarinai.update()` の状態機械化、`ants.js` の状態機械化、`items.js` 描画全体のレジストリ化は未実施。 -- 確認: 全 `js/*.js` の `node --check` 通過。 - -### 15.23.0 追確認 - -- `service-worker.js` / `app_manifest.json` のスクリプト一覧を `index.html` の実ロード順に同期。新規共通化ファイルもキャッシュ対象に追加。 -- アリ運搬中に寝ているたりないの状態変更も `startSleeping()` 経由へ寄せた。 -- 最終確認: 全 `js/*.js` と `service-worker.js` の `node --check` 通過。 -- 最終確認: `blockedByOshibyo`、`type === "oshibyo"`、`type === "pushpin"` の直接判定は 0件。`clonePlain` / `copyOwnData` / `applyOwnData` / `isPlainObject` は `snapshot_system.js` のみ。 - -## 15.24.0 safe integration / UI escape recursion fix - -- Fixed `Maximum call stack size exceeded` caused by `ui_helpers.htmlEscape()` calling the global `escapeHtml()` while `ui_selected.escapeHtml()` called back into `TarinaiUIHelpers.htmlEscape()`. -- Made `TarinaiUIHelpers.htmlEscape()` a pure escaping function and loaded `ui_helpers.js` before `ui_selected.js`. -- Added a guard in `ui_selected.escapeHtml()` so it never delegates to itself. -- Added a data URL favicon link to stop the browser's default `/favicon.ico` 404 request. -- Bumped static asset version to `15.24.0` in `app_manifest.json`, `index.html`, `service-worker.js`, and `js/version.js` to avoid stale cached scripts. -- Reduced target-label duplication: item labels now come from `TOOL_DEFINITIONS` / `toolLabel()`, with `text_catalog.js` holding only non-tool overrides. -- Removed the remaining synchronous family-tree DFS fallback blocks in `ui_family_data.js` and `ui_family_render.js`; both now use `TarinaiFamilyGraph.connectedComponents()`. -- Simplified the remaining manual ant proximity fallback in `tarinai_needs_items.js` to `world.nearbyAnts()`. -- Verification: all `js/*.js` and `service-worker.js` pass `node --check`. +- Old save compatibility is intentionally not provided. +- Some legacy fields such as loneliness, affection, mood, and fearTimer still exist as compatibility/input/display fields, but the main action selection now uses the six needs. diff --git a/app_manifest.json b/app_manifest.json index fdd5ec8..b9cdf68 100644 --- a/app_manifest.json +++ b/app_manifest.json @@ -1,5 +1,5 @@ { - "version": "15.24.0", + "version": "15.24.2", "css": [ "css/base.css", "css/layout.css", diff --git a/css/components.css b/css/components.css index 1e02c43..119532a 100644 --- a/css/components.css +++ b/css/components.css @@ -451,6 +451,13 @@ .selected-info .info-row[data-metric="loneliness"] { background: rgba(116, 150, 214, 0.10); } .selected-info .info-row[data-metric="energy"] { background: rgba(104, 184, 96, 0.10); } .selected-info .info-row[data-metric="stress"] { background: rgba(214, 104, 88, 0.10); } +.selected-info .need-row[data-chosen-need="true"] { + border-color: rgba(65, 112, 74, 0.52); + background: rgba(106, 154, 84, 0.16); +} +.selected-info .need-row[data-chosen-need="true"] strong { + color: #315f32; +} .selected-info .info-row[data-metric="zunchi"] { background: rgba(112, 142, 70, 0.10); } .selected-info .info-row[data-metric="mood"] { background: rgba(222, 196, 86, 0.10); } .selected-info .info-row[data-metric="lack"] { background: rgba(142, 112, 184, 0.10); } diff --git a/docs/prompt.txt b/docs/prompt.txt index 636a065..1950df9 100644 --- a/docs/prompt.txt +++ b/docs/prompt.txt @@ -1,466 +1,860 @@ -You are working on the browser game "たりないコロニー" based on the current ZIP/project state, assumed to be v15.20.3. - -Goal: resolve the remaining internal design confusion and underdeveloped systems, while preserving existing gameplay unless explicitly requested below. - -Hard exclusions: - -* Do NOT implement field-size balance tuning. Specifically do not implement the previously proposed "field-specific balance correction" work. -* Do NOT implement save/load. -* Do NOT implement debug scenario modes. -* Do NOT redesign or expand the zunchi system. Keep zunchi mechanics and general design as-is, except where existing code must be connected through registries/events without changing behavior. -* Do NOT modify `docs/prompt.txt` if present. -* Do not introduce a build toolchain requirement. Plain static HTML/CSS/JS must still run directly. - -Primary requirements: - -1. Make item visuals single-source-of-truth. - -* Current problem: field item rendering, tool UI icons, generated WebP icons, documentation, and item definitions can diverge. -* Establish one canonical visual definition per item/tool. -* Field rendering must be the primary visual source, or both field rendering and UI preview must derive from the same canonical visual descriptor. -* The tool UI must never have an independently invented appearance. -* Create or consolidate a visual registry, for example `js/item_visual_registry.js`, with descriptors such as: - - * `renderer` - * `shape` - * `palette` - * `scale` - * `uiPreviewScale` - * `fieldScale` - * `accessibleShapeTraits` - * optional `emojiFallback` -* Update field rendering and UI icon generation/preview so they share this registry. -* Fix visual drift for all known drift-prone items: - - * ammo - * mystery drug - * laxative - * sleeping drug - * protein - * nietorop - * giant drug - * dwarf drug - * zunda juice - * mercury - * rain-water item - * ball -* Keep the rule in docs: UI icon is a preview of the field visual, not a separate design. -* Ensure scalable items correctly respond to small/medium/large placement size. - -2. Data-drive tool categories. - -* Current problem: tool category membership/order/color is partly hardcoded in HTML/CSS and not owned by tool data. -* Move tool categories into a data registry, for example `js/tool_registry.js` or `js/data.js`. -* The registry must define: - - * category id - * Japanese label - * color/theme class - * sort order - * tool ids included in that category -* Generate/build the tool UI from this registry at runtime. -* Keep collapsible category behavior. -* Keep simple category color coding. -* Remove duplicated static category definitions from `index.html` where possible. -* Category changes must require editing only the registry, not HTML. - -3. Convert EffectRegistry from display-only to real behavior ownership. - -* Current problem: `effect_registry.js` mainly handles labels/display/random candidates, while actual behavior remains scattered in Tarinai/item code. -* Promote `EffectRegistry` into the canonical owner for item effect metadata and behavior. -* Each effect should define, where relevant: - - * `id` - * Japanese label - * duration or permanent flag - * exclusive group - * stack behavior - * display color - * display summary - * modifiers - * `onApply(tarinai, context)` - * `onTick(tarinai, dt, context)` - * `onRemove(tarinai, context)` - * visual effect id - * bubble policy - * whether it is eligible for "怪しい薬" - * whether it is removed by "ずんだ汁" -* Migrate these item effects into the registry: - - * laxative - * protein - * nietorop - * ammo - * mystery drug - * mercury - * giant drug - * dwarf drug - * zunda juice clearing behavior - * heko mochi timed effect - * fight mochi timed effect - * sleeping drug if it changes behavior -* Existing semantics must remain: - - * laxative: emits zunchi every 3 seconds during effect; eating does not reduce hunger because it immediately passes through. - * protein: permanent; damage dealt x1.75; disease chance x0.5; red upward particles; mutually exclusive with nietorop; latest wins. - * nietorop: permanent; damage dealt x0.5; disease chance x2; purple downward particles; mutually exclusive with protein; latest wins. - * ammo: timed; walking speed x10; while moving, collision with Tarinai/ants knocks them away. - * mystery drug: grants random two effects from behavior-changing item effects and diseases. - * mercury: each consumption multiplicatively increases lifespan by x1.3. - * giant drug: permanent; size x3; damage x2; speed x1.5; 1 damage/sec; mutually exclusive with dwarf drug; latest wins. - * dwarf drug: permanent; size x0.25; damage x0.25; speed x0.5; 1 damage/sec; mutually exclusive with giant drug; latest wins. - * zunda juice: removes all removable item effects. -* "たりないデータ" must read active item effects from the registry, not hand-built scattered conditions. - -4. Add DiseaseRegistry and connect disease behavior. - -* Current problem: diseases are individual booleans/branches and are not uniformly represented. -* Add `DiseaseRegistry` or equivalent. -* It must define: - - * disease id - * Japanese label - * symptoms/behavior flags - * infection chance modifiers - * cure rules - * display text - * visual/bubble policy - * eligibility for mystery drug -* Migrate these diseases into registry metadata while preserving behavior: - - * zunchi disease - * sleep disease - * explosion disease - * fight disease -* Explosion disease infection probability must remain 15% where currently defined, with protein/nietorop disease multipliers applied to that base. -* Mystery drug must sample diseases through this registry. -* Zunda juice should remove item effects, not necessarily diseases, unless current semantics already remove a given disease; do not silently change disease cure rules. - -5. Add FoodRegistry and centralize food semantics. - -* Current problem: food interest, nutrition, decay, hygiene penalty, cures, and special exceptions are scattered. -* Add `FoodRegistry`. -* It must define: - - * item id/type - * Japanese label - * nutrition - * palatability/interest class - * decay profile - * hygiene penalty on decay - * special effect id, if eating applies an effect - * whether it counts as grass-like interest, zunda-mochi high interest, medicine-like low interest, water, corpse, etc. -* Preserve existing behavior: - - * zunda mochi remains highly attractive. - * most non-zunda foods remain only slightly more interesting than grass. - * all food naturally decays about twice per half-day, not continuously. - * decay slightly reduces hygiene stats at those discrete decay ticks. - * laxative effect prevents hunger reduction from eating. -* `Tarinai` food-seeking logic must consult `FoodRegistry`. -* Food decay logic must consult `FoodRegistry`. -* Tooltips/descriptions should remain Japanese and current user-facing wording must not regress. - -6. Separate WeatherSystem from water items. - -* Current problem: rain visual effects and rain-spawned items/water-like items are conceptually mixed. -* Create or isolate a `WeatherSystem`. -* Explicitly separate: - - * `rain_visual`: diagonal blue-ish streaks/lines falling at an angle. - * `rain_water_item`: horizontal oval water item dropped by rain. - * `water_bowl`: placed water object. - * `zunda_juice`: green horizontal oval liquid item. - * `mercury`: gray horizontal oval liquid item. -* Do not reuse rain visual renderer for item droplets. -* Do not render rain effect as oval droplets. Rain effect must be angled falling lines. -* Do not render zunda juice or mercury with diagonal lines. -* Preserve current rain gameplay behavior. -* Add code comments documenting the distinction so future changes do not confuse them. - -7. Apply event bus more broadly. - -* Current problem: logs, sounds, notifications, stats, effects, and debug traces are still partly direct calls. -* Use the existing event bus or strengthen it. -* Add domain events for: - - * `tool:placed` - * `item:eaten` - * `item:decayed` - * `effect:applied` - * `effect:removed` - * `disease:infected` - * `disease:cured` - * `tarinai:damaged` - * `tarinai:died` - * `tarinai:born` - * `fight:hit` - * `fight:lost` - * `fight:ended` - * `ant:spawned` - * `ant:grabbed` - * `ant:carried` - * `ant:died` - * `weather:changed` - * `rain:itemDropped` -* Logs, push notifications, audio, stats, and debug history should subscribe to events where practical. -* Do not rewrite everything destructively. Add event emission at central points first, then migrate obvious direct calls. -* Avoid duplicate logs/sounds. - -8. Sound system source-of-truth cleanup. - -* Current problem: `sound_pack.js` and `audio.js` both contain overlapping settings. -* Make `sound_pack.js` the canonical metadata source for: - - * sound id - * category - * volume multiplier - * cooldown - * sample path - * fallback synthesis profile -* `audio.js` should be the playback engine only: - - * loading samples - * fallback synthesis - * category enable/disable - * master gain - * cooldown enforcement - * concurrent voice limiting -* Keep the current user settings: - - * master effect sound on/off - * Tarinai voice - * notification - * operation -* Do not regress volume. The previous issue was that only the first sound was loud and subsequent sounds became too quiet. Preserve the fixed master gain behavior. -* Keep `?debug=1` showing recent sound IDs and sound-pack version. - -9. Mobile input manager. - -* Current problem: mobile operation UI has appeared on PC repeatedly. -* Add a single `InputModeManager` or equivalent. -* It must own: - - * `isTouchDevice` - * `isCompactViewport` - * `hasHover` - * `pointerCoarse` - * `userAgentMobile` - * `currentMode` - * `gestureState` - * whether canvas can pan - * whether canvas can place tools - * whether family tree is allowed to capture touch -* Mobile operation UI must appear only when the device is clearly touch-first: - - * coarse pointer - * no hover - * real touch support - * and either compact viewport or mobile/tablet UA -* Desktop PCs with touch screens must not automatically show the mobile UI unless the viewport/UA also indicates mobile/tablet. -* Add debug display of the input classification under `?debug=1`. -* Keep existing modes: - - * auto - * camera - * tool - * family tree - -10. Ant system cleanup and extension hooks, without broad balance changes. - -* Do not create a full new ant ecology balance pass. -* Do consolidate ant domain events and state names. -* Preserve existing behavior: - - * ants can carry sleeping Tarinai. - * sleeping Tarinai do not wake just because ants carry them. - * sleeping Tarinai do not counterattack ants while asleep. - * ants without nests either join another available nest or wander. - * empty nests are removed. - * queen ants are visually larger. -* Add clear extension hooks or comments for future ant ecology: - - * nest hunger - * nest growth - * queen reproduction - * worker lifecycle - * carrying success rate - * territorial behavior -* Do not implement those future mechanics now unless already present. - -11. Family tree: add personality tags. - -* The family tree currently records lineage but should expose personality more directly. -* Add compact personality tags to each Tarinai node/card in the family tree. -* Use existing personality axes: - - * aggression - * openness - * sociability - * neuroticism -* Tags should be short Japanese labels, for example: - - * aggressive/high aggression - * calm/low aggression - * curious/high openness - * cautious/low openness - * social/high sociability - * solitary/low sociability - * nervous/high neuroticism - * stable/low neuroticism -* Use at most 2-3 tags per node to avoid clutter. -* Make tags visually subtle and compact. -* Do not break existing family tree panning/zooming/layout. -* If a Tarinai is dead, still show its personality tags if data exists. - -12. Tarinai data panel: show recent change causes. - -* The Tarinai individual data panel must include recent reasons for personality/state changes. -* Add a small "recent change causes" section. -* Record recent causes when personality or important state changes happen, for example: - - * genkotsu damage: fear increase and openness decrease - * fight win/loss - * being carried by ants - * disease infection/cure - * protein/nietorop - * giant/dwarf drug - * mercury consumption - * zunda juice clearing effects - * sleep/wake transitions where meaningful - * stress/fear significant changes -* Store only a short rolling history per Tarinai, for example last 5-8 entries. -* Each entry should include: - - * Japanese short reason - * affected stat/effect - * approximate in-game time or "recent" -* This is UI/diagnostic information, not save/load. -* Do not add full persistence. - -13. Personality system visibility. - -* The existing personality axes are meaningful but currently not visible enough. -* In addition to family tree tags and recent change causes, improve the Tarinai data panel to make personality effects understandable: - - * show current personality values already present, if available - * show the most recent cause next to changed values where practical - * avoid long prose; use compact labels. -* Do not add new personality axes. - -14. Documentation consolidation and English-only high-density docs. - -* Keep `docs/prompt.txt` untouched. -* Keep documentation concise, English-only, and high information density. -* Update or consolidate docs so the following source-of-truth rules are explicit: - - * item visuals come from the canonical visual registry. - * UI icons are previews, not independent art. - * tool categories come from the tool registry. - * item effects come from EffectRegistry. - * diseases come from DiseaseRegistry. - * food behavior comes from FoodRegistry. - * rain visuals are separate from rain-spawned water items. - * zunchi is intentionally unchanged. - * no field balance, save/load, or debug scenario implementation in this pass. -* Avoid many small docs. Prefer a small set such as: - - * `docs/ARCHITECTURE.md` - * `docs/CONTENT_GUIDE.md` - * `docs/MAINTENANCE.md` -* Remove obsolete docs if safely redundant. -* Do not delete `docs/prompt.txt`. - -15. Preserve user-facing Japanese UI text unless intentionally specified. - -* Game UI remains Japanese. -* Docs are English. -* The Codex implementation may use English comments for architecture, but visible labels/tooltips remain Japanese. - -16. Regression fixes to preserve. - Do not regress the following existing fixes: - -* Removed unwanted bubbles: - - * ドン - * ぐるる - * すっきり - * Hg xN - * ちまっ - * でかっ - * へにゃ - * ムキッ - * mm... -* Ball tool UI icon must be soccer ball emoji. -* Time periods: - - * morning starts at 05:00 - * noon/day starts at 10:00 - * evening starts at 17:00 - * night starts at 20:00 -* Genkotsu: - - * stronger knockback for living things - * zunchi is knocked away - * damaged Tarinai gain fear and lose openness -* Rain visual: - - * diagonal angled line rain, not droplets. -* Rain-spawned water item / zunda juice / mercury: - - * horizontal oval item visuals. -* Sleeping Tarinai: - - * can be carried by ants - * do not wake from ant carrying - * do not attack ants while sleeping - * after waking, remain awake for at least 10 seconds. -* Tarinai data: - - * fight win rate instead of cumulative defeats. -* Fight: - - * on taking damage, Tarinai may lose/flee probabilistically. - * high aggression lowers loss chance. - * high damage and low HP increase loss chance. - -17. Versioning and cache. - -* Bump app version to the next patch/minor version consistently. -* Update: - - * version file - * service worker cache name - * asset query versions - * manifest if present -* Ensure `service-worker.js` itself remains no-cache/no-store. -* Ensure generated app manifest validation still passes. - -18. Validation. - Run and report: - -* `node --check js/*.js service-worker.js` -* manifest validation/generation check if scripts exist -* zip integrity check if packaging -* basic static grep checks: - - * no stale app version references - * no removed bubble strings still emitted as bubbles - * mobile UI visibility logic uses the new InputModeManager - * tool categories are not duplicated in `index.html` - * sound metadata is not duplicated as canonical data in both `sound_pack.js` and `audio.js` - * item visual drift-prone items use canonical visual registry - * docs are English except `docs/prompt.txt` - -Deliverables: - -* Updated project files. -* Updated ZIP. -* Brief implementation summary. -* Validation results. -* Mention any deliberately deferred items: - - * field balance tuning - * save/load - * debug scenario modes - * zunchi expansion +Implement the new need-driven behavior system for the existing “tarinai” observation game. + +Keep the implementation simple, localized, and compatible with the existing architecture. Do not perform a broad rewrite unless absolutely necessary. + +Important source-code text rule: +All newly added Japanese UI strings or Japanese reason/action strings in source code must be written as Unicode escape sequences, not raw Japanese characters. + +Example: +Do not write: +"あぶないけど、食べた。" + +Write: +"\u3042\u3076\u306a\u3044\u3051\u3069\u3001\u98df\u3079\u305f\u3002" + +Runtime text may display Japanese, but source literals must be escaped. + +============================================================ +GOAL +============================================================ + +Replace or absorb the existing detailed emotion-driven behavior system into a simple six-need system. + +Behavior should be selected from six needs: + +- food +- sleep +- health +- safety +- social +- fulfill + +The system should allow imperfect behavior. + +Example: +If safety and food are both maxed, the tarinai may randomly choose food and eat even though it is dangerous. + +============================================================ +1. SIX NEEDS +============================================================ + +Each tarinai should have: + +needs = { + food: 0, + sleep: 0, + health: 0, + safety: 0, + social: 0, + fulfill: 0 +}; + +Meaning: + +food: +- eating +- drinking + +sleep: +- sleep +- rest +- tiredness + +health: +- illness +- injury +- dirt +- poison +- recovery + +safety: +- danger +- fear +- ants +- explosions +- punches +- being attacked + +social: +- friends +- parent/child +- mating/reproduction +- enemies if existing relation logic supports it + +fulfill: +- play +- owned place +- owned structure +- grass bed +- plushie +- simple construction + +Each need is internally 0–100. + +After raw calculation, quantize each value to 10-point steps: + +0, 10, 20, ... 100 + +Use a helper like: + +function quantizeNeed(value) { + return Math.max(0, Math.min(100, Math.round(value / 10) * 10)); +} + +For UI display, show only the tens digit: + +0, 1, 2, ... 10 + +Example: +internal value 80 -> display 8 +internal value 100 -> display 10 + +Safety is capped at 100 like every other need. +Safety is not a hard interrupt. + +============================================================ +2. NEED CALCULATION +============================================================ + +Calculate needs from existing tarinai/world state where possible. + +Suggested mapping: + +food: +- hunger +- thirst if available + +sleep: +- low energy +- long awake time if available +- night/time-of-day bonus if available + +health: +- disease +- injury +- dirtiness +- poison or negative status if available + +safety: +- nearby ants +- nearby dangerous items +- recent damage +- fear/panic-related existing state if any +- being attacked +- owned structure destruction shock + +social: +- loneliness if available +- nearby friend / parent / child +- reproduction readiness +- enemy proximity if current relation system supports it + +fulfill: +- wants to play +- has no owned structure +- wants to return to owned grass bed +- wants to carry/use plushie +- wants to build a simple owned structure + +Use existing personality fields if available: + +aggression: +- safety rises slightly less from danger +- may choose intimidate instead of panic when there is a breaker/attacker + +openness: +- fulfill rises more easily +- play/build actions become more likely + +sociability: +- social rises more easily +- reacts less negatively when others use owned structures + +neuroticism: +- safety and health rise more easily +- owned structure damage/destruction has stronger effect + +Keep personality modifiers small and easy to tune. + +============================================================ +3. ACTION SELECTION +============================================================ + +Use this behavior flow: + +1. Calculate all six raw needs. +2. Quantize all needs. +3. Find the maximum need value. +4. Collect all needs equal to the maximum. +5. Randomly choose one need from that tied top set. +6. Choose an executable action associated with that chosen need. +7. Store the chosen need and action in tarinai.intent. +8. Highlight only the chosen need in the tarinai data UI. + +If safety and food are both 100, either may be chosen randomly. + +Add helpers: + +- createDefaultNeeds() +- quantizeNeed(value) +- updateNeeds(tarinai, world) +- chooseTopNeedRandom(needs) +- chooseActionForNeed(need, tarinai, world) +- buildReasonText(chosenNeed, tiedNeeds, action) +- getNeedDisplayValue(value) + +============================================================ +4. SIMPLE ACTION DEFINITIONS +============================================================ + +Use a simple action list, not a complex behavior tree. + +Each action should have: + +- id +- need +- label +- phrase +- weight +- condition(tarinai, world) +- run(tarinai, world) + +Example shape: + +const TARINAI_ACTIONS = [ + { + id: "eat_food", + need: "food", + label: "\u98df\u3079\u7269\u3092\u63a2\u3057\u3066\u3044\u308b", + phrase: "\u98df\u3079\u305f", + weight: 50, + condition(t, world) { + return !!findNearestItemWithRole(world, t, "food"); + }, + run(t, world) { + const item = findNearestItemWithRole(world, t, "food"); + moveToOrUse(t, item); + } + } +]; + +Suggested actions: + +food: +- eat_food +- drink_water + +sleep: +- sleep_in_bed +- sleep_in_owned_structure +- sleep_anywhere + +health: +- use_medicine +- wash_or_drink_water +- rest_to_recover + +safety: +- flee +- hide_in_nest +- hide_at_owned_structure + +social: +- approach_friend +- approach_parent_or_child +- approach_mate +- intimidate_enemy + +fulfill: +- play +- wander_lightly +- build_grass_bed +- build_plushie +- return_owned_structure +- use_plushie + +Use weighted random among executable actions for the chosen need. + +If no action is executable, fall back to idle, wander, or rest. + +Do not make tarinai perfectly optimal. + +============================================================ +5. TIE REASON TEXT +============================================================ + +If multiple needs are tied for highest and the chosen need is only one of them, generate: + +“[ignored need phrase]\u3051\u3069\u3001[chosen action phrase]\u3002” + +Examples: +- "\u3042\u3076\u306a\u3044\u3051\u3069\u3001\u98df\u3079\u305f\u3002" +- "\u306d\u3080\u3044\u3051\u3069\u3001\u4ef2\u9593\u306b\u8fd1\u3065\u3044\u305f\u3002" +- "\u304a\u306a\u304b\u304c\u3059\u3044\u3066\u3044\u308b\u3051\u3069\u3001\u81ea\u5206\u306e\u5bdd\u5e8a\u3078\u623b\u3063\u305f\u3002" +- "\u8abf\u5b50\u304c\u60aa\u3044\u3051\u3069\u3001\u904a\u3093\u3060\u3002" + +When multiple ignored needs exist, mention the ignored need with highest priority: + +safety > health > food > sleep > social > fulfill + +Conflict phrases: + +food: +"\u304a\u306a\u304b\u304c\u3059\u3044\u3066\u3044\u308b" + +sleep: +"\u306d\u3080\u3044" + +health: +"\u8abf\u5b50\u304c\u60aa\u3044" + +safety: +"\u3042\u3076\u306a\u3044" + +social: +"\u3060\u308c\u304b\u304c\u6c17\u306b\u306a\u308b" + +fulfill: +"\u81ea\u5206\u306e\u5834\u6240\u304c\u6c17\u306b\u306a\u308b" + +If there is no tie, use: + +“[need phrase]\u306e\u3067\u3001[action phrase]\u3002” + +Store: + +tarinai.intent = { + need: chosenNeed, + tiedNeeds, + actionId: action.id, + actionLabel: action.label, + reasonText +}; + +============================================================ +6. NEED UI +============================================================ + +Update the tarinai data UI. + +Show six needs as 0–10 values. + +Labels must be escaped in source: + +food label: +"\u6442\u990c" + +sleep label: +"\u7761\u7720" + +health label: +"\u5065\u5eb7" + +safety label: +"\u5b89\u5168" + +social label: +"\u95a2\u4fc2" + +fulfill label: +"\u5145\u8db3" + +Example UI: + +摂餌 8 +睡眠 3 +健康 1 +安全 10 +関係 4 +充足 10 ★ + +Only the need actually chosen for the current action receives the highlight. + +Also show: + +"\u3044\u307e": +[action label] + +"\u7406\u7531": +[reasonText] + +Do not show detailed need breakdowns. +Do not add graphs or extra panels. + +============================================================ +7. ITEM ROLES AND NEED EFFECTS +============================================================ + +Use minimal item roles and needEffects. + +Do not create a broad tag system. + +Item example: + +item.roles = { + food: true, + drink: true, + medicine: true, + sleepPlace: true, + danger: true, + grassMaterial: true +}; + +item.needEffects = { + food: 0, + sleep: 0, + health: 0, + safety: 0, + social: 0, + fulfill: 0 +}; + +Only add roles that are actually needed by the new behavior. + +Useful helpers: + +- findNearestItemWithRole(world, tarinai, role) +- findNearestSleepPlace(world, tarinai) +- findNearbyDanger(world, tarinai) +- findNearbyMaterial(world, tarinai, materialRole) + +Adapt to existing item registries where possible. + +============================================================ +8. STRUCTURE REGISTRY +============================================================ + +Keep StructureRegistry because tarinai-built structures will expand in the future. + +Do not collapse structures into one-off special item cases. + +Create or adapt a small StructureRegistry for buildable tarinai structures. + +Shared structure instance shape: + +{ + id, + type, + isStructure: true, + ownerId, + hp, + attachment, + usedCount, + x, + y, + roles, + needEffects +} + +Do not implement: +- repair +- inheritance +- ownership privacy +- material-carrying inventory +- complex construction logistics + +First buildable structures: + +- grass_bed +- plushie + +============================================================ +9. STRUCTURE: GRASS BED +============================================================ + +Structure type: +"grass_bed" + +Japanese label, escaped: +"\u8349\u306e\u7c21\u6613\u30d9\u30c3\u30c9" + +Concept: +A simple bed made from grass. It is an owned place. The owner prefers it for sleep, safety, and fulfill. + +Example registry entry shape: + +grass_bed: { + type: "grass_bed", + label: "\u8349\u306e\u7c21\u6613\u30d9\u30c3\u30c9", + buildNeed: "fulfill", + buildTime: 4, + maxHp: 100, + materials: { + grassMaterial: 1 + }, + roles: { + sleepPlace: true, + ownedStructure: true + }, + needEffects: { + food: 0, + sleep: 60, + health: 5, + safety: 25, + social: 0, + fulfill: 40 + }, + create(owner, x, y, world) { + return { + id: createId("structure"), + type: "grass_bed", + isStructure: true, + ownerId: owner.id, + hp: 100, + attachment: 20, + usedCount: 0, + x, + y, + roles: this.roles, + needEffects: this.needEffects + }; + }, + onUse(user, structure, world) { + // owner gets stronger effects + // non-owner gets weaker effects + // owner use increases attachment + }, + onDestroyed(structure, world, breaker) { + // increase owner safety and fulfill + // trigger panic or intimidate through need shock logic + } +} + +Build condition: +- chosen need is fulfill +- tarinai has no owned grass_bed +- grass material is nearby +- tarinai is not sleeping, fighting, or panicking + +Build process: +- move near grass +- spend short build time if existing state system supports it +- consume/reduce grass if easy +- create grass_bed through StructureRegistry + +Owner behavior: +- owner prefers own grass_bed for sleep, safety, and fulfill +- using own grass_bed reduces sleep, safety, and fulfill +- using own grass_bed increases attachment + +Other tarinai: +- may use it with weaker effects +- if owner sees another tarinai using it: + - aggression may cause intimidate + - neuroticism may increase safety/fulfill + - sociability reduces negative reaction + +Destruction: +- hp can be reduced by explosions, punches, weather, repeated use, or existing damage sources if easy to connect +- when hp reaches 0, call onDestroyed and remove structure + +============================================================ +10. STRUCTURE: PLUSHIE +============================================================ + +Add a new tarinai-built structure: + +type: +"plushie" + +Japanese label, escaped: +"\u306c\u3044\u3050\u308b\u307f" + +Concept: +A small plushie item that resembles a tarinai. It is made from grass. When completed, it attaches to the owner tarinai’s head. While attached, it reduces fulfill. If damaged, it breaks and disappears. The owner receives a strong need shock and enters panic or intimidate. + +Example registry entry shape: + +plushie: { + type: "plushie", + label: "\u306c\u3044\u3050\u308b\u307f", + buildNeed: "fulfill", + buildTime: 4, + maxHp: 1, + materials: { + grassMaterial: 1 + }, + roles: { + carriedObject: true, + ownedStructure: true, + fulfillObject: true + }, + needEffects: { + food: 0, + sleep: 0, + health: 0, + safety: 5, + social: 0, + fulfill: 50 + }, + create(owner, x, y, world) { + return { + id: createId("structure"), + type: "plushie", + isStructure: true, + ownerId: owner.id, + hp: 1, + attachment: 30, + usedCount: 0, + x, + y, + carriedById: owner.id, + onHead: true, + roles: this.roles, + needEffects: this.needEffects + }; + }, + onUse(user, structure, world) { + // if owner carries/uses it, reduce fulfill + // optionally reduce safety slightly + // increase attachment slightly + }, + onDestroyed(structure, world, breaker) { + // large shock to owner safety and fulfill + // trigger panic or intimidate + } +} + +Build condition: +- chosen need is fulfill +- tarinai does not already own/carry a plushie +- grass material is nearby +- tarinai is not sleeping, fighting, or panicking + +Build process: +- move near grass +- spend short build time if existing state system supports it +- consume/reduce grass if easy +- create plushie through StructureRegistry +- attach it to owner’s head + +Behavior while attached: +- follow owner position +- render above owner’s head +- use same or similar sprite as tarinai, scaled down +- reduce fulfill over time or when used +- optionally reduce safety slightly +- do not implement inventory + +Damage/destruction: +- any meaningful damage destroys it +- remove plushie +- increase owner safety and fulfill strongly +- trigger panic or intimidate through need shock logic + +Do not implement: +- repair +- inheritance +- trading +- inventory +- multiple plushies per tarinai + +============================================================ +11. EMOTION SYSTEM SIMPLIFICATION +============================================================ + +Remove the old detailed emotion system as a behavior driver. + +Behavior must be selected only from the six needs: +food, sleep, health, safety, social, fulfill. + +Old emotions should be removed or absorbed: + +fear -> safety +loneliness -> social +happiness -> low stress / low fulfill pressure +sadness -> fulfill/social/safety pressure +comfort -> sleep/safety/fulfill satisfaction +boredom -> do not implement +anger -> intimidate state only +panic -> need shock reaction +stress -> derived pressure from needs + +Do not keep happiness, sadness, fear, loneliness, comfort, boredom, or anger as independent behavior-driving values. + +============================================================ +12. STRESS REDEFINITION +============================================================ + +Stress is not an independent emotion. + +Stress is a derived value calculated from current need pressure. + +Do not directly add to stress for shock events. +For shock events, increase relevant needs first, then recalculate stress from needs. + +Stress must not be used as a primary action-selection need. + +Behavior is selected only from the six needs. + +Stress may affect: +- expression +- minor visual intensity +- UI display if already present +- minor secondary effects if existing systems need it + +Suggested pressure function: + +function needPressure(value) { + const x = value / 100; + return x * x * 100; +} + +Suggested stress calculation: + +stress = + needPressure(food) * 0.10 + + needPressure(sleep) * 0.12 + + needPressure(health) * 0.25 + + needPressure(safety) * 0.30 + + needPressure(social) * 0.08 + + needPressure(fulfill) * 0.15; + +Adjust weights if needed, but keep stress derived from needs. + +============================================================ +13. PANIC REDEFINITION +============================================================ + +Panic is not a need. +Panic is not a persistent emotion. + +Panic is a short temporary reaction state caused by large sudden increases in safety, health, or fulfill. + +Food, sleep, and social should not normally trigger panic. + +Track previous needs or otherwise compute need delta. + +Suggested rule: + +panic triggers if: +- safety increases suddenly by 40 or more +- health increases suddenly by 45 or more +- fulfill increases suddenly by 50 or more + +Panic should last for a short timer, such as 2–4 seconds. + +After panic timer ends, return to normal need-based action selection. + +If panic would be triggered and the tarinai has high aggression and a known breaker/attacker, use intimidate instead of panic. + +Example: + +if (shockTriggered) { + if (breaker && t.personality?.aggression > 0.6) { + t.state = "intimidate"; + t.target = breaker; + } else { + t.state = "panic"; + t.panicTimer = 3.0; + } +} + +============================================================ +14. EXPRESSION / VISUAL EMOTION COMPATIBILITY +============================================================ + +If the old emotion system is deeply tied to expressions, keep only a small compatibility layer for visuals. + +Expressions should be derived from: +- current state +- chosen need +- stress level +- panic/intimidate + +Suggested mapping: + +state panic: +panic expression + +state intimidate: +angry/threat expression + +chosen need safety: +worried expression + +chosen need food: +hungry expression + +chosen need sleep: +sleepy expression + +chosen need health: +unwell expression + +chosen need social: +social/looking expression + +chosen need fulfill: +neutral/pleased expression + +Do not let old expression emotions drive behavior. + +============================================================ +15. SAVE COMPATIBILITY +============================================================ + +Backward compatibility is not required. + +Do not implement save migrations. +Do not add compatibility shims for old saves unless the current code would immediately crash during normal startup. + +It is acceptable if old saves are incompatible after this feature. + +============================================================ +16. DO NOT ADD +============================================================ + +Do not add: +- long-term memory +- boredom/habit system +- player-intervention profile +- ReactionRegistry +- WorldRules +- full behavior tree +- complex utility AI +- detailed need breakdown UI +- repair system +- inheritance system +- material-carrying inventory +- structure privacy system + +============================================================ +17. ACCEPTANCE CRITERIA +============================================================ + +After implementation: + +- Each tarinai has six needs: + - food + - sleep + - health + - safety + - social + - fulfill + +- Needs are clamped 0–100. +- Needs are quantized to 10-point steps. +- UI displays needs as 0–10. +- Only the chosen action-driving need is highlighted. +- If multiple needs are tied for highest, one is chosen randomly. +- Safety does not force interruption. +- If safety and another need are tied, non-safety behavior can happen. +- Tie reason text uses the “Xけど、Yした。” format. +- Newly added Japanese source strings are Unicode escaped. +- Actions are defined in a simple action list. +- Items expose minimal roles and needEffects. +- StructureRegistry exists and supports at least grass_bed and plushie. +- grass_bed consumes grass to build. +- grass_bed is preferred by its owner. +- grass_bed destruction increases owner safety/fulfill and can trigger panic/intimidate. +- plushie consumes grass to build. +- plushie attaches to the owner’s head. +- plushie visually resembles a small tarinai. +- plushie reduces fulfill while carried/used. +- plushie breaks and disappears when damaged. +- plushie destruction strongly increases owner safety/fulfill and triggers panic/intimidate. +- Old detailed emotion values no longer drive behavior. +- Stress is derived from needs. +- Panic is caused by sudden safety/health/fulfill increases. +- Old save compatibility is not required. \ No newline at end of file diff --git a/index.html b/index.html index 75ac774..4ea4a73 100644 --- a/index.html +++ b/index.html @@ -5,11 +5,11 @@