(This program in cl is of course open source, not commerial
![Smile :)](./images/smilies/icon_e_smile.gif)
It goes good but there is a big time difference of evaluation in sbcl and clisp.
For example:
when we have hand: Jack of Diamonds and Queen of Diamonds
and there is three hidden opponents:
i get in sbcl:
(34.66 2.4490001) (odds for win and odds for drawn)
time: 1.946 seconds of real time
and in clisp:
(34.643 2.5319998)
time: Real time: 67.22213 sec.
Small diferences in evaluation are result from randomness in algorithm.
(I used 100000 repetitions in drawing cards from deck)
I give a part of my program with function "test" which checks validation of random choice community cards form deck:
Code: Select all
(defmacro rm-it (i a len)
`(setf (aref ,a ,i) (aref ,a (decf ,len))))
(defun rand-ch (n a len)
(let ((i) (res) (items))
(loop repeat n do
(setf i (random len))
(push (aref a i) res)
(push i items)
(rm-it i a len))
(list res items)))
(defun make-deck ()
(let ((a (make-array 52)))
(loop for i upto 51 do (setf (aref a i) i)) a))
(defmacro rm-hand (hand stack len)
`(progn
(rm-it (position (car ,hand) ,stack) ,stack ,len)
(rm-it (position (cadr ,hand) ,stack) ,stack ,len)))
(defun clean-deck (deck removes)
(destructuring-bind (rm-cards rm-items) removes
(loop for c in rm-cards for i in rm-items do
(setf (aref deck i) c))))
(defun test (n)
(let ((deck (make-deck)) (choice) (cards) (len 52) (rep t))
(rm-hand '(23 40) deck len)
(loop repeat n while rep do
(setf choice (rand-ch 5 deck len))
(setf cards (car choice))
(when (/= (length (remove-duplicates cards)) 5)
(print cards) (setf rep nil))
(clean-deck deck choice))))
(time (test 100000)):
sbcl: 0.659 sec
clisp: 8.258135 sec
From what such big time difference in these two cl implementations? What can I change in program?
I'm always using sbcl, but I want to show this program on ms windows also.
![Smile :)](./images/smilies/icon_e_smile.gif)
thanks