Start implementing task5

Start implementing task5

(defrule fact
 =>
 (printout t "n=")
 (bind ?n (read))
 (bind ?r 1)
 (loop-for-count (?i 2 ?n) do
 	(bind ?r (* ?r ?i))
 )
 (printout t "fact is:")
 (printout t ?r)
 (printout t "")
)

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


Added some helper functions for color handling

; /lib/chicanery/color.clp - Routines for handling chicanery color features

(defgeneric translate/standard-color)
(defgeneric intensity-to-cmap)
(defmethod translate/standard-color
  ((?color LEXEME))
  (switch (lowcase (string-to-field ?color))
          (case opaque then 0)
          (case transparent then 1)
          (case black then 2)
          (case white then 3)
          (case red then 4)
          (case green then 5)
          (case blue then 6)
          (case cyan then 7)
          (case magenta then 8)
          (case yellow then 9)
          (case paleyellow then 10)
          (case darkyellow then 11)
          (case darkgreen then 12)
          (case palegreen then 13)
          (case medgreen then 14)
          (case darkblue then 15)
          (case palebluegreen then 16)
          (case paleblue then 17)
          (case bluegreen then 18)
          (case greygreen then 19)
          (case palegreygreen then 20)
          (case yellowgreen then 21)
          (case medblue then 22)
          (case greyblue then 23)
          (case palegreyblue then 24)
          (case purpleblue then 25)
          (case notacolor then 26)
          (case nofill then 27)
          (default 28)))

(defmethod get-standard-color
  ((?color LEXEME INSTANCE-NAME))
  (get-standard-color
    (translate/standard-color ?color)))

(defmethod intensity-to-cmap
  "Converts an intensity value to a greyscale color"
  ((?intensity INTEGER (<= 0 ?intensity 255)))
  (rgb-to-cmap ?intensity
               ?intensity
               ?intensity))

(defmethod rgb-to-cmap
  ((?tuple INTEGER MULTIFIELD (>= (length$ ?tuple) 3)))
  (rgb2cmap (nth$ 1 ?tuple)
            (nth$ 2 ?tuple)
            (nth$ 3 ?tuple)))

error: pathspec 'lib/chicanery/color.clp' did not match any file(s) known to git


Added a short description of what LLVMConstant.clp contains

;------------------------------------------------------------------------------
;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.
;------------------------------------------------------------------------------
; LLVMConstant.clp - Contains classes that represent the different LLVM
; constant types
;------------------------------------------------------------------------------
(defclass llvm::Constant
  (is-a LLVMUser)
  (slot IsNullValue (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsAllOnesValue (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsNegativeZeroValue (type SYMBOL) (allowed-values FALSE TRUE))
  (slot CanTrap (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsConstantUsed (type SYMBOL) (allowed-values FALSE TRUE))
  (slot RelocationInfo (type SYMBOL) (default nil)
		  (allowed-symbols nil NoRelocations LocalRelocation GlobalRelocations)))
;------------------------------------------------------------------------------
(defclass llvm::BlockAddress
  (is-a Constant)
  (slot TargetBlock (type SYMBOL)))
;------------------------------------------------------------------------------
(defclass llvm::ConstantAggregateZero
  (is-a Constant)
  (slot Element (type SYMBOL)))
;------------------------------------------------------------------------------
(defclass llvm::ConstantArray
  (is-a Constant))
;------------------------------------------------------------------------------
(defclass llvm::ConstantDataSequential
  (is-a Constant)
  (multislot Elements)
  (slot ElementType (type SYMBOL))
  (slot ElementCount (type NUMBER) (range 0 ?VARIABLE))
  (slot ElementByteSize (type NUMBER) (range 0 ?VARIABLE))
  (slot IsString (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsCString (type SYMBOL) (allowed-values FALSE TRUE)))
;------------------------------------------------------------------------------
(defclass llvm::ConstantDataArray
  (is-a ConstantDataSequential))
;------------------------------------------------------------------------------
(defclass llvm::ConstantDataVector
  (is-a ConstantDataSequential))
;------------------------------------------------------------------------------
(defclass llvm::ConstantExpression
  (is-a Constant)
  (slot Operation)
  (slot IsCast (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsCompare (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasIndices (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsGEPWithNoNotionalOverIndexing (type SYMBOL)
		  (allowed-values FALSE TRUE))
  (slot Opcode (type NUMBER) (range 0 ?VARIABLE))
  (slot Predicate (type NUMBER) (range 0 ?VARIABLE))
  (multislot Indices)
  (slot OpcodeName (type SYMBOL)))
;------------------------------------------------------------------------------
(defclass llvm::BinaryConstantExpression
  (is-a ConstantExpression))
;------------------------------------------------------------------------------
(defclass llvm::CompareConstantExpression
  (is-a ConstantExpression)
  (slot Predicate (type NUMBER)))
;------------------------------------------------------------------------------
(defclass llvm::ConstantFloatingPoint
  (is-a Constant)
  (slot IsZero (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsNegative (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsNaN (type SYMBOL) (allowed-values FALSE TRUE))
  (slot Value (type FLOAT)))
;------------------------------------------------------------------------------
(defclass llvm::ConstantInteger
  (is-a Constant)
  (slot ZeroExtendedValue (type NUMBER))
  (slot SignExtendedValue (type NUMBER))
  (slot Width (type NUMBER) (range 0 ?VARIABLE))
  (slot Value (type SYMBOL NUMBER))
  (slot IsNegative (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsZero (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsOne (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsMinusOne (type SYMBOL) (allowed-values FALSE TRUE)))
;------------------------------------------------------------------------------
(defclass llvm::PointerConstant
  (is-a Constant)
  (slot PointerType (type SYMBOL)))
;------------------------------------------------------------------------------
(defclass llvm::ConstantPointerNull
  (is-a PointerConstant))
;------------------------------------------------------------------------------
(defclass llvm::ConstantStruct
  (is-a PointerConstant))
;------------------------------------------------------------------------------
(defclass llvm::ConstantVector
  (is-a PointerConstant)
  (slot SplatValue (type SYMBOL)))
;------------------------------------------------------------------------------
(defclass llvm::GlobalValue
  (is-a Constant)
  (slot Alignment (type NUMBER))
  (slot HasUnnamedAddress (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasDefaultVisibility (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasHiddenVisibility (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasProtectedVisibility (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasSection (type SYMBOL) (allowed-values FALSE TRUE))
  (slot Section (type SYMBOL))
  (slot UseEmptyExceptConstants (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasExternalLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasAvailableExternallyLinkage (type SYMBOL)
		  (allowed-values FALSE TRUE))
  (slot HasLinkOnceLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasAppendingLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasInternalLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasPrivateLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasLinkerPrivateLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasLinkerPrivateWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasLinkerPrivateWeakDefAutoLinkage (type SYMBOL)
		  (allowed-values FALSE TRUE))
  (slot HasLocalLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasDLLImportLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasDLLExportLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasExternalWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasCommonLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsWeakForLinker (type SYMBOL) (allowed-values FALSE TRUE))
  (slot MayBeOverridden (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsDeclaration (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsMaterializable (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsDematerializable (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasUnnamedAddr (type SYMBOL) (allowed-values FALSE TRUE))
  (slot Initializer))

;------------------------------------------------------------------------------
(defclass llvm::GlobalVariable
  (is-a GlobalValue)
  (slot HasInitializer (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasDefinitiveInitializer (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasUniqueInitializer (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsConstant (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsThreadLocal (type SYMBOL) (allowed-values FALSE TRUE)))
;------------------------------------------------------------------------------
(defclass llvm::GlobalAlias
  (is-a GlobalValue)
  (slot Aliasee))

;------------------------------------------------------------------------------
(defclass llvm::UndefValue
  (is-a Constant))

;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
;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.
;------------------------------------------------------------------------------
(defclass llvm::Constant
  (is-a LLVMUser)
  (slot IsNullValue (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsAllOnesValue (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsNegativeZeroValue (type SYMBOL) (allowed-values FALSE TRUE))
  (slot CanTrap (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsConstantUsed (type SYMBOL) (allowed-values FALSE TRUE))
  (slot RelocationInfo (type SYMBOL) (default nil)
		  (allowed-symbols nil NoRelocations LocalRelocation GlobalRelocations)))
;------------------------------------------------------------------------------
(defclass llvm::BlockAddress
  (is-a Constant)
  (slot TargetBlock (type SYMBOL)))
;------------------------------------------------------------------------------
(defclass llvm::ConstantAggregateZero
  (is-a Constant)
  (slot Element (type SYMBOL)))
;------------------------------------------------------------------------------
(defclass llvm::ConstantArray
  (is-a Constant))
;------------------------------------------------------------------------------
(defclass llvm::ConstantDataSequential
  (is-a Constant)
  (multislot Elements)
  (slot ElementType (type SYMBOL))
  (slot ElementCount (type NUMBER) (range 0 ?VARIABLE))
  (slot ElementByteSize (type NUMBER) (range 0 ?VARIABLE))
  (slot IsString (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsCString (type SYMBOL) (allowed-values FALSE TRUE)))
;------------------------------------------------------------------------------
(defclass llvm::ConstantDataArray
  (is-a ConstantDataSequential))
;------------------------------------------------------------------------------
(defclass llvm::ConstantDataVector
  (is-a ConstantDataSequential))
;------------------------------------------------------------------------------
(defclass llvm::ConstantExpression
  (is-a Constant)
  (slot Operation)
  (slot IsCast (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsCompare (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasIndices (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsGEPWithNoNotionalOverIndexing (type SYMBOL)
		  (allowed-values FALSE TRUE))
  (slot Opcode (type NUMBER) (range 0 ?VARIABLE))
  (slot Predicate (type NUMBER) (range 0 ?VARIABLE))
  (multislot Indices)
  (slot OpcodeName (type SYMBOL)))
;------------------------------------------------------------------------------
(defclass llvm::BinaryConstantExpression
  (is-a ConstantExpression))
;------------------------------------------------------------------------------
(defclass llvm::CompareConstantExpression
  (is-a ConstantExpression)
  (slot Predicate (type NUMBER)))
;------------------------------------------------------------------------------
(defclass llvm::ConstantFloatingPoint
  (is-a Constant)
  (slot IsZero (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsNegative (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsNaN (type SYMBOL) (allowed-values FALSE TRUE))
  (slot Value (type FLOAT)))
;------------------------------------------------------------------------------
(defclass llvm::ConstantInteger
  (is-a Constant)
  (slot ZeroExtendedValue (type NUMBER))
  (slot SignExtendedValue (type NUMBER))
  (slot Width (type NUMBER) (range 0 ?VARIABLE))
  (slot Value (type SYMBOL NUMBER))
  (slot IsNegative (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsZero (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsOne (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsMinusOne (type SYMBOL) (allowed-values FALSE TRUE)))
;------------------------------------------------------------------------------
(defclass llvm::PointerConstant
  (is-a Constant)
  (slot PointerType (type SYMBOL)))
;------------------------------------------------------------------------------
(defclass llvm::ConstantPointerNull
  (is-a PointerConstant))
;------------------------------------------------------------------------------
(defclass llvm::ConstantStruct
  (is-a PointerConstant))
;------------------------------------------------------------------------------
(defclass llvm::ConstantVector
  (is-a PointerConstant)
  (slot SplatValue (type SYMBOL)))
;------------------------------------------------------------------------------
(defclass llvm::GlobalValue
  (is-a Constant)
  (slot Alignment (type NUMBER))
  (slot HasUnnamedAddress (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasDefaultVisibility (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasHiddenVisibility (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasProtectedVisibility (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasSection (type SYMBOL) (allowed-values FALSE TRUE))
  (slot Section (type SYMBOL))
  (slot UseEmptyExceptConstants (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasExternalLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasAvailableExternallyLinkage (type SYMBOL)
		  (allowed-values FALSE TRUE))
  (slot HasLinkOnceLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasAppendingLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasInternalLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasPrivateLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasLinkerPrivateLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasLinkerPrivateWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasLinkerPrivateWeakDefAutoLinkage (type SYMBOL)
		  (allowed-values FALSE TRUE))
  (slot HasLocalLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasDLLImportLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasDLLExportLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasExternalWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasCommonLinkage (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsWeakForLinker (type SYMBOL) (allowed-values FALSE TRUE))
  (slot MayBeOverridden (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsDeclaration (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsMaterializable (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsDematerializable (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasUnnamedAddr (type SYMBOL) (allowed-values FALSE TRUE))
  (slot Initializer))

;------------------------------------------------------------------------------
(defclass llvm::GlobalVariable
  (is-a GlobalValue)
  (slot HasInitializer (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasDefinitiveInitializer (type SYMBOL) (allowed-values FALSE TRUE))
  (slot HasUniqueInitializer (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsConstant (type SYMBOL) (allowed-values FALSE TRUE))
  (slot IsThreadLocal (type SYMBOL) (allowed-values FALSE TRUE)))
;------------------------------------------------------------------------------
(defclass llvm::GlobalAlias
  (is-a GlobalValue)
  (slot Aliasee))

;------------------------------------------------------------------------------
(defclass llvm::UndefValue
  (is-a Constant))

;------------------------------------------------------------------------------


Recomendations Works So Flawless, Much Intense

(deftemplate campeon
	(slot nombre (type STRING))
  (multislot tiene-rols)
	(slot salud (type INTEGER))
	(slot ataque (type INTEGER))
	(slot hechizo (type INTEGER))
	(slot dificultad (type INTEGER))
	(slot fecha (type STRING))
	(slot puntosip (type INTEGER))
	(slot puntosrp (type INTEGER))
	(slot prioridad (type INTEGER))
  (slot ban (type INTEGER))
)
; Aatrox
(defglobal ?*op1* = 0)
(defglobal ?*op2* = 0)
(defglobal ?*op3* = 0)
(defglobal ?*equipo* = 0)
(defglobal ?*player* = 0)
(defglobal ?*candidatos* = 0)
(defglobal ?*prioridades* = 0)
;(defrule le-fue-bien
;	(salience 187)
;	(comolefue 1)
;	?p <- (campeon (nombre ?**))
;=>
;	(modify ?p (+ prioridad 1))
;)
;(defrule le-fue-mal
;	(salience 187)
;	(comolefue 0)
;	?p <- (campeon (nombre ?**))
;=>
;	(modify ?p (- prioridad 1))
;)
;(defrule como-le-fue
;(declare salience 186)
;	(initial-fact)
;=>
;	(printout t "Le fue bien? si o no: ")
;	(assert (comolefue =(readline)))
;)

;(defrule analisis-ingreso-jugador
;	(declare (salience 187))
;	?p <- (juega-con ?jA ?campeon)
;	(juega-con ?jX ?campeon)
;=>
	;(printout t "Campeon " ?campeon " ya pertenece a jugador " ?jX)
;)
;(defrule ingreso-jugador1a
;(declare (salience 200))
	;(initial-fact)
;
	;(not (juega-con ?* ?*op1*))
;
;	(not (juega-con ?* ?*op2*))
;
;	(not (juega-con ?* ?*op3*))
;=>
;	(printout t "Jugador 1 equipo azul, estas son tus 3 recomendaciones de campeon: " crlf)
;	()
	;(bind ?campeon (readline))
	;(assert (juega-con "1a" ?campeon))
;)
;analisar rol
;no banneado (ban ?campeon)
;no elegido (juega-con ?x ?campeon)
;ordenarlos segun prioridad
;top 3
;assert juega-con j1a campeon
; ORDEN DE ELECCION
; 1a
; 1m
; 2m
; 2a
; 3a
; 3m
; 4m
; 4a
; 5a
; 5m

;(
;  (4)
;  (Pida su jugador)
;  (5)
;  )
; -1 - 5
;(defrule prioridad-gw
  ;(juega-con ?j ?nombre)
  ;?f1 <- (campeon (nombre ?nombre) (gw $?gw))
  ;(juega-con ? $?gw )
;=>
  ;(modify ?f1 (+ prioridad 1))
;)
(defrule ingreso-campeon-fase2
  (declare (salience 199)); mas alto que los ingreso-#equipo
  (con-posicion ?jugador ?equipo ?pos)
=>
  (printout t crlf "Top 3 Campeones Recomendados:" crlf)
  (printout t (implode$ (subseq$ ?*candidatos* 1 3)) crlf)
  (bind ?*candidatos* 0) ; limpiar la lista
  (bind ?*prioridades* 0) ; limpiar la lista
  (printout t "Ingrese nombre del campeon: ")
  (bind ?campeon (readline))
  (assert (juega-con ?jugador ?equipo ?campeon))
  (assert (ban ?campeon)) ; ya no se podra elegir
  (printout t crlf)
)
(defrule ingreso-campeon
  (declare (salience 200)); mas alto que los ingreso-#equipo
  (con-posicion ?jugador ?equipo ?pos)(tiene-codigo ?posicion ?pos)
  (puede-con ?pos $?rols)

  (campeon
    (nombre ?campeon
      ;&:(not (member ?campeon $?*bans*))
      ;&:()
    )
    (tiene-rols ?r1 ?r2
      &:(or (member ?r1 $?rols)(member ?r2 $?rols))
    )
    (prioridad ?prioridad)
    (ban 0)
  )
  ;(juega-con ? ?&~?nombre)
=>
  (if (integerp ?*candidatos*)
    then
      (bind ?*candidatos* ?*candidatos* ?campeon)
      (bind ?*prioridades* ?*prioridades* ?prioridad)
      (bind ?*candidatos*   (delete$ ?*candidatos*  1 1))
      (bind ?*prioridades*  (delete$ ?*prioridades* 1 1))
      ;(printout t "ELIMINANDO" crlf)
    else ; ingrese ordenado segun prioridad
      (bind ?length (length$ ?*candidatos*))
      (bind ?nswapped True)
      (loop-for-count (?x 1 ?length)
          (bind ?prioridadLista (nth$ ?x ?*prioridades*))
          (if (>= ?prioridad ?prioridadLista)
            then
              ; make the swap happen :)
              (bind ?*candidatos* (insert$ ?*candidatos* ?x ?campeon))
              (bind ?*prioridades* (insert$ ?*prioridades* ?x ?prioridad))
              (bind ?nswapped False)
              ;(printout t "ROMPIENDO" crlf)
              (break)
          )
      )
      (if (eq ?nswapped True)
        then ; anadir al final de la lista
          (bind ?*candidatos* ?*candidatos* ?campeon)
          (bind ?*prioridades* ?*prioridades* ?prioridad)
      )
  )
  ;(printout t crlf "== " ?jugador " == " ?posicion " == " $?rols " == " ?r1 " == " ?r2 " == " ?campeon " == prioridad " ?prioridad  crlf crlf)
)
(defrule ingreso-5m
  (declare (salience 190))
  (jugador 5 "m")
=>
  (printout t crlf "ELECCION DE POSICION" crlf "Posiciones disponibles:" crlf
    "1. Top" crlf "2. Mid" crlf "3. ADC" crlf "4. Support" crlf "5. Jungle" crlf
    "Jugador 5 de Equipo Morado, Elija su posicion: ")
  (bind ?pos (read))
  (assert(con-posicion 5 "m" ?pos))
  ;(assert (jugador 5 "m")) ; proximo jugador que elije
)
(defrule ingreso-5a
  (declare (salience 190))
  (jugador 5 "a")
=>
  (printout t crlf "ELECCION DE POSICION" crlf "Posiciones disponibles:" crlf
    "1. Top" crlf "2. Mid" crlf "3. ADC" crlf "4. Support" crlf "5. Jungle" crlf
    "Jugador 5 de Equipo Azul, Elija su posicion: ")
  (bind ?pos (read))
  (assert(con-posicion 5 "a" ?pos))
  (assert (jugador 5 "m")) ; proximo jugador que elije
)
(defrule ingreso-4a
  (declare (salience 190))
  (jugador 4 "a")
=>
  (printout t crlf "ELECCION DE POSICION" crlf "Posiciones disponibles:" crlf
    "1. Top" crlf "2. Mid" crlf "3. ADC" crlf "4. Support" crlf "5. Jungle" crlf
    "Jugador 4 de Equipo Azul, Elija su posicion: ")
  (bind ?pos (read))
  (assert(con-posicion 4 "a" ?pos))
  (assert (jugador 5 "a")) ; proximo jugador que elije
)
(defrule ingreso-4m
  (declare (salience 190))
  (jugador 4 "m")
=>
  (printout t crlf "ELECCION DE POSICION" crlf "Posiciones disponibles:" crlf
    "1. Top" crlf "2. Mid" crlf "3. ADC" crlf "4. Support" crlf "5. Jungle" crlf
    "Jugador 4 de Equipo Morado, Elija su posicion: ")
  (bind ?pos (read))
  (assert(con-posicion 4 "m" ?pos))
  (assert (jugador 4 "a")) ; proximo jugador que elije
)
(defrule ingreso-3m
  (declare (salience 190))
  (jugador 3 "m")
=>
  (printout t crlf "ELECCION DE POSICION" crlf "Posiciones disponibles:" crlf
    "1. Top" crlf "2. Mid" crlf "3. ADC" crlf "4. Support" crlf "5. Jungle" crlf
    "Jugador 3 de Equipo Morado, Elija su posicion: ")
  (bind ?pos (read))
  (assert(con-posicion 3 "m" ?pos))
  (assert (jugador 4 "m")) ; proximo jugador que elije
)
(defrule ingreso-3a
  (declare (salience 190))
  (jugador 3 "a")
=>
  (printout t crlf "ELECCION DE POSICION" crlf "Posiciones disponibles:" crlf
    "1. Top" crlf "2. Mid" crlf "3. ADC" crlf "4. Support" crlf "5. Jungle" crlf
    "Jugador 3 de Equipo Azul, Elija su posicion: ")
  (bind ?pos (read))
  (assert(con-posicion 3 "a" ?pos))
  (assert (jugador 3 "m")) ; proximo jugador que elije
)
(defrule ingreso-2a
  (declare (salience 190))
  (jugador 2 "a")
=>
  (printout t crlf "ELECCION DE POSICION" crlf "Posiciones disponibles:" crlf
    "1. Top" crlf "2. Mid" crlf "3. ADC" crlf "4. Support" crlf "5. Jungle" crlf
    "Jugador 2 de Equipo Azul, Elija su posicion: ")
  (bind ?pos (read))
  (assert(con-posicion 2 "a" ?pos))
  (assert (jugador 3 "a")) ; proximo jugador que elije
)
(defrule ingreso-2m
  (declare (salience 190))
  (jugador 2 "m")
=>
  (printout t crlf "ELECCION DE POSICION" crlf "Posiciones disponibles:" crlf
    "1. Top" crlf "2. Mid" crlf "3. ADC" crlf "4. Support" crlf "5. Jungle" crlf
    "Jugador 2 de Equipo Morado, Elija su posicion: ")
  (bind ?pos (read))
  (assert(con-posicion 2 "m" ?pos))
  (assert (jugador 2 "a")) ; proximo jugador que elije
)
(defrule ingreso-1m
  (declare (salience 190))
  (jugador 1 "m")
=>
  (printout t crlf "ELECCION DE POSICION" crlf "Posiciones disponibles:" crlf
    "1. Top" crlf "2. Mid" crlf "3. ADC" crlf "4. Support" crlf "5. Jungle" crlf
    "Jugador 1 de Equipo Morado, Elija su posicion: ")
  (bind ?pos (read))
  (assert(con-posicion 1 "m" ?pos))
  (assert (jugador 2 "m")) ; proximo jugador que elije
)
(defrule ingreso-1a
  (declare (salience 190))
  (jugador 1 "a")
=>
  (printout t crlf "ELECCION DE POSICION" crlf "Posiciones disponibles:" crlf
    "1. Top" crlf "2. Mid" crlf "3. ADC" crlf "4. Support" crlf "5. Jungle" crlf
    "Jugador 1 de Equipo Azul, Elija su posicion: ")
  (bind ?pos (read))
  (assert (jugador 1 "m")) ; proximo jugador que elije
  (assert(con-posicion 1 "a" ?pos))
)
(defrule trato-ban
(declare (salience 201))
  ?b <- (ban ?campeon)
  ?p <- (campeon (nombre ?campeon) (ban 0))
=>
  (modify ?p (ban 1))
  (retract ?b)
)
(defrule ingreso-informacion1
(declare (salience 201))
   (initial-fact)
=>
	(printout t "Modo Blind-Pick" crlf)

	;(assert (flag201 1))
  (assert (ban "Irelia"))
  (assert (ban "Janna"))
  (assert (ban "Jarvan IV"))
  (assert (ban "Jax"))
  (assert (ban "Jayce"))
  (assert (ban "Jinx"))

	(printout t crlf "Ingrese equipo a pertener, Azul o Morado: ")
	(bind ?*equipo* Azul)

	(printout t crlf "Ingrese el # de jugador (1 - 6) del equipo " ?*equipo* ": ")
	(bind ?*player* 1)
	(printout t crlf)
  (assert (jugador 1 "a")) ; proximo jugador que elije
)
(defrule inicio
(declare (salience 202))
  (initial-fact)
=>
  (load-facts limited_facts.clp)
	(printout t " Exito!!, Se cargaron los datos correctamente" crlf crlf )
)

(deftemplate campeon
	(slot nombre (type STRING))
  (multislot tiene-rols)
	(slot salud (type INTEGER))
	(slot ataque (type INTEGER))
	(slot hechizo (type INTEGER))
	(slot dificultad (type INTEGER))
	(slot fecha (type STRING))
	(slot puntosip (type INTEGER))
	(slot puntosrp (type INTEGER))
	(slot prioridad (type INTEGER))
  (slot ban (type INTEGER))
)
; Aatrox
(defglobal ?*op1* = 0)
(defglobal ?*op2* = 0)
(defglobal ?*op3* = 0)
(defglobal ?*equipo* = 0)
(defglobal ?*player* = 0)
(defglobal ?*candidatos* = 0)
(defglobal ?*prioridades* = 0)
;(defrule le-fue-bien
;	(salience 187)
;	(comolefue 1)
;	?p <- (campeon (nombre ?**))
;=>
;	(modify ?p (+ prioridad 1))
;)
;(defrule le-fue-mal
;	(salience 187)
;	(comolefue 0)
;	?p <- (campeon (nombre ?**))
;=>
;	(modify ?p (- prioridad 1))
;)
;(defrule como-le-fue
;(declare salience 186)
;	(initial-fact)
;=>
;	(printout t "Le fue bien? si o no: ")
;	(assert (comolefue =(readline)))
;)

;(defrule analisis-ingreso-jugador
;	(declare (salience 187))
;	?p <- (juega-con ?jA ?campeon)
;	(juega-con ?jX ?campeon)
;=>
	;(printout t "Campeon " ?campeon " ya pertenece a jugador " ?jX)
;)
;(defrule ingreso-jugador1a
;(declare (salience 200))
	;(initial-fact)
;
	;(not (juega-con ?* ?*op1*))
;
;	(not (juega-con ?* ?*op2*))
;
;	(not (juega-con ?* ?*op3*))
;=>
;	(printout t "Jugador 1 equipo azul, estas son tus 3 recomendaciones de campeon: " crlf)
;	()
	;(bind ?campeon (readline))
	;(assert (juega-con "1a" ?campeon))
;)
;analisar rol
;no banneado (ban ?campeon)
;no elegido (juega-con ?x ?campeon)
;ordenarlos segun prioridad
;top 3
;assert juega-con j1a campeon
; ORDEN DE ELECCION
; 1a
; 1m
; 2m
; 2a
; 3a
; 3m
; 4m
; 4a
; 5a
; 5m

;(
;  (4)
;  (Pida su jugador)
;  (5)
;  )
; -1 - 5
;(defrule prioridad-gw
  ;(juega-con ?j ?nombre)
  ;?f1 <- (campeon (nombre ?nombre) (gw $?gw))
  ;(juega-con ? $?gw )
;=>
  ;(modify ?f1 (+ prioridad 1))
;)
(defrule ingreso-campeon-fase2
  (declare (salience 199)); mas alto que los ingreso-#equipo
  (con-posicion ?jugador ?equipo ?pos)
=>
  (printout t crlf "Top 3 Campeones Recomendados:" crlf)
  (printout t (implode$ (subseq$ ?*candidatos* 1 3)) crlf)
  (bind ?*candidatos* 0) ; limpiar la lista
  (bind ?*prioridades* 0) ; limpiar la lista
  (printout t "Ingrese nombre del campeon: ")
  (bind ?campeon (readline))
  (assert (juega-con ?jugador ?equipo ?campeon))
  (printout t crlf)
)
(defrule ingreso-campeon
  (declare (salience 200)); mas alto que los ingreso-#equipo
  (con-posicion ?jugador ?equipo ?pos)(tiene-codigo ?posicion ?pos)
  (puede-con ?pos $?rols)

  (campeon
    (nombre ?campeon
      ;&:(not (member ?campeon $?*bans*))
      ;&:()
    )
    (tiene-rols ?r1 ?r2
      &:(or (member ?r1 $?rols)(member ?r2 $?rols))
    )
    (prioridad ?prioridad)
    (ban 0)
  )
  ;(juega-con ? ?&~?nombre)
=>
  (if (integerp ?*candidatos*)
    then
      (bind ?*candidatos* ?*candidatos* ?campeon)
      (bind ?*prioridades* ?*prioridades* ?prioridad)
      (bind ?*candidatos*   (delete$ ?*candidatos*  1 1))
      (bind ?*prioridades*  (delete$ ?*prioridades* 1 1))
      ;(printout t "ELIMINANDO" crlf)
    else ; ingrese ordenado segun prioridad
      (bind ?length (length$ ?*candidatos*))
      (bind ?nswapped True)
      (loop-for-count (?x 1 ?length)
          (bind ?prioridadLista (nth$ ?x ?*prioridades*))
          (if (>= ?prioridad ?prioridadLista)
            then
              ; make the swap happen :)
              (bind ?*candidatos* (insert$ ?*candidatos* ?x ?campeon))
              (bind ?*prioridades* (insert$ ?*prioridades* ?x ?prioridad))
              (bind ?nswapped False)
              ;(printout t "ROMPIENDO" crlf)
              (break)
          )
      )
      (if (eq ?nswapped True)
        then ; anadir al final de la lista
          (bind ?*candidatos* ?*candidatos* ?campeon)
          (bind ?*prioridades* ?*prioridades* ?prioridad)
      )
  )
  ;(printout t crlf "== " ?jugador " == " ?posicion " == " $?rols " == " ?r1 " == " ?r2 " == " ?campeon " == prioridad " ?prioridad  crlf crlf)
)
(defrule ingreso-5m
  (declare (salience 190))
  (jugador 5 "m")
=>
  (printout t crlf "ELECCION DE POSICION" crlf "Posiciones disponibles:" crlf
    "1. Top" crlf "2. Mid" crlf "3. ADC" crlf "4. Support" crlf "5. Jungle" crlf
    "Jugador 5 de Equipo Morado, Elija su posicion: ")
  (bind ?pos (read))
  (assert(con-posicion 5 "m" ?pos))
  ;(assert (jugador 5 "m")) ; proximo jugador que elije
)
(defrule ingreso-5a
  (declare (salience 190))
  (jugador 5 "a")
=>
  (printout t crlf "ELECCION DE POSICION" crlf "Posiciones disponibles:" crlf
    "1. Top" crlf "2. Mid" crlf "3. ADC" crlf "4. Support" crlf "5. Jungle" crlf
    "Jugador 5 de Equipo Azul, Elija su posicion: ")
  (bind ?pos (read))
  (assert(con-posicion 5 "a" ?pos))
  (assert (jugador 5 "m")) ; proximo jugador que elije
)
(defrule ingreso-4a
  (declare (salience 190))
  (jugador 4 "a")
=>
  (printout t crlf "ELECCION DE POSICION" crlf "Posiciones disponibles:" crlf
    "1. Top" crlf "2. Mid" crlf "3. ADC" crlf "4. Support" crlf "5. Jungle" crlf
    "Jugador 4 de Equipo Azul, Elija su posicion: ")
  (bind ?pos (read))
  (assert(con-posicion 4 "a" ?pos))
  (assert (jugador 5 "a")) ; proximo jugador que elije
)
(defrule ingreso-4m
  (declare (salience 190))
  (jugador 4 "m")
=>
  (printout t crlf "ELECCION DE POSICION" crlf "Posiciones disponibles:" crlf
    "1. Top" crlf "2. Mid" crlf "3. ADC" crlf "4. Support" crlf "5. Jungle" crlf
    "Jugador 4 de Equipo Morado, Elija su posicion: ")
  (bind ?pos (read))
  (assert(con-posicion 4 "m" ?pos))
  (assert (jugador 4 "a")) ; proximo jugador que elije
)
(defrule ingreso-3m
  (declare (salience 190))
  (jugador 3 "m")
=>
  (printout t crlf "ELECCION DE POSICION" crlf "Posiciones disponibles:" crlf
    "1. Top" crlf "2. Mid" crlf "3. ADC" crlf "4. Support" crlf "5. Jungle" crlf
    "Jugador 3 de Equipo Morado, Elija su posicion: ")
  (bind ?pos (read))
  (assert(con-posicion 3 "m" ?pos))
  (assert (jugador 4 "m")) ; proximo jugador que elije
)
(defrule ingreso-3a
  (declare (salience 190))
  (jugador 3 "a")
=>
  (printout t crlf "ELECCION DE POSICION" crlf "Posiciones disponibles:" crlf
    "1. Top" crlf "2. Mid" crlf "3. ADC" crlf "4. Support" crlf "5. Jungle" crlf
    "Jugador 3 de Equipo Azul, Elija su posicion: ")
  (bind ?pos (read))
  (assert(con-posicion 3 "a" ?pos))
  (assert (jugador 3 "m")) ; proximo jugador que elije
)
(defrule ingreso-2a
  (declare (salience 190))
  (jugador 2 "a")
=>
  (printout t crlf "ELECCION DE POSICION" crlf "Posiciones disponibles:" crlf
    "1. Top" crlf "2. Mid" crlf "3. ADC" crlf "4. Support" crlf "5. Jungle" crlf
    "Jugador 2 de Equipo Azul, Elija su posicion: ")
  (bind ?pos (read))
  (assert(con-posicion 2 "a" ?pos))
  (assert (jugador 3 "a")) ; proximo jugador que elije
)
(defrule ingreso-2m
  (declare (salience 190))
  (jugador 2 "m")
=>
  (printout t crlf "ELECCION DE POSICION" crlf "Posiciones disponibles:" crlf
    "1. Top" crlf "2. Mid" crlf "3. ADC" crlf "4. Support" crlf "5. Jungle" crlf
    "Jugador 2 de Equipo Morado, Elija su posicion: ")
  (bind ?pos (read))
  (assert(con-posicion 2 "m" ?pos))
  (assert (jugador 2 "a")) ; proximo jugador que elije
)
(defrule ingreso-1m
  (declare (salience 190))
  (jugador 1 "m")
=>
  (printout t crlf "ELECCION DE POSICION" crlf "Posiciones disponibles:" crlf
    "1. Top" crlf "2. Mid" crlf "3. ADC" crlf "4. Support" crlf "5. Jungle" crlf
    "Jugador 1 de Equipo Morado, Elija su posicion: ")
  (bind ?pos (read))
  (assert(con-posicion 1 "m" ?pos))
  (assert (jugador 2 "m")) ; proximo jugador que elije
)
(defrule ingreso-1a
  (declare (salience 190))
  (jugador 1 "a")
=>
  (printout t crlf "ELECCION DE POSICION" crlf "Posiciones disponibles:" crlf
    "1. Top" crlf "2. Mid" crlf "3. ADC" crlf "4. Support" crlf "5. Jungle" crlf
    "Jugador 1 de Equipo Azul, Elija su posicion: ")
  (bind ?pos (read))
  (assert (jugador 1 "m")) ; proximo jugador que elije
  (assert(con-posicion 1 "a" ?pos))
)
(defrule trato-ban
(declare (salience 201))
  ?b <- (ban ?campeon)
  ?p <- (campeon (nombre ?campeon) (ban 0))
=>
  (modify ?p (ban 1))
  (retract ?b)
)
(defrule ingreso-informacion1
(declare (salience 201))
   (initial-fact)
=>
	(printout t "Modo Blind-Pick" crlf)

	;(assert (flag201 1))
  (assert (ban "Irelia"))
  (assert (ban "Janna"))
  (assert (ban "Jarvan IV"))
  (assert (ban "Jax"))
  (assert (ban "Jayce"))
  (assert (ban "Jinx"))

	(printout t crlf "Ingrese equipo a pertener, Azul o Morado: ")
	(bind ?*equipo* Azul)

	(printout t crlf "Ingrese el # de jugador (1 - 6) del equipo " ?*equipo* ": ")
	(bind ?*player* 1)
	(printout t crlf)
  (assert (jugador 1 "a")) ; proximo jugador que elije
)
(defrule inicio
(declare (salience 202))
  (initial-fact)
=>
  (load-facts limited_facts.clp)
	(printout t " Exito!!, Se cargaron los datos correctamente" crlf crlf )
)


Cleaned up the module definition in rampancy/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.
;------------------------------------------------------------------------------
; ModuleHeader.clp - Contains the entry point into the rampancy module.
;------------------------------------------------------------------------------

(defmodule rampancy
 (import core ?ALL)
 (import llvm ?ALL)
 (export ?ALL))

(load* "modules/rampancy/CompilerWrappers.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.
;------------------------------------------------------------------------------
; ModuleHeader.clp - Contains the entry point into the rampancy module.
;------------------------------------------------------------------------------

(defmodule rampancy
 (import core defclass ?ALL)
 (import llvm defclass ?ALL)
 (import core deffunction ?ALL)
 (export defclass ?ALL)
 (export deffunction ?ALL))

(load* "modules/rampancy/CompilerWrappers.clp")


Fixed a bug in lib/chicanery/color.clp

Fixed a bug in lib/chicanery/color.clp

The file should load correctly now.

; /lib/chicanery/color.clp - Routines for handling chicanery color features

(defgeneric translate/standard-color)
(defgeneric intensity-to-cmap)
(defmethod translate/standard-color
  ((?color LEXEME))
  (switch (lowcase (string-to-field ?color))
          (case opaque then 0)
          (case transparent then 1)
          (case black then 2)
          (case white then 3)
          (case red then 4)
          (case green then 5)
          (case blue then 6)
          (case cyan then 7)
          (case magenta then 8)
          (case yellow then 9)
          (case paleyellow then 10)
          (case darkyellow then 11)
          (case darkgreen then 12)
          (case palegreen then 13)
          (case medgreen then 14)
          (case darkblue then 15)
          (case palebluegreen then 16)
          (case paleblue then 17)
          (case bluegreen then 18)
          (case greygreen then 19)
          (case palegreygreen then 20)
          (case yellowgreen then 21)
          (case medblue then 22)
          (case greyblue then 23)
          (case palegreyblue then 24)
          (case purpleblue then 25)
          (case notacolor then 26)
          (case nofill then 27)
          (default 28)))

(defmethod get-standard-color
  ((?color LEXEME INSTANCE-NAME))
  (get-standard-color
    (translate/standard-color ?color)))

(defmethod intensity-to-cmap
  "Converts an intensity value to a greyscale color"
  ((?intensity INTEGER (<= 0 ?intensity 255)))
  (rgb-to-cmap ?intensity
               ?intensity
               ?intensity))

(defmethod rgb-to-cmap
  ((?tuple INTEGER MULTIFIELD (>= (length$ ?tuple) 3)))
  (rgb-to-cmap (nth$ 1 ?tuple)
               (nth$ 2 ?tuple)
               (nth$ 3 ?tuple)))

; /lib/chicanery/color.clp - Routines for handling chicanery color features

(defgeneric translate/standard-color)
(defgeneric intensity-to-cmap)
(defmethod translate/standard-color
  ((?color LEXEME))
  (switch (lowcase (string-to-field ?color))
          (case opaque then 0)
          (case transparent then 1)
          (case black then 2)
          (case white then 3)
          (case red then 4)
          (case green then 5)
          (case blue then 6)
          (case cyan then 7)
          (case magenta then 8)
          (case yellow then 9)
          (case paleyellow then 10)
          (case darkyellow then 11)
          (case darkgreen then 12)
          (case palegreen then 13)
          (case medgreen then 14)
          (case darkblue then 15)
          (case palebluegreen then 16)
          (case paleblue then 17)
          (case bluegreen then 18)
          (case greygreen then 19)
          (case palegreygreen then 20)
          (case yellowgreen then 21)
          (case medblue then 22)
          (case greyblue then 23)
          (case palegreyblue then 24)
          (case purpleblue then 25)
          (case notacolor then 26)
          (case nofill then 27)
          (default 28)))

(defmethod get-standard-color
  ((?color LEXEME INSTANCE-NAME))
  (get-standard-color
    (translate/standard-color ?color)))

(defmethod intensity-to-cmap
  "Converts an intensity value to a greyscale color"
  ((?intensity INTEGER (<= 0 ?intensity 255)))
  (rgb-to-cmap ?intensity
               ?intensity
               ?intensity))

(defmethod rgb-to-cmap
  ((?tuple INTEGER MULTIFIELD (>= (length$ ?tuple) 3)))
  (rgb2cmap (nth$ 1 ?tuple)
            (nth$ 2 ?tuple)
            (nth$ 3 ?tuple)))


Fixed a bug where the determinant-cleanup module was missing.

This has been fixed.

;------------------------------------------------------------------------------
;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.
;------------------------------------------------------------------------------
;this module is used to determine which regions should be targeted for pathing
(defmodule wavefront-scheduling-determinant
			  (import core ?ALL)
			  (import llvm ?ALL)
			  (import types ?ALL)
			  (import pipeline ?ALL)
			  (import indirect ?ALL)
			  (import rampancy ?ALL)
			  (import MAIN ?ALL))
;------------------------------------------------------------------------------
(defmodule wavefront-scheduling-determinant-cleanup
			  (import core ?ALL)
			  (import llvm ?ALL)
			  (import types ?ALL)
			  (import pipeline ?ALL)
			  (import indirect ?ALL)
			  (import rampancy ?ALL)
			  (import MAIN ?ALL))
;------------------------------------------------------------------------------
(defmodule wavefront-scheduling-pre-init
			  (import core ?ALL)
			  (import llvm ?ALL)
			  (import types ?ALL)
			  (import pipeline ?ALL)
			  (import indirect ?ALL)
			  (import rampancy ?ALL)
			  (import MAIN ?ALL))
;------------------------------------------------------------------------------
(defmodule wavefront-scheduling-code
			  (import core ?ALL)
			  (import llvm ?ALL)
			  (import types ?ALL)
			  (import pipeline ?ALL)
			  (import indirect ?ALL)
			  (import rampancy ?ALL)
			  (import MAIN ?ALL))
;------------------------------------------------------------------------------
(defmodule wavefront-scheduling-final
			  (import core ?ALL)
			  (import llvm ?ALL)
			  (import types ?ALL)
			  (import pipeline ?ALL)
			  (import indirect ?ALL)
			  (import rampancy ?ALL)
			  (import MAIN ?ALL))
;------------------------------------------------------------------------------
(defrule wavefront-scheduling::macro-expand-passes
			"Pushes the modules that make up this pass into the pass-description"
			?f <- (message (from pipeline)
								(to wavefront-scheduling)
								(action initial-fact))
			?p <- (object (is-a pass-description) (passes $?passes))
			=>
			(retract ?f)
			(modify-instance ?p (passes
										loop-region-merging
										dependency-analysis
										wavefront-scheduling-determinant
										wavefront-scheduling-determinant-cleanup
										paths-conditional
                    wavefront-scheduling-pre-init
										wavefront-scheduling-code
                    wavefront-scheduling-final
										$?passes)))
;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
;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.
;------------------------------------------------------------------------------
;this module is used to determine which regions should be targeted for pathing
(defmodule wavefront-scheduling-determinant
			  (import core ?ALL)
			  (import llvm ?ALL)
			  (import types ?ALL)
			  (import pipeline ?ALL)
			  (import indirect ?ALL)
			  (import rampancy ?ALL)
			  (import MAIN ?ALL))
;------------------------------------------------------------------------------
(defmodule wavefront-scheduling-determinant-cleanup
			  (import core ?ALL)
			  (import llvm ?ALL)
			  (import types ?ALL)
			  (import pipeline ?ALL)
			  (import indirect ?ALL)
			  (import rampancy ?ALL)
			  (import MAIN ?ALL))
;------------------------------------------------------------------------------
(defmodule wavefront-scheduling-pre-init
			  (import core ?ALL)
			  (import llvm ?ALL)
			  (import types ?ALL)
			  (import pipeline ?ALL)
			  (import indirect ?ALL)
			  (import rampancy ?ALL)
			  (import MAIN ?ALL))
;------------------------------------------------------------------------------
(defmodule wavefront-scheduling-code
			  (import core ?ALL)
			  (import llvm ?ALL)
			  (import types ?ALL)
			  (import pipeline ?ALL)
			  (import indirect ?ALL)
			  (import rampancy ?ALL)
			  (import MAIN ?ALL))
;------------------------------------------------------------------------------
(defmodule wavefront-scheduling-final
			  (import core ?ALL)
			  (import llvm ?ALL)
			  (import types ?ALL)
			  (import pipeline ?ALL)
			  (import indirect ?ALL)
			  (import rampancy ?ALL)
			  (import MAIN ?ALL))
;------------------------------------------------------------------------------
(defrule wavefront-scheduling::macro-expand-passes
			"Pushes the modules that make up this pass into the pass-description"
			?f <- (message (from pipeline)
								(to wavefront-scheduling)
								(action initial-fact))
			?p <- (object (is-a pass-description) (passes $?passes))
			=>
			(retract ?f)
			(modify-instance ?p (passes
										loop-region-merging
										dependency-analysis
										wavefront-scheduling-determinant
										paths-conditional
                    wavefront-scheduling-pre-init
										wavefront-scheduling-code
                    wavefront-scheduling-final
										$?passes)))
;------------------------------------------------------------------------------


added waltz test file

added waltz test file

;;; The Waltz Algorithm implemented using CLIPS
;;; The original source for the OPS5 benchmark suite is available
;;; at http://www.cs.utexas.edu/ftp/pub/ops5-benchmark-suite/

;;; The copyright notice from the original code:

;;; Copyright C 1991 Satoshi Nishiyama and the University of Texas at Austin
;;; anyone may copy and use this program the terms listed in the copyright
;;; notice in and covering the Communications of the ACM, the program is
;;; is not warranted to do anything

;;; Changes made for the CLIPS version
;;;
;;;   Reformatted code
;;;   Converted C code to deffunctions
;;;   Uses salience to obtain a number of rule firings consistent
;;;     with other rule engines running this benchmark

;;; ##########################################################################
;;; Deftemplates
;;;
;;; Lines have the lable line followed by the 2 points defining the line.
;;;
;;; Edges are like lines accept that they can be labeled, permanently labeled,
;;; and plotted.
;;;
;;; Junctions are defined by 4 points.  The basepoint is where the 3 (2) lines
;;; intersect.  The points p1, p2, p3 are the other endpoints of the lines at
;;; this junction
;;; ##########################################################################

(deftemplate stage
   (slot value))

(deftemplate line
   (slot p1 (type INTEGER))
   (slot p2 (type INTEGER)))

(deftemplate edge
   (slot p1 (type INTEGER))
   (slot p2 (type INTEGER))
   (slot joined (type BOOLEAN))
   (slot label)
   (slot plotted))

(deftemplate junction
   (slot p1 (type INTEGER))
   (slot p2 (type INTEGER))
   (slot p3 (type INTEGER))
   (slot base_point (type INTEGER))
   (slot jtype))

; ;;; #################################################################
; ;;; Deffunctions
; ;;;
; ;;; In the OPS5 version of this program, the following deffunctions
; ;;; were implemented in C code that needed to be linked with the OPS5
; ;;; interpreter. Using deffunctions allows the benchmark to be run
; ;;; without having to recompile and relink CLIPS with the C code used
; ;;; in the original benchmark. The performance impact of using
; ;;; deffunctions for this benchmark rather than C code is minimal.
; ;;; #################################################################

; (defglobal ?*MOD-NUM* = 100)

; ;;; *****
; ;;; atan2
; ;;; *****

; (deffunction atan2 (?y ?x)
;    (if (> ?x 0)
;       then
;       (return (atan (/ ?y ?x))))

;    (if (< ?x 0)
;       then
;       (return (- (atan (/ ?y ?x)) (pi))))

;    (if (> ?y 0) then
;       then
;       (return (pi)))

;    (if (< ?y 0)
;       then
;       (return (- 0 (pi))))

;    (return undefined))

; ;;; *****
; ;;; get-y
; ;;; *****

; (deffunction get-y (?val)
;    (mod ?val ?*MOD-NUM*))

; ;;; *****
; ;;; get-x
; ;;; *****

; (deffunction get-x (?val)
;    (integer (/ ?val ?*MOD-NUM*)))

; ;;; *********
; ;;; get-angle
; ;;; *********

; (deffunction get-angle (?p1 ?p2)
;    (bind ?delta-x (- (get-x ?p2) (get-x ?p1)))
;    (bind ?delta-y (- (get-y ?p2) (get-y ?p1)))
;    (if (= ?delta-x 0)
;       then
;        (if (> ?delta-y 0)
; 		  then (return (/ (pi) 2))
; 		  else (if (< ?delta-y 0) then (return (/ (pi) -2))))
;       else
;       (if (= ?delta-y 0)
;          then
;          (if (> ?delta-x 0)
;             then (return 0.0)
; 		    else (if (< ?delta-x 0) then return (pi)))
;          else
;          (return (atan2 ?delta-y ?delta-x)))))

; ;;; ***************
; ;;; inscribed-angle
; ;;; ***************

; (deffunction inscribed-angle (?basepoint ?p1 ?p2)

; 	;; Get the angle between line #1 and the origin and the angle
; 	;; between line #2 and the origin, and then subtract these values.

;    (bind ?angle1 (get-angle ?basepoint ?p1))
;    (bind ?angle2 (get-angle ?basepoint ?p2))
;    (bind ?temp (- ?angle1 ?angle2))

;    (if (< ?temp 0)
;       then (bind ?temp (- 0 ?temp)))

;    ;; We always want the smaller of the two angles inscribed, so
;    ;; if the answer is greater than 180 degrees, calculate the
;    ;; smaller angle and return it.

;    (if (> ?temp (pi))
;       then
;       (bind ?temp (- (* 2 (pi)) ?temp)))

;    (if (< ?temp 0)
;       then (return (- 0 ?temp)))

;    (return ?temp))

; ;;; ***************
; ;;; make-3-junction
; ;;; ***************

; (deffunction make-3-junction (?basepoint ?p1 ?p2 ?p3)
;    (bind ?angle12 (inscribed-angle ?basepoint ?p1 ?p2))
;    (bind ?angle13 (inscribed-angle ?basepoint ?p1 ?p3))
;    (bind ?angle23 (inscribed-angle ?basepoint ?p2 ?p3))

;    (bind ?sum1213 (+ ?angle12 ?angle13))
;    (bind ?sum1223 (+ ?angle12 ?angle23))
;    (bind ?sum1323 (+ ?angle13 ?angle23))

;    (if (< ?sum1213 ?sum1223)
;       then
;       (if (< ?sum1213 ?sum1323)
;          then
;          (bind ?sum ?sum1213)
;          (bind ?shaft ?p1)
;          (bind ?barb1 ?p2)
;          (bind ?barb2 ?p3)
;          else
;          (bind ?sum ?sum1323)
;          (bind ?shaft ?p3)
;          (bind ?barb1 ?p1)
;          (bind ?barb2 ?p2))
;       else
;       (if (< ?sum1223 ?sum1323)
;          then
;          (bind ?sum ?sum1223)
;          (bind ?shaft ?p2)
;          (bind ?barb1 ?p1)
;          (bind ?barb2 ?p3)
;          else
;          (bind ?sum ?sum1323)
;          (bind ?shaft ?p3)
;          (bind ?barb1 ?p1)
;          (bind ?barb2 ?p2)))

;    (bind ?delta (- ?sum (pi)))
;    (if (< ?delta 0)
;       then (bind ?delta (- 0 ?delta)))

;    (if (< ?delta 0.001)
;       then (bind ?jtype tee)
;       else
;       (if (> ?sum (pi))
;          then (bind ?jtype fork)
;          else (bind ?jtype arrow)))

;    (assert (junction (p1 (integer ?barb1))
;                      (p2 (integer ?shaft))
;                      (p3 (integer ?barb2))
;                      (base_point (integer ?basepoint))
;                      (jtype ?jtype))))

;;; ########
;;; Defrules
;;; ########

;;; *******************************************************
;;; begin: Our starting production. It checks to see if the
;;;   start flag is in WM, and if it is, it deletes it
;;; *******************************************************

(set-compiler ecblocksrand)

(defrule begin
	?f1 <- (stage (value start))
	=>
	(assert (line (p1 0122) (p2 0107)))
	(assert (line (p1 0107) (p2 2207)))
	(assert (line (p1 2207) (p2 3204)))
	(assert (line (p1 3204) (p2 6404)))
	(assert (line (p1 2216) (p2 2207)))
	(assert (line (p1 3213) (p2 3204)))
	(assert (line (p1 2216) (p2 3213)))
	(assert (line (p1 0107) (p2 2601)))
	(assert (line (p1 2601) (p2 7401)))
	(assert (line (p1 6404) (p2 7401)))
	(assert (line (p1 3213) (p2 6413)))
	(assert (line (p1 6413) (p2 6404)))
	(assert (line (p1 7416) (p2 7401)))
	(assert (line (p1 5216) (p2 6413)))
	(assert (line (p1 2216) (p2 5216)))
	(assert (line (p1 0122) (p2 5222)))
	(assert (line (p1 5222) (p2 7416)))
	(assert (line (p1 5222) (p2 5216)))
	(modify ?f1 (value duplicateStage)))

;;; **********************************************************************
;;; reverse_edges: If the duplicate flag is set, and there is still a line
;;;   in WM, delete the line and add two edges. One edge runs from p1 to
;;;   p2 and the other runs from p2 to p1. We then plot the edge.
;;; **********************************************************************

(defrule reverse_edges
	(stage (value duplicateStage))
	?f2 <- (line (p1 ?p1) (p2 ?p2))
	=>
	(assert (edge (p1 ?p1) (p2 ?p2) (joined false)))
    (assert (edge (p1 ?p2) (p2 ?p1) (joined false)))
	(retract ?f2))

;;; **************************************************************************
;;; done_reversing: If the duplicating flag is set, and there are no more
;;;   lines, then remove the duplicating flag and set the make junctions flag.
;;; **************************************************************************

(set-compiler pathblocks)
(defrule done_reversing
	(declare (salience -10))
	?f1 <- (stage (value duplicateStage))
	(not (line))
	=>
	(modify ?f1 (value detect_junctions)))

;;; *****************************************************************************
;;; make-3_junction: If three edges meet at a point and none of them have already
;;;   been joined in a junction, then make the corresponding jtype of junction and
;;;   label the edges joined.  This production calls make-3_junction to determine
;;;   what jtype of junction it is based on the angles inscribed by the
;;;   intersecting edges.
;;; *****************************************************************************

(set-compiler ecblocksrand)
(defrule make-3_junction
	(declare (salience 10))
	(stage (value detect_junctions))
	?f2 <- (edge (p1 ?base_point) (p2 ?p1) (joined false))
	?f3 <- (edge (p1 ?base_point) (p2 ?p2&~?p1) (joined false))
	?f4 <- (edge (p1 ?base_point) (p2 ?p3&~?p1&~?p2) (joined false))
	=>
	(make-3-junction ?base_point ?p1 ?p2 ?p3)
	(modify ?f2 (joined true))
	(modify ?f3 (joined true))
	(modify ?f4 (joined true)))

;;; ******************************************************
;;; make_L: If two, and only two, edges meet that have not
;;;   already been joined, then the junction is an "L".
;;; ******************************************************

(set-compiler pathblocks)
(defrule make_L
	(stage (value detect_junctions))
	?f2 <- (edge (p1 ?base_point) (p2 ?p2) (joined false))
	?f3 <- (edge (p1 ?base_point) (p2 ?p3&~?p2) (joined false))
	(not (edge (p1 ?base_point) (p2 ~?p2&~?p3)))
	=>
	(assert (junction (jtype L)
               		  (base_point ?base_point)
		              (p1 ?p2)
		              (p2 ?p3)))
	(modify ?f2 (joined true))
	(modify ?f3 (joined true)))

;;; ******************************************************************
;;; done_detecting: If the detect junctions flag is set, and there are
;;;   no more un_joined edges, set the find_initial_boundary flag.
;;; ******************************************************************

(defrule done_detecting
	(declare (salience -10))
	?f1 <- (stage (value detect_junctions))
	(not (edge (joined false)))
	=>
	(modify ?f1 (value find_initial_boundary)))

;;; ****************************************************
;;; initial_boundary_junction_L: If the initial boundary
;;;   junction is an L, then we know it's labelling
;;; ****************************************************

(defrules
(initial_boundary_junction_L
	?f1 <- (stage (value find_initial_boundary))
    (junction (jtype L)
              (base_point ?base_point)
              (p1 ?p1)
              (p2 ?p2))
	?f3 <- (edge (p1 ?base_point) (p2 ?p1))
	?f4 <- (edge (p1 ?base_point) (p2 ?p2))
    (not (junction (base_point ?bp&:(> ?bp ?base_point))))
	=>
    (modify ?f3 (label B))
	(modify ?f4 (label B))
	(modify ?f1 (value find_second_boundary)))

;;; ***************************************************
;;; initial_boundary_junction_arrow: Ditto for an arrow
;;; ***************************************************

(initial_boundary_junction_arrow
	?f1 <- (stage (value find_initial_boundary))
	(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))
	?f3 <- (edge (p1 ?bp) (p2 ?p1))
	?f4 <- (edge (p1 ?bp) (p2 ?p2))
	?f5 <- (edge (p1 ?bp) (p2 ?p3))
	(not (junction (base_point ?base_point&:(> ?base_point ?bp))))
	=>
    (modify ?f3 (label B))
	(modify ?f4 (label +))
	(modify ?f5 (label B))
	(modify ?f1 (value find_second_boundary)))

;;; ***********************************************************************
;;; second_boundary_junction_L: If we have already found the first boundary
;;;   point, then find the second boundary point, and label it.
;;; ***********************************************************************

(second_boundary_junction_L
	?f1 <- (stage (value find_second_boundary))
    (junction (jtype L) (base_point ?base_point) (p1 ?p1) (p2 ?p2))
	?f3 <- (edge (p1 ?base_point) (p2 ?p1))
	?f4 <- (edge (p1 ?base_point) (p2 ?p2))
    (not (junction (base_point ?bp&:(< ?bp ?base_point))))
	=>
    (modify ?f3 (label B))
    (modify ?f4 (label B))
    (modify ?f1 (value labeling)))

;;; ******************************
;;; second_boundary_junction_arrow
;;; ******************************

(second_boundary_junction_arrow
	?f1 <- (stage (value find_second_boundary))
	(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))
	?f3 <- (edge (p1 ?bp) (p2 ?p1))
	?f4 <- (edge (p1 ?bp) (p2 ?p2))
	?f5 <- (edge (p1 ?bp) (p2 ?p3))
	(not (junction (base_point ?base_point&:(< ?base_point ?bp))))
	=>
    (modify ?f3 (label B))
	(modify ?f4 (label +))
	(modify ?f5 (label B))
	(modify ?f1 (value labeling)))
)

;;; **********************************************************************
;;; match_edge: If we have an edge whose label we already know definitely,
;;;   then label the corresponding edge in the other direction
;;; **********************************************************************

(set-compiler ecblocksrand)

(defrule match_edge
	(stage (value labeling))
	?f2 <- (edge (p1 ?p1) (p2 ?p2) (label ?label& + | - | B))
	?f3 <- (edge (p1 ?p2) (p2 ?p1) (label nil))
	=>
	(modify ?f2 (plotted t))
	(modify ?f3 (label ?label) (plotted t)))

;;; The following productions propogate the possible labellings of the edges
;;; based on the labellings of edges incident on adjacent junctions.  Since
;;; from the initial boundary productions, we have determined the labellings of
;;; of atleast two junctions, this propogation will label all of the junctions
;;; with the possible labellings.  The search space is pruned due to filtering,
;;; i.e. - only label a junction in the ways physically possible based on the
;;; labellings of adjacent junctions.

;;; *******
;;; label_L
;;; *******

(defrules
(label_L
	(stage (value labeling))
	(junction (jtype L) (base_point ?p1))
	(edge (p1 ?p1) (p2 ?p2) (label + | -))
	?f4 <- (edge (p1 ?p1) (p2 ~?p2) (label nil))
	=>
	(modify ?f4 (label B)))

;;; ***********
;;; label_tee_A
;;; ***********

(label_tee_A
	(declare (salience 5))
	(stage (value labeling))
	(junction (jtype tee) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))
	?f3 <- (edge (p1 ?bp) (p2 ?p1) (label nil))
	?f4 <- (edge (p1 ?bp) (p2 ?p3))
	=>
    (modify ?f3 (label B))
	(modify ?f4 (label B)))

;;; ***********
;;; label_tee_B
;;; ***********

(label_tee_B
	(stage (value labeling))
	(junction (jtype tee) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))
	?f3 <- (edge (p1 ?bp) (p2 ?p1))
	?f4 <- (edge (p1 ?bp) (p2 ?p3) (label nil))
	=>
    (modify ?f3 (label B))
	(modify ?f4 (label B)))
)

;;; ************
;;; label_fork-1
;;; ************

(defrules
(label_fork-1
	(stage (value labeling))
	(junction (jtype fork) (base_point ?bp))
	(edge (p1 ?bp) (p2 ?p1) (label +))
	?f4 <- (edge (p1 ?bp) (p2 ?p2&~?p1) (label nil))
	?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1))
	=>
	(modify ?f4 (label +))
	(modify ?f5 (label +)))

;;; ************
;;; label_fork-2
;;; ************

(label_fork-2
	(stage (value labeling))
	(junction (jtype fork) (base_point ?bp))
	(edge (p1 ?bp) (p2 ?p1) (label B))
	(edge (p1 ?bp) (p2 ?p2&~?p1) (label -))
	?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))
	=>
	(modify ?f5 (label B)))

;;; ************
;;; label_fork-3
;;; ************

(label_fork-3
	(stage (value labeling))
	(junction (jtype fork) (base_point ?bp))
	(edge (p1 ?bp) (p2 ?p1) (label B))
	(edge (p1 ?bp) (p2 ?p2&~?p1) (label B))
	?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))
	=>
	(modify ?f5 (label -)))

;;; ************
;;; label_fork-4
;;; ************

(label_fork-4
	(stage (value labeling))
	(junction (jtype fork) (base_point ?bp))
	(edge (p1 ?bp) (p2 ?p1) (label -))
	(edge (p1 ?bp) (p2 ?p2&~?p1) (label -))
	?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))
	=>
	(modify ?f5 (label -)))
)
;;; **************
;;; label_arrow-1A
;;; **************

(defrule label_arrow-1A
	(declare (salience 5))
	(stage (value labeling))
	(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))
	(edge (p1 ?bp) (p2 ?p1) (label ?label& B | - ))
	?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))
	?f5 <- (edge (p1 ?bp) (p2 ?p3))
	=>
	(modify ?f4 (label +))
	(modify ?f5 (label ?label)))

;;; **************
;;; label_arrow-1B
;;; **************

(defrule label_arrow-1B
	(stage (value labeling))
	(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))
	(edge (p1 ?bp) (p2 ?p1) (label ?label& B | - ))
	?f4 <- (edge (p1 ?bp) (p2 ?p2))
	?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))
	=>
	(modify ?f4 (label +))
	(modify ?f5 (label ?label)))

;;; **************
;;; label_arrow-2A
;;; **************

(defrule label_arrow-2A
	(declare (salience 5))
	(stage (value labeling))
	(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))
	(edge (p1 ?bp) (p2 ?p3) (label ?label& B | - ))
	?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))
	?f5 <- (edge (p1 ?bp) (p2 ?p1))
	=>
	(modify ?f4 (label +))
	(modify ?f5 (label ?label)))

;;; **************
;;; label_arrow-2B
;;; **************

(defrule label_arrow-2B
	(stage (value labeling))
	(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))
	(edge (p1 ?bp) (p2 ?p3) (label ?label& B | - ))
	?f4 <- (edge (p1 ?bp) (p2 ?p2))
	?f5 <- (edge (p1 ?bp) (p2 ?p1) (label nil))
	=>
	(modify ?f4 (label +))
	(modify ?f5 (label ?label)))

;;; **************
;;; label_arrow-3A
;;; **************

(defrule label_arrow-3A
	(declare (salience 5))
	(stage (value labeling))
	(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))
	(edge (p1 ?bp) (p2 ?p1) (label +))
	?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))
	?f5 <- (edge (p1 ?bp) (p2 ?p3))
	=>
	(modify ?f4 (label -))
	(modify ?f5 (label +)))

;;; **************
;;; label_arrow-3B
;;; **************

(defrule label_arrow-3B
	(stage (value labeling))
	(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))
	(edge (p1 ?bp) (p2 ?p1) (label +))
	?f4 <- (edge (p1 ?bp) (p2 ?p2))
	?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))
	=>
	(modify ?f4 (label -))
	(modify ?f5 (label +)))

;;; **************
;;; label_arrow-4A
;;; **************

(defrule label_arrow-4A
	(declare (salience 5))
	(stage (value labeling))
	(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))
	(edge (p1 ?bp) (p2 ?p3) (label +))
	?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))
	?f5 <- (edge (p1 ?bp) (p2 ?p1))
	=>
	(modify ?f4 (label -))
	(modify ?f5 (label +)))

;;; **************
;;; label_arrow-4B
;;; **************

(defrule label_arrow-4B
	(stage (value labeling))
	(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))
	(edge (p1 ?bp) (p2 ?p3) (label +))
	?f4 <- (edge (p1 ?bp) (p2 ?p2))
	?f5 <- (edge (p1 ?bp) (p2 ?p1) (label nil))
	=>
	(modify ?f4 (label -))
	(modify ?f5 (label +)))

;;; **************
;;; label_arrow-5A
;;; **************

(defrule label_arrow-5A
	(declare (salience 5))
	(stage (value labeling))
	(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))
	(edge (p1 ?bp) (p2 ?p2) (label -))
	?f4 <- (edge (p1 ?bp) (p2 ?p1))
	?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))
	=>
	(modify ?f4 (label +))
	(modify ?f5 (label +)))

;;; **************
;;; label_arrow-5B
;;; **************

(defrule label_arrow-5B
	(stage (value labeling))
	(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))
	(edge (p1 ?bp) (p2 ?p2) (label -))
	?f4 <- (edge (p1 ?bp) (p2 ?p1) (label nil))
	?f5 <- (edge (p1 ?bp) (p2 ?p3))
	=>
	(modify ?f4 (label +))
	(modify ?f5 (label +)))

;;; *******************************************************************************
;;; done_labeling: The conflict resolution mechanism will only execute a production
;;;   if no productions that are more complicated are satisfied.  This production
;;;   is simple, so all of the above dictionary productions will fire before this
;;;   change of state production
;;; *******************************************************************************

(defrule done_labeling
	(declare (salience -10))
	?f1 <- (stage (value labeling))
	=>
	(modify ?f1 (value plot_remaining_edges)))

;;; **************************************************
;;; plot_remaining: At this point, some labellings may
;;;   have not been plotted, so plot them
;;; **************************************************

(defrules
(plot_remaining
	(stage (value plot_remaining_edges))
	?f2 <- (edge (plotted nil) (label ?label&~nil) (p1 ?p1) (p2 ?p2))
	=>
	(modify ?f2 (plotted t)))

;;; ********************************************************************************
;;; plot_boundaries: If we have been un able to label an edge, assume that it is a
;;;   boundary. This is a total Kludge, but what the hell. (if we assume only
;;;   valid drawings will be given for labeling, this assumption generally is true!)
;;; ********************************************************************************

(plot_boundaries
	(stage (value plot_remaining_edges))
	?f2 <- (edge (plotted nil) (label nil) (p1 ?p1) (p2 ?p2))
	=>
	(modify ?f2 (plotted t)))
)

;;; ****************************************************************************
;;; done_plotting: If there is no more work to do, then we are done and flag it.
;;; ****************************************************************************

(set-compiler pathblocks)
(defrule done_plotting
	(declare (salience -10))
	?f1 <- (stage (value plot_remaining_edges))
	(not (edge (plotted nil)))
	=>
	(modify ?f1 (value done)))

(export-gv "waltzTest.gv")

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


Updated menu.clp to use the pointer class

; /lib/chicanery/menu.clp - Contains methods and classes to simplify accessing
; menus
(defgeneric quickmenu)
(defgeneric quickmenu/show)
(defgeneric defmenu)
(defgeneric translate-menu-id)
(defclass Menu
  (is-a Pointer)
  (slot pointer-class
        (source composite)
        (default menu))
  (multislot menu-elements
             (type LEXEME)
             (storage local)
             (access initialize-only)
             (default ?NONE))
  (message-handler show-menu primary))

(defmessage-handler Menu show-menu primary
                    "shows the target menu and translates it to the corresponding symbolic
                    representation"
                    (?button)
                    (translate-menu-id (menu/show ?self:pointer ?button)
                                       ?self:menu-elements))

(defmethod quickmenu
  "Defines a menu pointer without any associated object"
  (($?entries LEXEME))
  (quickmenu ?entries))

(defmethod quickmenu
  "Defines a menu pointer without any associated object"
  ((?entries MULTIFIELD LEXEME))
  (new menu (expand$ ?entries)))

(defmethod defmenu
  "Constructs a Menu object and corresponding pointer"
  ((?name SYMBOL)
   ($?entries LEXEME))
  (defmenu ?name ?entries))
(defmethod defmenu
  "Constructs a Menu object and corresponding pointer"
  ((?name SYMBOL)
   (?entries MULTIFIELD LEXEME))
  (make-instance ?name of Menu
                 (pointer (quickmenu ?entries))
                 (menu-elements ?entries)))

(defmethod translate-menu-id
  "If we get -1 back then return the nil symbol"
  ((?id INTEGER (= ?id -1))
   (?elements MULTIFIELD LEXEME))
  nil)

(defmethod translate-menu-id
  "Translates numeric input from menu/show to symbolic representation"
  ((?id INTEGER (> ?id -1))
   (?elements MULTIFIELD LEXEME))
  ; We are one indexed while libevent is zero indexed
  (return (nth$ (+ ?id 1) ?elements)))

(defmethod translate-menu-id
  "Translates numeric input from menu/show to symbolic representation"
  ((?id INTEGER)
   ($?elements LEXEME))
  (translate-menu-id ?id ?elements))

(defmethod quickmenu/show
  "Construct a quick list and return a symbolic representation"
  ((?elements MULTIFIELD LEXEME)
   (?button INTEGER))
  (translate-menu-id (menu/show (quickmenu ?elements) ?button) ?elements))

; /lib/chicanery/menu.clp - Contains methods and classes to simplify accessing
; menus
(defgeneric quickmenu)
(defgeneric quickmenu/show)
(defgeneric defmenu)
(defgeneric translate-menu-id)
(defclass Menu
  (is-a USER)
  (slot pointer
        (type EXTERNAL-ADDRESS)
        (access initialize-only)
        (storage local)
        (default ?NONE))
  (multislot menu-elements
             (type LEXEME)
             (storage local)
             (access initialize-only)
             (default ?NONE))
  (message-handler show-menu primary))

(defmessage-handler Menu show-menu primary
                    "shows the target menu and translates it to the corresponding symbolic
                    representation"
                    (?button)
                    (translate-menu-id (menu/show ?self:pointer ?button)
                                       ?self:menu-elements))

(defmethod quickmenu
  "Defines a menu pointer without any associated object"
  (($?entries LEXEME))
  (quickmenu ?entries))

(defmethod quickmenu
  "Defines a menu pointer without any associated object"
  ((?entries MULTIFIELD LEXEME))
  (new menu (expand$ ?entries)))

(defmethod defmenu
  "Constructs a Menu object and corresponding pointer"
  ((?name SYMBOL)
   ($?entries LEXEME))
  (defmenu ?name ?entries))
(defmethod defmenu
  "Constructs a Menu object and corresponding pointer"
  ((?name SYMBOL)
   (?entries MULTIFIELD LEXEME))
  (make-instance ?name of Menu
                 (pointer (quickmenu ?entries))
                 (menu-elements ?entries)))

(defmethod translate-menu-id
  "If we get -1 back then return the nil symbol"
  ((?id INTEGER (= ?id -1))
   (?elements MULTIFIELD LEXEME))
  nil)

(defmethod translate-menu-id
  "Translates numeric input from menu/show to symbolic representation"
  ((?id INTEGER (> ?id -1))
   (?elements MULTIFIELD LEXEME))
  ; We are one indexed while libevent is zero indexed
  (return (nth$ (+ ?id 1) ?elements)))

(defmethod translate-menu-id
  "Translates numeric input from menu/show to symbolic representation"
  ((?id INTEGER)
   ($?elements LEXEME))
  (translate-menu-id ?id ?elements))

(defmethod quickmenu/show
  "Construct a quick list and return a symbolic representation"
  ((?elements MULTIFIELD LEXEME)
   (?button INTEGER))
  (translate-menu-id (menu/show (quickmenu ?elements) ?button) ?elements))


Nuevo menu de cambio de estado

Nuevo menu de cambio de estado

; David Yzaguirre Gonzalez
; 200819312
(deftemplate Seleccion
	(slot nombre (type STRING))
	(slot ata (type INTEGER))
	(slot med (type INTEGER))
	(slot def (type INTEGER))
	(slot ip (type INTEGER))
)
(deftemplate Jugador
	(slot nombre (type STRING))
	(slot Seleccion (type STRING))
	(slot Media (type INTEGER))
	(slot Dorsal (type INTEGER))

	(slot centros (type INTEGER)) ; ATAQUE
	(slot definicion (type INTEGER)) ; ATAQUE
	(slot precision_cabeza (type INTEGER)) ; ATAQUE
	(slot pases_cortos (type INTEGER)) ; ATAQUE
	(slot voleas (type INTEGER)) ; ATAQUE
	(slot regates (type INTEGER)) ; HABILIDAD
	(slot efecto (type INTEGER)) ; HABILIDAD
	(slot precision_falta (type INTEGER)) ; HABILIDAD
	(slot pases_largos (type INTEGER)) ; HABILIDAD
	(slot control_balon (type INTEGER)) ; HABILIDAD
	(slot aceleracion (type INTEGER)) ; MOVIMIENTO
	(slot velocidad_sprint (type INTEGER)) ; MOVIMIENTO
	(slot agilidad (type INTEGER)) ; MOVIMIENTO
	(slot mreflejos (type INTEGER)) ; MOVIMIENTO
	(slot equilibrio (type INTEGER)) ; MOVIMIENTO
	(slot potencia_disparo (type INTEGER)) ; POTENCIA
	(slot saldo (type INTEGER)) ; POTENCIA
	(slot resistencia (type INTEGER)) ; POTENCIA
	(slot fuerza (type INTEGER)) ; POTENCIA
	(slot disparos_lejanos (type INTEGER)) ; POTENCIA
	(slot agresividad (type INTEGER)) ; MENTALIDAD
	(slot tactico (type INTEGER)) ; MENTALIDAD
	(slot mposicionamiento (type INTEGER)) ; MENTALIDAD
	(slot vision (type INTEGER)) ; MENTALIDAD
	(slot penaltis (type INTEGER)) ; MENTALIDAD
	(slot marcaje (type INTEGER)) ; DEFENSA
	(slot entrada (type INTEGER)) ; DEFENSA
	(slot entrada_agresiva (type INTEGER)) ; DEFENSA
	(slot estirada (type INTEGER)) ; PORTEROS
	(slot parada (type INTEGER)) ; PORTEROS
	(slot saque_puerta (type INTEGER)) ; PORTEROS
	(slot posicionamiento (type INTEGER)) ; PORTEROS
	(slot reflejos (type INTEGER)) ; PORTEROS
)
(defglobal ?*rival* = "")
(defglobal ?*EstrategiaRival* = "Defensiva")
(defglobal ?*EstrategiaBolivia* = "Defensiva")
(defglobal ?*Defensa* = "Bien")
(defglobal ?*Ataque* = "Bien")
(deftemplate tiene-goles
	(slot equipo (type STRING))
	(slot goles (type INTEGER))
)
(defrule menu-o9
	?f <- (menu-oficial 8)
=>
	(retract ?f)
)
(defrule menu-o8
	?f <- (menu-oficial 7)
=>
	(printout t "se recomienda" crlf)
	(retract ?f)
	(assert (menu-oficial 0))
)
(defrule menu-o7
	?f <- (menu-oficial 6)
=>
	(printout t "Bolivia esta atacando actualmente: " ?*Ataque* crlf "La nueva es [Bien|Mal]: ")
	(bind ?*Ataque* (readline))
	(retract ?f)
	(assert (menu-oficial 0))
)
(defrule menu-o6
	?f <- (menu-oficial 5)
=>
	(printout t "Bolivia se esta defendiendo actualmente: " ?*Defensa* crlf "La nueva es [Bien|Mal]: ")
	(bind ?*Defensa* (readline))
	(retract ?f)
	(assert (menu-oficial 0))
)
(defrule menu-o5
	?f <- (menu-oficial 4)
=>
	(printout t "Bolivia tiene estrategia actual: " ?*EstrategiaBolivia* crlf "La nueva es [Ofensiva|Defensiva]: ")
	(bind ?*EstrategiaBolivia* (readline))
	(retract ?f)
	(assert (menu-oficial 0))
)
(defrule menu-o4
	?f <- (menu-oficial 3)
=>
	(printout t ?*rival* " tiene estrategia actual: " ?*EstrategiaRival* crlf "La nueva es [Ofensiva|Defensiva]: ")
	(bind ?*EstrategiaRival* (readline))
	(retract ?f)
	(assert (menu-oficial 0))
)
(defrule menu-o3
	?f <- (menu-oficial 2)
	?tg <- (tiene-goles (equipo ?r) (goles ?goles))
	(test (eq ?r ?*rival*))
=>
	(bind ?g (+ ?goles 1))
	(modify ?tg (goles ?g))
	(printout t "Marcador" ?*rival* ": " ?g)
	(retract ?f)
	(assert (menu-oficial 0))
)
(defrule menu-o2
	?f <- (menu-oficial 1)
	?tg <- (tiene-goles (equipo "Bolivia") (goles ?goles))
=>
	(bind ?g (+ ?goles 1))
	(modify ?tg (goles ?g))
	(printout t "Marcador Bolivia: " ?g)
	(retract ?f)
	(assert (menu-oficial 0))
)
(defrule menu-oficial1
	?f <- (menu-oficial 0)
=>
	(printout t crlf crlf "Opciones de ingreso para estado del partido:" crlf "1.) Nuestro Equipo anotó gol" crlf "2.) Equipo Rival anotó gol" crlf "3.) Equipo Rival tiene estrategia..." crlf "4.) Equipo Bolivia tiene estrategia..." crlf "5.) Nuestra defensa cambio para..." crlf "6.) Nuestro ataque cambio para..." crlf "7.) Solicitar Recomendacion" crlf "8.) Salir" crlf)
	(printout t "Elija opcion [1-7]: ")
	(bind ?opcion (read))
	(retract ?f)
	(assert (menu-oficial ?opcion))
	(printout t crlf)
)
(defrule seleccion-jugador
	(declare (salience 201))
	(initial-fact)
=>
	(printout t crlf "Ingrese dorsal de jugador 1: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 1))
	(printout t crlf "Ingrese dorsal de jugador 2: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 2))
	(printout t crlf "Ingrese dorsal de jugador 3: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 3))
	(printout t crlf "Ingrese dorsal de jugador 4: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 4))
	(printout t crlf "Ingrese dorsal de jugador 5: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 5))
	(printout t crlf "Ingrese dorsal de jugador 6: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 6))
	(printout t crlf "Ingrese dorsal de jugador 7: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 7))
	(printout t crlf "Ingrese dorsal de jugador 8: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 8))
	(printout t crlf "Ingrese dorsal de jugador 9: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 9))
	(printout t crlf "Ingrese dorsal de jugador 10: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 10))
	(printout t crlf "Ingrese dorsal de jugador 11: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 11))
	(assert (menu-oficial 0))
)
(defrule jugadores
	(declare (salience 202))
	(initial-fact)
	(Jugador (nombre ?nombre) (Media ?media) (Dorsal ?dorsal))
=>
	(printout t ?dorsal ": " ?nombre ", tiene media " ?media "." crlf)
)
(defrule seleccion-rival
	(declare (salience 203))
	(initial-fact)
=>
	(printout t crlf "Seleccione Pais Rival: ")
	(bind ?*rival* (readline))
	(assert (tiene-goles (equipo ?*rival*) (goles 0)))
	(assert (tiene-goles (equipo "Bolivia") (goles 0)))
	;(assert (rival =(readline)))
	(printout t crlf "JUGADORES SELECCION BOLIVIA" crlf)
)
(defrule mostrar-paises
	(declare (salience 204))
	(initial-fact)
	(Seleccion (nombre ?nombre))
=>
	(printout t ?nombre crlf)
)
(defrule inicio
	(declare (salience 205))
	(initial-fact)
=>
	(load-facts main_facts.clp)
	;(printout t " Exito!!, Se cargaron los datos correctamente" crlf crlf )
	(printout t "Paises: " crlf)
)

; David Yzaguirre Gonzalez
; 200819312
(deftemplate Seleccion
	(slot nombre (type STRING))
	(slot ata (type INTEGER))
	(slot med (type INTEGER))
	(slot def (type INTEGER))
	(slot ip (type INTEGER))
)
(deftemplate Jugador
	(slot nombre (type STRING))
	(slot Seleccion (type STRING))
	(slot Media (type INTEGER))
	(slot Dorsal (type INTEGER))

	(slot centros (type INTEGER)) ; ATAQUE
	(slot definicion (type INTEGER)) ; ATAQUE
	(slot precision_cabeza (type INTEGER)) ; ATAQUE
	(slot pases_cortos (type INTEGER)) ; ATAQUE
	(slot voleas (type INTEGER)) ; ATAQUE
	(slot regates (type INTEGER)) ; HABILIDAD
	(slot efecto (type INTEGER)) ; HABILIDAD
	(slot precision_falta (type INTEGER)) ; HABILIDAD
	(slot pases_largos (type INTEGER)) ; HABILIDAD
	(slot control_balon (type INTEGER)) ; HABILIDAD
	(slot aceleracion (type INTEGER)) ; MOVIMIENTO
	(slot velocidad_sprint (type INTEGER)) ; MOVIMIENTO
	(slot agilidad (type INTEGER)) ; MOVIMIENTO
	(slot mreflejos (type INTEGER)) ; MOVIMIENTO
	(slot equilibrio (type INTEGER)) ; MOVIMIENTO
	(slot potencia_disparo (type INTEGER)) ; POTENCIA
	(slot saldo (type INTEGER)) ; POTENCIA
	(slot resistencia (type INTEGER)) ; POTENCIA
	(slot fuerza (type INTEGER)) ; POTENCIA
	(slot disparos_lejanos (type INTEGER)) ; POTENCIA
	(slot agresividad (type INTEGER)) ; MENTALIDAD
	(slot tactico (type INTEGER)) ; MENTALIDAD
	(slot mposicionamiento (type INTEGER)) ; MENTALIDAD
	(slot vision (type INTEGER)) ; MENTALIDAD
	(slot penaltis (type INTEGER)) ; MENTALIDAD
	(slot marcaje (type INTEGER)) ; DEFENSA
	(slot entrada (type INTEGER)) ; DEFENSA
	(slot entrada_agresiva (type INTEGER)) ; DEFENSA
	(slot estirada (type INTEGER)) ; PORTEROS
	(slot parada (type INTEGER)) ; PORTEROS
	(slot saque_puerta (type INTEGER)) ; PORTEROS
	(slot posicionamiento (type INTEGER)) ; PORTEROS
	(slot reflejos (type INTEGER)) ; PORTEROS
)
(defrule seleccion-jugador
	(declare (salience 201))
	(initial-fact)
=>
	(printout t crlf "Ingrese dorsal de jugador 1: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 1))
	(printout t crlf "Ingrese dorsal de jugador 2: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 2))
	(printout t crlf "Ingrese dorsal de jugador 3: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 3))
	(printout t crlf "Ingrese dorsal de jugador 4: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 4))
	(printout t crlf "Ingrese dorsal de jugador 5: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 5))
	(printout t crlf "Ingrese dorsal de jugador 6: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 6))
	(printout t crlf "Ingrese dorsal de jugador 7: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 7))
	(printout t crlf "Ingrese dorsal de jugador 8: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 8))
	(printout t crlf "Ingrese dorsal de jugador 9: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 9))
	(printout t crlf "Ingrese dorsal de jugador 10: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 10))
	(printout t crlf "Ingrese dorsal de jugador 11: ")
	(bind ?dorsal (read))
	(assert (jugador-en-pos ?dorsal 11))
)
(defrule jugadores
	(declare (salience 202))
	(initial-fact)
	(Jugador (nombre ?nombre) (Media ?media) (Dorsal ?dorsal))
=>
	(printout t ?dorsal ": " ?nombre ", tiene media " ?media "." crlf)
)
(defrule seleccion-rival
	(declare (salience 203))
	(initial-fact)
=>
	(printout t crlf "Seleccione Pais Rival: ")
	(assert (rival =(readline)))
	(printout t crlf "JUGADORES SELECCION BOLIVIA" crlf)
)
(defrule mostrar-paises
	(declare (salience 204))
	(initial-fact)
	(Seleccion (nombre ?nombre))
=>
	(printout t ?nombre crlf)
)
(defrule inicio
	(declare (salience 205))
	(initial-fact)
=>
	(load-facts main_facts.clp)
	;(printout t " Exito!!, Se cargaron los datos correctamente" crlf crlf )
	(printout t "Paises: " crlf)
)