From b2eba6dea2093919d2da16aee6d54c815b33199d Mon Sep 17 00:00:00 2001 From: Diana Fernanda Belle Date: Sun, 12 Nov 2023 16:58:03 -0800 Subject: [PATCH 1/2] fix population curves --- src/the_longtime_game/core.clj | 2 +- test/the_longtime_game/core_test.clj | 29 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/the_longtime_game/core.clj b/src/the_longtime_game/core.clj index 63bdf2b..f881972 100644 --- a/src/the_longtime_game/core.clj +++ b/src/the_longtime_game/core.clj @@ -711,7 +711,7 @@ (let [population (-> herd :individuals count) optimal (calc-optimal-population herd) delta (- optimal population) - n (int (Math/abs (Math/log delta)))] + n (int (Math/log (max 1 (Math/abs delta))))] (if (> delta 0) [(rand-int n) (rand-int 2)] [(rand-int 2) (rand-int n)]))) diff --git a/test/the_longtime_game/core_test.clj b/test/the_longtime_game/core_test.clj index 0dde5bd..41a4098 100644 --- a/test/the_longtime_game/core_test.clj +++ b/test/the_longtime_game/core_test.clj @@ -75,20 +75,21 @@ `core/update-individuals `core/update-nutrients])) -(deftest test-stable-population-growth - (let [herd (core/gen-herd) - optimal (core/calc-optimal-population herd) - herd* - (reduce - (fn [herd _] - (let [[journeyings deaths] (core/shift-population herd) - [new-adults new-dead] (core/calc-pop-changes herd journeyings deaths)] - (core/apply-pop-changes herd new-adults new-dead))) - herd - (range 100))] - (is (> (* 3/2 optimal) - (count (:individuals herd*)) - (* 1/2 optimal))))) +(defspec test-stable-population-growth 5 + (props/for-all + [herd (s/gen ::core/herd)] + (let [optimal (core/calc-optimal-population herd) + delta (- (count (:individuals herd)) optimal) + herd* + (reduce + (fn [herd _] + (let [[journeyings deaths] (core/shift-population herd) + [new-adults new-dead] (core/calc-pop-changes herd journeyings deaths)] + (core/apply-pop-changes herd new-adults new-dead))) + herd + (range 100)) + delta* (- (count (:individuals herd*)) optimal)] + (is (> (Math/abs delta) (Math/abs delta*)))))) (deftest test-inc-max-skill (testing "Skills should not change when inc'd if all skills are maxed." From 1a36a8a11fcc8b5c686e19233c25789acd07df55 Mon Sep 17 00:00:00 2001 From: Diana Fernanda Belle Date: Sun, 12 Nov 2023 18:30:17 -0800 Subject: [PATCH 2/2] new events --- src/the_longtime_game/event.clj | 17 ++++++- src/the_longtime_game/event_text.clj | 74 ++++++++++++++++++++++++++-- 2 files changed, 86 insertions(+), 5 deletions(-) diff --git a/src/the_longtime_game/event.clj b/src/the_longtime_game/event.clj index 29df940..e83ccf6 100644 --- a/src/the_longtime_game/event.clj +++ b/src/the_longtime_game/event.clj @@ -58,6 +58,18 @@ individual #(update % :traits disj :weary))))}) +(def funeral + {:name "Funeral" + :text-fn event-text/funeral + :selects [{}] + :filter-fn + #(< 1 (count (:new-dead %))) + :marshal-fn + (fn [herd & _] + (first (:new-dead herd))) + :effect + (fn [herd & _] herd)}) + (def gruxnis-attack! {:name "Grux'nis attack" :text-fn event-text/gruxnis-attack! @@ -138,12 +150,13 @@ gruxnis-attack! ration-rot plague - wound-healed]) + wound-healed + crossed-paths]) (def general-events [journeying-ends offshoot-joins - crossed-paths]) + funeral]) (s/def ::event (s/with-gen diff --git a/src/the_longtime_game/event_text.clj b/src/the_longtime_game/event_text.clj index a64c536..8427151 100644 --- a/src/the_longtime_game/event_text.clj +++ b/src/the_longtime_game/event_text.clj @@ -1,6 +1,7 @@ (ns the-longtime-game.event-text (:require [clojure.string :as string] - [the-longtime-game.core :as core])) + [the-longtime-game.core :as core] + [the-longtime-game.text :as text])) (def -trait->adj {:angry "strong" @@ -86,8 +87,51 @@ ""))) (defn gruxnis-attack! - [herd [victim ibba] & _] - "TODO") + [_herd [victim ibba] & _] + (text/join-text + "A Grux'nis is a great beast, + a glorious testament to the fecund murk + of the Yuliak Range's swampy base. + Tough and shiny scales, + quick and vicious beak, + and toesome flippers that flop on land + but fly in water. + They eat the bottom-feeders of the upland bogs, + but can be drawn by chance down the riverfloes + to the paths of the herds." + (:name victim) "was attacked on the beach," + "where" (:name ibba) "fought it off with adroit hand and crushing arm." + "The beast was only scared back into the water, but not to end its ways. + So the threat remained." + (:name ibba) "traveled out lonesome to riddle with other herds" + "of how to pacify a Grux'nis. + In their heart they could not accept killing the animal outright, + though some argued easily for the necessity. + Facile, they thought. + But still they took a spear and went to kill the thing. + They goaded it with caught fish, + but recognized in its rampaging eye a worm -- + a worm that aggravates the temper, + and elicits rampant violence, + that can be driven out with a tincture. + Deftly they fought with the beast, as the sun rose and fell, + nipping it with a blade bathed in sleeping poison. + Blow by blow, the Grux'nis staggered, + until it felt, and slept! + Asleep," (:name ibba) "could treat it." + "It awoke bound but clear-eyed." + (:name ibba) "would not take chances," + "not more than this chance of knowing a Grux'nis in peace, + and though it struggled she watched it. + It was nervous now more than hungry, more than vicious. + So after a time they brought it to the river's edge and undid the bonds. + It fled, disappearing into the river with all the sound of a single droplet. + After that there were no more attacks. + The relief at violence averted brought great celebration." + "But" (:name ibba) "wondered still, where that creature" + "would go now. Back to the upland bogs, perhaps? + Or perhaps... to stay near, + to protect the one that saved its mind.")) (def journeying-ends (fn [herd & _] @@ -186,3 +230,27 @@ (:name sadcow) "offers a small thanks," "but their eyes go to the horizon," "the world open to them unfettered."]))) + +(def funeral + (fn [_herd [mourncow] deadcow] + (text/join-text + "All living things return to soil. + Life comes from life through death. + That is the cycle. + For the dead, the soil is turned over, + so that they lie deep beneath it, + and a sapling is placed over them. + What remains to mark their passing + is a mound in the earth + that becomes a limb of the land." + (:name deadcow) "was a friend of" (:name mourncow) ";" + "they will try to remember them fondly, + however bitterly their absence tastes. + They leave a complex legacy, a hole in the tapestry of the herd + that will take generations to scar over. + A friend heaps dirt on a hole in the ground + where their confidant will remain forever, + until the pieces of them return, + spoken by the tongues of the wind. + Life goes on, + differently.")))