Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.82 KB | None | 0 0
  1. (defun nextState (st act)
  2.   "generate the nextState after state st and action act from prolem"
  3.   (let ((new-state (make-state :action act :track (state-track st))))
  4.     (setf (state-vel new-state)
  5.       (make-vel (+ (vel-l (state-vel st)) (acce-l act))
  6.             (+ (vel-c (state-vel st)) (acce-c act))))
  7.     (setf (state-pos new-state)
  8.       (make-pos (+ (pos-l (state-pos st)) (vel-l (state-vel new-state)))
  9.             (+ (pos-c (state-pos st)) (vel-c (state-vel new-state)))))
  10.     (setf (state-cost new-state)
  11.       (cond ((isGoalp new-state) -100)
  12.         ((isObstaclep (state-pos new-state) (state-track new-state)) 20)
  13.         (T 1)))
  14.     (when (= (state-cost new-state) 20)
  15.       (setf (state-vel new-state) (make-vel 0 0))
  16.       (setf (state-pos new-state) (make-pos (pos-l (state-pos st))
  17.                         (pos-c (state-pos st)))))
  18.     (values new-state)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement