In this picture is possible see the "Visualize" method working:
In this picture is possible see the "Analyze" method working:
Combining them we can see the method "demo-va" working:
Bellow, a image of the use of the method "stats" to display the statistics of the game played randomly showing the games.
Running the algorithm with two random players and 30000 games, we could see the statistic in the view of the first player. The result was: 58.43% of win, 28.74% Lost and 12.82% Draw. As expected for most of class it was about 60% of chance of winning. Bellow you can see a screen shot of the test.
and here the code.
Also, the most interesting part of the code was the method of analysis.
(defmethod analyze((l list))
(defparameter wonlist '( (nw n ne) (w c e) (sw s se) (nw w sw) (n c s) (ne e se) (nw c se) (ne c sw)))
(defparameter result 'd)
(defparameter xlist ())
(defparameter olist ())
(loop
for n from 0
for move in l
if (and (evenp n) (equal result 'd)) do (setf xlist (cons move xlist))
do (loop for lane in wonlist
if (equal (length(intersection xlist lane)) 3)
do (setf result 'w)
)
if (and (oddp n) (equal result 'd)) do (setf olist (cons move olist))
(loop for lane in wonlist
if (equal (length(intersection olist lane)) 3)
do (setf result 'l)
)
)
result
)
No comments:
Post a Comment