2017-02-18 38 views
1

Я пытаюсь проверить, есть ли какие-либо препятствия перед автомобилем. Скажем, автомобиль находится в месте «2». Моя цель - проверить, есть ли какие-либо препятствия в местоположении «3». Невозможно определить факты препятствий, что означает, что в этом конкретном месте нет. Я проверяю, что существует условный. Но я получаю ошибку синтаксиса CLIPS [PRNTUTIL2] для этой части (+? Location_car 1) в правиле r6. Он работает, если я откажу от добавления. Какую альтернативу я могу использовать, или я просто пропускаю некоторые синтаксические вещи?Как правильно использовать дополнение внутри существует условно? CLIPS

(deftemplate car 
    (slot location) 
) 
(deftemplate obstacles 
    (slot location) ; location of road segment 
    (slot tlights) ; number of red traffic lights 
    (slot cars) ; number of cars which have priority drive through 
    (slot pedestrians) ; number of pedestrians crossing the road 
    (slot spec_service) ; number of spec service vehicles passing by 
) 

(deffacts faktu-inicializavimas 
(car (location 0)) 
(obstacles (location 9) (tlights 1) (cars 2) (pedestrians 5) (spec_service 2)) 
) 

(defrule r6 "Drive to location" 
    ?fact-id1 <- (car (location ?location_car)) 
    (or 
    (exists (obstacles (location (+ ?location_car 1)) (tlights 0) (cars 0) (pedestrians 0) (spec_service 0))) 
    (not 
     (exists (obstacles (location (+ ?location_car 1)))) 
    ) 
) 
=> 
(printout t "Drive to location") 
(modify ?fact-id1 (location (+ ?location_car 2))) 
) 

ответ

0

Используйте ограничение возвращаемого значения (знак равенства, =), чтобы ограничить поле возвращаемым значением вызова функции.

(defrule r6 "Drive to location" 
    ?fact-id1 <- (car (location ?location_car)) 
    (or 
    (exists (obstacles (location =(+ ?location_car 1)) 
         (tlights 0) 
         (cars 0) 
         (pedestrians 0) 
         (spec_service 0))) 
    (not 
     (exists (obstacles (location =(+ ?location_car 1)))) 
    ) 
) 
=> 
(printout t "Drive to location") 
(modify ?fact-id1 (location (+ ?location_car 2))) 
)