summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrant Shangreaux <grant@unabridgedsoftware.com>2022-01-30 20:40:20 -0600
committerGrant Shangreaux <grant@unabridgedsoftware.com>2022-01-30 20:40:20 -0600
commitaf0f607cf8c7a4f34d138ee3bf9155269cfdc2f9 (patch)
treef80f1996f3dbff057d67535cd74e947b1940b3c2
parent9684eefdbd850f4d92f0e16fec9f15b4740722dc (diff)
Fix: broken behavior methods so the base sim runs
-rw-r--r--mafia.org18
1 files changed, 13 insertions, 5 deletions
diff --git a/mafia.org b/mafia.org
index bb0a68c..6ea93a9 100644
--- a/mafia.org
+++ b/mafia.org
@@ -25,7 +25,7 @@ the following source block represents the whole program from a high level:
<<top-level-mafia-methods>>
- ;; <<actor-behavior-methods>>
+ <<actor-behavior-methods>>
<<game-loop>>
#+end_src
@@ -183,8 +183,8 @@ So... we need to define a game loop function, and a method for the actors to
(cl-remove-if-not #'mafia-alive-p (mafia-innocents obj)))
(cl-defmethod mafia-update ((obj mafia))
- "Performs the update logic for the mafia game instane."
- (mafia-innocent-die (cl-first (mafia-innocents-alive obj))))
+ "Performs the update logic for the mafia game instance."
+ (mafia-innocent-die (cl-first (mafia-living-innocents obj))))
(cl-defmethod mafia-innocents ((obj mafia))
"Returns the list of innocents from a mafia game."
@@ -354,14 +354,22 @@ watched by someone else. ???
(setf target (seq-random-elt other-actors))))
#+end_src
-*** Helper method to tell if an actor is alive
+*** ~mafia-alive-p~ actor predicate
+:PROPERTIES:
+:header-args: :noweb-ref actor-behavior-methods :noweb-sep "\n\n" :results silent
+:END:
+
#+begin_src emacs-lisp
(cl-defmethod mafia-alive-p ((obj mafia-innocent))
"Returns `t' if the actor is alive, otherwise `nil'"
(eql (slot-value obj 'status) 'alive))
#+end_src
-*** Dying innocents
+*** Dying Actors
+:PROPERTIES:
+:header-args: :noweb-ref actor-behavior-methods :noweb-sep "\n\n" :results silent
+:END:
+
We need a method to make an actor die. For now, we'll just print some
message and update its state so that the ~alive~ slot is ~nil~. According
to the game rules, we should start some "timer" so that it will count down