Jump to content

another markov game


Recommended Posts

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;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) 

 

Edited by AM
attached missing function
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy