Jump to content

Featured Replies

Posted
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;another little markov-game => markov with "global-tendency"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;a "neutral table with 4 values"
(setq transitions '((1 (1 1) (2 1) (3 1) (4 1))
                    (2 (1 1) (2 1) (3 1) (4 1))
                    (3 (1 1) (2 1) (3 1) (4 1))
                    (3 (1 1) (2 1) (3 1) (4 1))
                    (4 (1 1) (2 1) (3 1) (4 1))))
      
;;;subfunctions

(defun filter-first-last (n sequence)
  (car (filter-last n sequence)))

(defun substitute-transition-weight (transition-list value new-weight)
  (loop 
    for j in transition-list
    collect (append (list (first j))
                    (loop repeat (1- (length j))
                      for cnt = 1 then (incf cnt)
                      when (equal (first (nth cnt j)) value)
                      collect (list (first (nth cnt j)) new-weight)
                      else collect (nth cnt j)))))

;;;mainfuction
(defun markov-with-tendency (transitions size generations value)
(loop repeat generations
   with list = (gen-markov-from-transitions 
                 transitions
                 :size size :start 1)
  with weight = 1
  with weight-add = 0

  do (setq transitions (substitute-transition-weight transitions value weight))
  append (setq list (gen-markov-from-transitions transitions :size size :start (filter-first-last 1 list)))
  do (incf weight (incf weight-add))))


;;;some simulations => evaluate!!!
(list-plot 
  (markov-with-tendency transitions 10 20 1)
  :point-radius 0 :style :fill) 

(list-plot 
 (list
  (markov-with-tendency transitions 10 20 1)
  (markov-with-tendency transitions 10 20 2)
  (markov-with-tendency transitions 10 20 4))
  :point-radius 0 :style :fill) 

(list-plot ;;non-neutral-table
  (markov-with-tendency '((1 (1 1) (2 4))
                          (2 (1 1) (4 1))
                          (3 (1 4) (3 5) (4 3))
                          (3 (1 1) (2 4) (3 2))
                          (4 (1 1) (3 2) (4 3))) 10 20 1)
  :point-radius 0 :style :fill) 

 

  • Author

you are right, sorry. no computer with me... think you could replace filter-first-last by: (car (last list))

 

 

Create an account or sign in to comment


Copyright © 2014-2025 Opusmodus™ Ltd. All rights reserved.
Product features, specifications, system requirements and availability are subject to change without notice.
Opusmodus, the Opusmodus logo, and other Opusmodus trademarks are either registered trademarks or trademarks of Opusmodus Ltd.
All other trademarks contained herein are the property of their respective owners.

Powered by Invision Community

Important Information

Terms of Use Privacy Policy