From 7af4bf9d6cc47cf5b4b23ca8a28bf0089354ad25 Mon Sep 17 00:00:00 2001 From: El-BG-1970 Date: Mon, 30 Jan 2023 11:38:34 +0100 Subject: 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 --- src/game.lisp | 1 + src/zone.lisp | 7 +++++++ 2 files changed, 8 insertions(+) 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)))))) -- cgit v1.2.3