Added Init.clp as the default entry point for this optimization

;------------------------------------------------------------------------------
;Copyright (c) 2012, Joshua Scoggins
;All rights reserved.
;
;Redistribution and use in source and binary forms, with or without
;modification, are permitted provided that the following conditions are met:
;    * Redistributions of source code must retain the above copyright
;      notice, this list of conditions and the following disclaimer.
;    * Redistributions in binary form must reproduce the above copyright
;      notice, this list of conditions and the following disclaimer in the
;      documentation and/or other materials provided with the distribution.
;    * Neither the name of Joshua Scoggins nor the
;      names of its contributors may be used to endorse or promote products
;      derived from this software without specific prior written permission.
;
;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY
;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;------------------------------------------------------------------------------
; Init.clp - Default Entry Point for a expert system optimization
;------------------------------------------------------------------------------
; Usually this only contains elements necessary to start the load process
; With the modifications I made to CLIPS for LLVM this usually manifests
; itself as being a batch-load command which allows multiple loads to occur as
; a single command
;------------------------------------------------------------------------------

error: pathspec 'Init.clp' did not match any file(s) known to git


Changed the loader to reference the new core.clp

;------------------------------------------------------------------------------
;Copyright (c) 2012, Joshua Scoggins
;All rights reserved.
;
;Redistribution and use in source and binary forms, with or without
;modification, are permitted provided that the following conditions are met:
;    * Redistributions of source code must retain the above copyright
;      notice, this list of conditions and the following disclaimer.
;    * Redistributions in binary form must reproduce the above copyright
;      notice, this list of conditions and the following disclaimer in the
;      documentation and/or other materials provided with the distribution.
;    * Neither the name of Joshua Scoggins nor the
;      names of its contributors may be used to endorse or promote products
;      derived from this software without specific prior written permission.
;
;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY
;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;------------------------------------------------------------------------------
; Init.clp - Default Entry Point for a expert system optimization
;------------------------------------------------------------------------------
; Usually this only contains elements necessary to start the load process
; With the modifications I made to CLIPS for LLVM this usually manifests
; itself as being a batch-load command which allows multiple loads to occur as
; a single command
;------------------------------------------------------------------------------
(batch* "modules/core/core.clp")
(batch-load (create$ "modules/llvm/ModuleHeader.clp"
                     "modules/rampancy/ModuleHeader.clp"
                     "modules/indirect/ModuleHeader.clp"
                     "modules/types/ModuleHeader.clp"
                     "modules/pipeline/ModuleHeader.clp"
                     ; Add entries to other modules here
                     "passes/PassRegistry.clp"
                     "modules/main/ModuleHeader.clp"
                     ))

;------------------------------------------------------------------------------
;Copyright (c) 2012, Joshua Scoggins
;All rights reserved.
;
;Redistribution and use in source and binary forms, with or without
;modification, are permitted provided that the following conditions are met:
;    * Redistributions of source code must retain the above copyright
;      notice, this list of conditions and the following disclaimer.
;    * Redistributions in binary form must reproduce the above copyright
;      notice, this list of conditions and the following disclaimer in the
;      documentation and/or other materials provided with the distribution.
;    * Neither the name of Joshua Scoggins nor the
;      names of its contributors may be used to endorse or promote products
;      derived from this software without specific prior written permission.
;
;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY
;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;------------------------------------------------------------------------------
; Init.clp - Default Entry Point for a expert system optimization
;------------------------------------------------------------------------------
; Usually this only contains elements necessary to start the load process
; With the modifications I made to CLIPS for LLVM this usually manifests
; itself as being a batch-load command which allows multiple loads to occur as
; a single command
;------------------------------------------------------------------------------
(batch-load
  (create$ "modules/core/ModuleHeader.clp"
			  "modules/llvm/ModuleHeader.clp"
			  "modules/rampancy/ModuleHeader.clp"
			  "modules/indirect/ModuleHeader.clp"
			  "modules/types/ModuleHeader.clp"
			  "modules/pipeline/ModuleHeader.clp"
			  ; Add entries to other modules here
			  "passes/PassRegistry.clp"
			  "modules/main/ModuleHeader.clp"
			  ))


update task1 from chapter4

update task1 from chapter4

(deffacts employees
    (employee Lelyakin 10 2 100000)
    (employee Lelyakina 11 2 100000)
    (employee Timkaev 12 3 110000)
    (employee Timkaeva 13 3 110000)
    (employee Kisurin 13 3 111000)
    (employee Oldmann 31 3 111991)
)

(defrule prem
    (employee ?name ?expierence ?children ?salary)

    (test (or (> ?children 2)
              (>= ?expierence 5)
          )
    )
      =>
    (assert (premia ?name (* ?salary 0.2)))
)

(defrule all_empl_prem
    (forall (employee ?name ?expierence ?children ?salary)
            (prem ?name))
      =>
    (printout t "All employees has prem")
)

(defrule veteran
    (employee ?name ?expierence ?children ?salary)

    (test (> ?expierence 20))
      =>
    (printout t "There are veterans" crlf)
)

(deffacts employees
    (employee Lelyakin 10 2 100000)
    (employee Lelyakina 11 2 100000)
    (employee Timkaev 12 3 110000)
    (employee Timkaeva 13 3 110000)
    (employee Kisurin 13 3 111000)
)

(defrule prem
    (employee ?name ?expierence ?children ?salary)

    (test (or (?children > 2)
              (?expierence >= 5)
          )
    )
      =>
    (assert (premia ?name (* ?salary 0.2)))
)


Update expert-system.clp

Update expert-system.clp

(deffunction ask-question (?question $?allowed-values)
    (printout t ?question)
    (bind ?answer (read))

    (if (lexemep ?answer) then
        (bind ?answer (lowcase ?answer)))

    (while (not (member ?answer ?allowed-values)) do
        (printout t ?question)
        (bind ?answer (read))

        (if (lexemep ?answer) then
            (bind ?answer (lowcase ?answer)))
    )

    ?answer
)

(deffunction yes-or-no-p (?question)
    (bind ?response (ask-question ?question yes no у n))
    (or (eq ?response yes) (eq ?response y))
)


Realizado cambios al ejercicio 1

Realizado cambios al ejercicio 1

(defrule R1
    (viven-mismo-pueblo ?x ?y)
        => (assert (posible-equipo ?x ?y))
)

(defrule R2
    (estudian-misma-facultad ?x ?y)
        => (assert (posible-equipo ?x ?y))
)

(defrule R3
    (son-misma-cuadrilla ?x ?y)
        => (assert (posible-equipo ?x ?y))
)

(defrule R4
    (posible-equipo ?x ?y)
        => (assert (equipo-campeonato ?x ?y))
)

(defrule R5
    (equipo-campeonato ?x ?y) (gusta-jugar-pala ?x) (gusta-jugar-pala ?y)
        => (assert (equipo-pala ?x ?y))
)

(defrule R6
    (equipo-campeonato ?x ?y) (gusta-jugar-pala ?x) (gusta-jugar-pala ?y)(es-zurda ?x)
        =>(assert (equipo-pala ?x ?y))
)

(defrule R7
    (buen-saque ?x) (gusta-cualquier-deporte ?x)
        => (assert (gusta-jugar-pala ?x))
)

(defrule R8
    (habitual-Anoeta ?x)(gusta-cualquier-deporte ?x)
        => (assert (gusta-jugar-pala ?x))
)
(defrule R9
    (equipo-pala ?x ?y)
    (equipo-pala ?w ?z)
    ?pista<-(pista-libre-Anoeta ?m)
    (test(neq ?equipo1 ?equipo2))
        => (assert (partido (equipo1 ?x ?y)(equipo2 ?w ?z) (pista ?m)) (retract ?pista)
)

(defrule R1
    (viven-mismo-pueblo ?x ?y)
        => (assert (posible-equipo ?x ?y))
)

(defrule R2
    (estudian-misma-facultad ?x ?y)
        => (assert (posible-equipo ?x ?y))
)

(defrule R3
    (son-misma-cuadrilla ?x ?y)
        => (assert (posible-equipo ?x ?y))
)

(defrule R4
    (posible-equipo ?x ?y)
        => (assert (equipo-campeonato ?x ?y))
)

(defrule R5
    (equipo-campeonato ?x ?y) (gusta-jugar-pala ?x) (gusta-jugar-pala ?y)
        => (assert (equipo-pala ?x ?y))
)

(defrule R6
    (equipo-campeonato ?x ?y) (gusta-jugar-pala ?x) (gusta-jugar-pala ?y)(es-zurda ?x)
        =>(assert (equipo-pala ?x ?y))
)

(defrule R7
    (buen-saque ?x) (gusta-cualquier-deporte ?x)
        => (assert (gusta-jugar-pala ?x))
)

(defrule R8
    (habitual-Anoeta ?x)(gusta-cualquier-deporte ?x)
        => (assert (gusta-jugar-pala ?x))
)
(defrule R9
    ?equipo1<- (equipo-pala ?x ?y)
    ?equipo2<-(equipo-pala ?w ?z)
    ?pista<-(pista-libre-Anoeta ?m)
    (test(neq ?equipo1 ?equipo2))
        => (assert (partido ?equipo1 ?equipo2 ?pista)) (retract ?pista)
)


-changed manners for jamochas needs

-changed manners for jamochas needs

git-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@1509 2cd91b7d-3b21-0410-a5f4-f42db4f24360

(deftemplate guest
   (slot name (type STRING))
   (slot sex (type STRING))
   (slot hobby (type STRING)) )

(deftemplate last_seat
   (slot seat (type INTEGER)) )

(deftemplate seating
   (slot seat1 (type INTEGER))
   (slot name1 (type STRING))
   (slot seat2 (type INTEGER))
   (slot name2 (type STRING))
   (slot id (type INTEGER))
   (slot pid (type INTEGER))
   (slot path_done (type BOOLEAN)) )

(deftemplate context
   (slot name (type STRING)) )

(deftemplate path
   (slot id (type INTEGER))
   (slot name (type STRING))
   (slot seat (type INTEGER)) )

(deftemplate chosen
   (slot id (type INTEGER))
   (slot name (type STRING))
   (slot hobby (type STRING)) )

(deftemplate count
   (slot c (type INTEGER)) )

(defrule assign_first_seat "assign the first seat"
   ?context <- (context (name "startup") )
   (guest (name ?n))
   ?count <- (count (c ?cnt) )
   =>
   (assert (seating (seat1 1) (name1 ?n) (name2 ?n) (seat2 1) (id ?cnt) (pid 0) (path_done TRUE) ) )
   (assert (path (id ?cnt) (name ?n) (seat 1) ) )
   (printout t "first seat seat1=1 name=" ?n " name2=" ?n " seat2=1 id=" ?cnt " pid=0 path_done TRUE" crlf)
   (bind ?cntPlus1 (+ ?cnt 1) )
   (modify ?count (c ?cntPlus1) )
   (modify ?context (name "assign_seats") )
)
(defrule find_seating "find seating for guest"
   ?context <- (context (name "assign_seats") )
   (seating (seat2 ?s2) (name2 ?n2) (id ?id) (path_done TRUE) )
   (guest (name ?n2) (sex ?sex1) (hobby ?h1) )
   (guest (name ?g2) (sex ~?sex1) (hobby ?h1) )
   ?count <- (count (c ?cnt) )
   (not (path (id ?id) (name ?g2) ) )
   (not (chosen (id ?id) (name ?g2) (hobby ?h1) ) )
=>
   (bind ?s2plus1 (+ ?s2 1) )
   (assert (seating (seat1 ?s2) (name1 ?n2) (name2 ?g2) (seat2 ?s2plus1) (id ?cnt) (pid ?id) (path_done FALSE) ) )
   (assert (path (id ?cnt) (name ?g2) (seat ?s2plus1) ) )
   (assert (chosen (id ?id) (name ?g2) (hobby ?h1) ) )
   (bind ?cntPlus1 (+ ?cnt 1) )
   (modify ?count (c ?cntPlus1) )
   (modify ?context (name "make_path") )
   (printout t "seat1=" ?s2 " : name1=" ?n2 " : seat2=" ?s2plus1 " : name2=" ?g2 " : id=" ?cnt " : pid=" ?id " : path_done=FALSE" crlf)
)
(defrule path_done "path is done"
   ?context <- (context (name "make_path") )
   ?seating <- (seating (path_done FALSE) )
=>
   (modify ?seating (path_done TRUE) )
   (modify ?context (name "check_done") )
   (printout t "path is done " crlf)
)
(defrule make_path
   ?context <- (context (name "make_path") )
   (seating (id ?id) (pid ?sPID) (path_done FALSE) )
   (path (id ?sPID) (name ?n1) (seat ?s) )
   (not (path (id ?id) (name ?n1) ) )
=>
   (assert (path (id ?id) (name ?n1) (seat ?s) ) )
   (printout t "make_path - id=" ?id " name=" ?n1 " seat=" ?s crlf)
)
(defrule continue "continue matching"
   ?context <- (context (name "check_done") )
=>
   (modify ?context (name "assign_seats") )
   (printout t "assign seats again" crlf)
)
(defrule are_we_done "are we done?"
   ?context <- (context (name "check_done") )
   (last_seat (seat ?lseat) )
   (seating (seat2 ?lseat) )
=>
   (printout t "Yes, we are done:  Print Results!!" crlf)
   (modify ?context (name "all_done") )
)

(defrule all_done "all done with test"
  ?context <- (context (name "all_done") )
=>
  (modify ?context (name "print_results") )
  (printout t crlf "rule all done: Condition context print_results" crlf )
)
(defrule print_results "print the results"
  (context (name "print_results") )
  ?seating <- (seating (id ?id) (seat2 ?s2) )
  (last_seat (seat ?s2) )
  (path (id ?id) (name ?n1) (seat ?s1) )
=>
  (printout t "name=" ?n1 " seat=" ?s1 crlf)
  (retract ?seating)
)

(assert (context (name "startup") ) )
(assert (count (c 1) ) )

(assert (guest (name "1") (sex "m") (hobby "3") ) )
(assert (guest (name "1") (sex "m") (hobby "2") ) )
(assert (guest (name "2") (sex "m") (hobby "2") ) )
(assert (guest (name "2") (sex "m") (hobby "3") ) )
(assert (guest (name "3") (sex "m") (hobby "1") ) )
(assert (guest (name "3") (sex "m") (hobby "2") ) )
(assert (guest (name "3") (sex "m") (hobby "3") ) )
(assert (guest (name "4") (sex "f") (hobby "3") ) )
(assert (guest (name "4") (sex "f") (hobby "2") ) )
(assert (guest (name "5") (sex "f") (hobby "1") ) )
(assert (guest (name "5") (sex "f") (hobby "2") ) )
(assert (guest (name "5") (sex "f") (hobby "3") ) )
(assert (guest (name "6") (sex "f") (hobby "3") ) )
(assert (guest (name "6") (sex "f") (hobby "1") ) )
(assert (guest (name "6") (sex "f") (hobby "2") ) )
(assert (guest (name "7") (sex "f") (hobby "3") ) )
(assert (guest (name "7") (sex "f") (hobby "2") ) )
(assert (guest (name "8") (sex "m") (hobby "3") ) )
(assert (guest (name "8") (sex "m") (hobby "1") ) )
(assert (last_seat (seat 8) ) )
(bind ?*start* (ms-time) )
(fire)
(bind ?*end* (ms-time) )
(bind ?et (- ?*end* ?*start*) )
(printout t "elpasedTime=" ?et crlf)

(deftemplate guest
   (slot name (type STRING))
   (slot sex (type STRING))
   (slot hobby (type STRING)) )

(deftemplate last_seat
   (slot seat (type INTEGER)) )

(deftemplate seating
   (slot seat1 (type INTEGER))
   (slot name1 (type STRING))
   (slot name2 (type STRING))
   (slot seat2 (type INTEGER))
   (slot id (type INTEGER))
   (slot pid (type INTEGER))
   (slot path_done (type BOOLEAN)) )

(deftemplate context
   (slot name (type STRING)) )

(deftemplate path
   (slot id (type INTEGER))
   (slot name (type STRING))
   (slot seat (type INTEGER)) )

(deftemplate chosen
   (slot id (type INTEGER))
   (slot name (type STRING))
   (slot hobby (type STRING)) )

(deftemplate count
   (slot c (type INTEGER)) )

(defrule assign_first_seat "assign the first seat"
   ?context <- (context (name "startup") )
   (guest (name ?n))
   ?count <- (count (c ?cnt) )
   =>
   (assert (seating (seat1 1) (name1 ?n) (name2 ?n) (seat2 1) (id ?cnt) (pid 0) (path_done TRUE) ) )
   (assert (path (id ?cnt) (name ?n) (seat 1) ) )
   (printout t "first seat seat1=1 name=" ?n " name2=" ?n " seat2=1 id=" ?cnt " pid=0 path_done TRUE" crlf)
   (bind ?cntPlus1 (+ ?cnt 1) )
   (modify ?count (c ?cntPlus1) )
   (modify ?context (name "assign_seats") )
)
(defrule find_seating "find seating for guest"
   ?context <- (context (name "assign_seats") )
   (seating (seat2 ?s2) (name2 ?n2) (id ?id) (path_done TRUE) )
   (guest (name ?n2) (sex ?sex1) (hobby ?h1) )
   (guest (name ?g2) (sex ~?sex1) (hobby ?h1) )
   ?count <- (count (c ?cnt) )
   (not (path (id ?id) (name ?g2) ) )
   (not (chosen (id ?id) (name ?g2) (hobby ?h1) ) )
=>
   (bind ?s2plus1 (+ ?s2 1) )
   (assert (seating (seat1 ?s2) (name1 ?n2) (name2 ?g2) (seat2 ?s2plus1) (id ?cnt) (pid ?id) (path_done FALSE) ) )
   (assert (path (id ?cnt) (name ?g2) (seat ?s2plus1) ) )
   (assert (chosen (id ?id) (name ?g2) (hobby ?h1) ) )
   (bind ?cntPlus1 (+ ?cnt 1) )
   (modify ?count (c ?cntPlus1) )
   (modify ?context (name "make_path") )
   (printout t "seat1=" ?s2 " : name1=" ?n2 " : seat2=" ?s2plus1 " : name2=" ?g2 " : id=" ?cnt " : pid=" ?id " : path_done=FALSE" crlf)
)
(defrule make_path
   ?context <- (context (name "make_path") )
   (seating (id ?id) (pid ?sPID) (path_done FALSE) )
   (path (id ?sPID) (name ?n1) (seat ?s) )
   (not (path (id ?id) (name ?n1) ) )
=>
   (assert (path (id ?id) (name ?n1) (seat ?s) ) )
   (printout t "make_path - id=" ?id " name=" ?n1 " seat=" ?s crlf)
)

(defrule are_we_done "are we done?"
   ?context <- (context (name "check_done") )
   (last_seat (seat ?lseat) )
   (seating (seat2 ?lseat) )
=>
   (printout t "Yes, we are done:  Print Results!!" crlf)
   (modify ?context (name "all_done") )
)
(defrule path_done "path is done"
   ?context <- (context (name "make_path") )
   ?seating <- (seating (path_done FALSE) )
=>
   (modify ?seating (path_done TRUE) )
   (modify ?context (name "check_done") )
   (printout t "path is done " crlf)
)
(defrule continue "continue matching"
   ?context <- (context (name "check_done") )
=>
   (modify ?context (name "assign_seats") )
   (printout t "assign seats again" crlf)
)
(defrule all_done "all done with test"
  ?context <- (context (name "all_done") )
=>
  (modify ?context (name "print_results") )
  (printout t crlf "rule all done: Condition context print_results" crlf )
)
(defrule print_results "print the results"
  (context (name "print_results") )
  ?seating <- (seating (id ?id) (seat2 ?s2) )
  (last_seat (seat ?s2) )
  (path (id ?id) (name ?n1) (seat ?s1) )
=>
  (printout t "name=" ?n1 " seat=" ?s1 crlf)
  (retract ?seating)
)

(assert (context (name "startup") ) )
(assert (count (c 1) ) )
(assert (guest (name "1") (sex "m") (hobby "3") ) )
(assert (guest (name "1") (sex "m") (hobby "2") ) )
(assert (guest (name "2") (sex "m") (hobby "2") ) )
(assert (guest (name "2") (sex "m") (hobby "3") ) )
(assert (guest (name "3") (sex "m") (hobby "1") ) )
(assert (guest (name "3") (sex "m") (hobby "2") ) )
(assert (guest (name "3") (sex "m") (hobby "3") ) )
(assert (guest (name "4") (sex "f") (hobby "3") ) )
(assert (guest (name "4") (sex "f") (hobby "2") ) )
(assert (guest (name "5") (sex "f") (hobby "1") ) )
(assert (guest (name "5") (sex "f") (hobby "2") ) )
(assert (guest (name "5") (sex "f") (hobby "3") ) )
(assert (guest (name "6") (sex "f") (hobby "3") ) )
(assert (guest (name "6") (sex "f") (hobby "1") ) )
(assert (guest (name "6") (sex "f") (hobby "2") ) )
(assert (guest (name "7") (sex "f") (hobby "3") ) )
(assert (guest (name "7") (sex "f") (hobby "2") ) )
(assert (guest (name "8") (sex "m") (hobby "3") ) )
(assert (guest (name "8") (sex "m") (hobby "1") ) )
(assert (last_seat (seat 8) ) )
(bind ?*start* (ms-time) )
(fire)
(bind ?*end* (ms-time) )
(bind ?et (- ?*end* ?*start*) )
(printout t "elpasedTime=" ?et crlf)


Added WidgetElement.clp

Added WidgetElement.clp

The base class of all widgets is the WidgetElement. It is a simple class that
provides the functionality that all widgets share.

;------------------------------------------------------------------------------
;Copyright (c) 2013, Joshua Scoggins
;All rights reserved.
;
;Redistribution and use in source and binary forms, with or without
;modification, are permitted provided that the following conditions are met:
;    * Redistributions of source code must retain the above copyright
;      notice, this list of conditions and the following disclaimer.
;    * Redistributions in binary form must reproduce the above copyright
;      notice, this list of conditions and the following disclaimer in the
;      documentation and/or other materials provided with the distribution.
;    * Neither the name of Joshua Scoggins nor the
;      names of its contributors may be used to endorse or promote products
;      derived from this software without specific prior written permission.
;
;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY
;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;------------------------------------------------------------------------------
; WidgetElement.clp - Base class of all widgets
;
; Written by Joshua Scoggins
; Started on 3/11/2013
;------------------------------------------------------------------------------
(defclass widget::WidgetElement
 "Base class of all widgets in the adventure engine"
 (is-a Object))
;------------------------------------------------------------------------------

error: pathspec 'src/lib/widget/WidgetElement.clp' did not match any file(s) known to git


Added code to Init.clp as an example

Added code to Init.clp as an example

;------------------------------------------------------------------------------
;Copyright (c) 2012, Joshua Scoggins
;All rights reserved.
;
;Redistribution and use in source and binary forms, with or without
;modification, are permitted provided that the following conditions are met:
;    * Redistributions of source code must retain the above copyright
;      notice, this list of conditions and the following disclaimer.
;    * Redistributions in binary form must reproduce the above copyright
;      notice, this list of conditions and the following disclaimer in the
;      documentation and/or other materials provided with the distribution.
;    * Neither the name of Joshua Scoggins nor the
;      names of its contributors may be used to endorse or promote products
;      derived from this software without specific prior written permission.
;
;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY
;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;------------------------------------------------------------------------------
; Init.clp - Default Entry Point for a expert system optimization
;------------------------------------------------------------------------------
; Usually this only contains elements necessary to start the load process
; With the modifications I made to CLIPS for LLVM this usually manifests
; itself as being a batch-load command which allows multiple loads to occur as
; a single command
;------------------------------------------------------------------------------
(batch-load
  (create$ "modules/core/ModuleHeader.clp"
	        "modules/llvm/ModuleHeader.clp"
			  "modules/scheduler/ModuleHeader.clp"
			  ; Add entries to other modules here
			  ))


Added a tool to convert defines in gl.h to corresponding C code

This is not a complete tool but is in the process of being written.

;------------------------------------------------------------------------------
;Copyright (c) 2013, Joshua Scoggins
;All rights reserved.
;
;Redistribution and use in source and binary forms, with or without
;modification, are permitted provided that the following conditions are met:
;    * Redistributions of source code must retain the above copyright
;      notice, this list of conditions and the following disclaimer.
;    * Redistributions in binary form must reproduce the above copyright
;      notice, this list of conditions and the following disclaimer in the
;      documentation and/or other materials provided with the distribution.
;    * Neither the name of Joshua Scoggins nor the
;      names of its contributors may be used to endorse or promote products
;      derived from this software without specific prior written permission.
;
;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY
;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;------------------------------------------------------------------------------
; GLConstantConversion.clp - an expert system that reads a define and generates
; conversion code for it.
;------------------------------------------------------------------------------
(defclass opened-file
 (is-a USER)
 (slot id)
 (slot index (type INTEGER) (range 0 ?VARIABLE))
 (message-handler next-index)
 (message-handler read-line)
 (message-handler close-file))
;------------------------------------------------------------------------------
(defmessage-handler opened-file next-index ()
 (bind ?old ?self:index)
 (bind ?self:index (+ ?old 1))
 (return ?old))
;------------------------------------------------------------------------------
(defmessage-handler opened-file read-line ()
 (readline ?self:id))
;------------------------------------------------------------------------------
(defmessage-handler opened-file close-file ()
 (close ?self:id))
;------------------------------------------------------------------------------
(deftemplate file-line
 (slot index)
 (slot parent)
 (multifield contents))
;------------------------------------------------------------------------------
; INPUT FACT FORM: (parse constant file ?path)
;------------------------------------------------------------------------------
(deffunction get-input-form-factor ()
 (printout t "(parse constant file ?path)" crlf))
;------------------------------------------------------------------------------
(defrule open-target-file
 "This rule takes a fact of the above INPUT FORM and attempts to open the file"
 ?fct <- (parse constant file ?path)
 =>
 (bind ?name (gensym*))
 (retract ?fct)
 (if (open ?path ?name "r") then
  (make-instance of opened-file (id ?name) (index 0))
  (assert (read file ?name))
 else
 (printout t "ERROR: target file at " ?path " does not exist!" crlf
  "Halting!" crlf)
 (halt)))
;------------------------------------------------------------------------------
(defrule build-file-line
 ?fct <- (read file ?fid)
 ?obj <- (object (is-a opened-file)
                 (id ?fid))
 =>
 (retract ?fct)
 (bind ?result (send ?obj read-line))
 (if (neq ?result EOF) then
  (assert (read file ?fid)
          (file-line (index (send ?obj next-index))
           (parent ?fid)
           (contents (explode$ ?result))))
  else
  (send ?obj close-file)
  (unmake-instance ?obj)))
;------------------------------------------------------------------------------

error: pathspec 'src/tools/GLConstantConversion.clp' did not match any file(s) known to git


Create task4.clp

Create task4.clp

(deffunction fx (?x ?a)
  (if (< ?x 0) then (return (/ (abs (- ?x ?a)) (* ?x ?x))))
  (if (> ?x 0) then (return (sin (abs (+ ?x ?a)))))
  0
)

error: pathspec 'ssu-ai-level-2/chapter6/task4.clp' did not match any file(s) known to git