diff options
| author | El-BG-1970 <elouan.gros.fr@gmail.com> | 2023-01-30 11:38:34 +0100 |
|---|---|---|
| committer | El-BG-1970 <elouan.gros.fr@gmail.com> | 2023-01-30 11:38:34 +0100 |
| commit | 7af4bf9d6cc47cf5b4b23ca8a28bf0089354ad25 (patch) | |
| tree | 83dde278a8d816773023cf26352cfeaf2aa42095 | |
| parent | e056ac5d58e44a76a4185c37fce6948044b83c66 (diff) | |
| download | transacc-7af4bf9d6cc47cf5b4b23ca8a28bf0089354ad25.tar.gz | |
added an update-zone function that updates prices randomly
currently does not have tests in the test suite
prices currently update at random but ideally we'd update the
prices using the amount of stuff traded during the last round
| -rw-r--r-- | src/game.lisp | 1 | ||||
| -rw-r--r-- | src/zone.lisp | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/game.lisp b/src/game.lisp index f0efd14..b1774d5 100644 --- a/src/game.lisp +++ b/src/game.lisp @@ -46,6 +46,7 @@ (zone:name z))) zones))) (when z + (zone:update-zone cur-zone) (setq cur-zone z))))) (defmethod get-profit-in-zone ((g game) name zone) diff --git a/src/zone.lisp b/src/zone.lisp index 8e733b1..b43f7a8 100644 --- a/src/zone.lisp +++ b/src/zone.lisp @@ -2,6 +2,7 @@ (:use :cl) (:export :new-zone :name + :update-zone :get-commodity :get-commodities)) @@ -23,3 +24,9 @@ (find-if (lambda (c) (string= (commodities:name c) commodity-name)) (commodities z))) + +(defmethod update-zone ((z zone)) + (loop for c in (commodities z) + do (setf (commodities:price c) + (* (commodities:price c) + (+ 0.5 (random 1.0)))))) |
