You must be logged in to post messages.
Please login or register

AI and RM Scripting
Moderated by Crazed Ewok, Gen_Rhys_Dallows

Hop to:    
Welcome! You are not logged in. Please Login or Register.No replies
SWGB Heaven » Forums » AI and RM Scripting » I have made an interesting discovery!
Bottom
Topic Subject:I have made an interesting discovery!
Captain Keno
Clone Trooper
posted 05-05-20 06:53 PM EDT (US)         
The code that is the A.I. for Galactic Battlegrounds I realized has a startling similarity and syntax from a similar language known as the CLIPS programming language.
CLIPS is a public domain software tool for building expert systems. The name is an acronym for "C Language Integrated Production System." The syntax and name was inspired by Charles Forgy's OPS5. The first versions of CLIPS were developed starting in 1985 at NASA-Johnson Space Center (as an alternative for existing system ART*Inference) until the mid-1990s when the development group's responsibilities ceased to focus on expert system technology. The original name of the project was NASA's AI Language (NAIL)

CLIPS is probably the most widely used expert system tool.[1] CLIPS itself is written in C, extensions can be written in C, and CLIPS can be called from C. Its syntax resembles that of the programming language Lisp.

CLIPS incorporates a complete object-oriented language for writing expert systems. COOL combines the programming paradigms of procedural, object oriented and logical (theorem proving) languages.
It can be downloaded here at this Source. I looked at the game and looked at the code and realised they looked pretty strongly similar. It could be just me though.


This is sample code from the CLIPS programming language:
(defmodule OAV (export deftemplate oav))

(deftemplate OAV::oav
(multislot object (type SYMBOL))
(multislot attribute (type SYMBOL))
(multislot value )
(slot CF (type FLOAT) (range -1.0 +1.0)))

(set-fact-duplication TRUE)

(defmethod OAV::combine-certainties
((?CF1 NUMBER (> ?CF1 0)) (?CF2 NUMBER (> ?CF2 0)))
(- (+ ?CF1 ?CF2) (* ?CF1 ?CF2)))

(defrule OAV::combine-certainties
(declare (auto-focus TRUE))
?fact1 <- (oav (object $?o)
(attribute $?a)
(value $?v)
(CF ?C1))
?fact2 <- (oav (object $?o)
(attribute $?a)
(value $?v)
(CF ?C2))
(test (neq ?fact1 ?fact2))
=>
(retract ?fact1)
(modify ?fact2
(CF (combine-certainties ?CF1 ?CF2))))

... And this is sample coding from the Star Wars Galactic Battlegrounds AI/Per scripts:

(defrule
(true)
=>
(generate-random-number 10)
(disable-self)
)

#load-if-defined REBEL

; 70% Air combat-arm, Troop combat-supp
(defrule
(goal combat-arm NOTICE)
(random-number > 3)
=>
(set-goal combat-arm AIR)
(set-goal combat-supp TROOP)
(disable-self)
)

(defrule
(goal combat-arm NOTICE)
(random-number <= 3)
=>
(set-goal combat-arm TROOP)
(set-goal combat-supp AIR)
(disable-self)
)

#end-if


#load-if-defined EMPIRE

; 70% Mech/HW combat-arm, Troop combat-supp
(defrule
(goal combat-arm NOTICE)
(random-number > 3)
=>
(set-goal combat-arm MECH/HW)
(set-goal combat-supp TROOP)
(disable-self)
)

(defrule
(goal combat-arm NOTICE)
(random-number <= 3)
=>
(set-goal combat-arm TROOP)
(set-goal combat-supp MECH/HW)
(disable-self)
)

#end-if


#load-if-defined NABOO

; Water map: 70% Air combat-arm, Sea combat-supp
(defrule
(goal special-map WATER)
(goal combat-arm NOTICE)
(random-number > 3)
=>
(set-goal combat-arm AIR)
(set-goal combat-supp SEA)
(disable-self)
)

(defrule
(goal special-map WATER)
(goal combat-arm NOTICE)
(random-number <= 3)
=>
(set-goal combat-arm SEA)
(set-goal combat-supp AIR)
(disable-self)
)

; Not water map: 70% Air combat-arm, Troop combat-supp
(defrule
(not (goal special-map WATER))
(goal combat-arm NOTICE)
(random-number > 3)
=>
(set-goal combat-arm AIR)
(set-goal combat-supp TROOP)
(disable-self)
)

(defrule
(not (goal special-map WATER))
(goal combat-arm NOTICE)
(random-number <= 3)
=>
(set-goal combat-arm TROOP)
(set-goal combat-supp AIR)
(disable-self)
)

#end-if


#load-if-defined GUNGANS

; Water map: 70% Sea combat-arm, Mech/HW combat-supp
(defrule
(goal special-map WATER)
(goal combat-arm NOTICE)
(random-number > 3)
=>
(set-goal combat-arm SEA)
(set-goal combat-supp MECH/HW)
(disable-self)
)

(defrule
(goal special-map WATER)
(goal combat-arm NOTICE)
(random-number <= 3)
=>
(set-goal combat-arm MECH/HW)
(set-goal combat-supp SEA)
(disable-self)
)

; Not water map: 70% Mech/HW combat-arm, Troop combat-supp
(defrule
(not (goal special-map WATER))
(goal combat-arm NOTICE)
(random-number > 3)
=>
(set-goal combat-arm MECH/HW)
(set-goal combat-supp TROOP)
(disable-self)
)

(defrule
(not (goal special-map WATER))
(goal combat-arm NOTICE)
(random-number <= 3)
=>
(set-goal combat-arm TROOP)
(set-goal combat-supp MECH/HW)
(disable-self)
)

#end-if


#load-if-defined WOOKIEES

; 70% Troop combat-arm, Air combat-supp
(defrule
(goal combat-arm NOTICE)
(random-number > 3)
=>
(set-goal combat-arm TROOP)
(set-goal combat-supp AIR)
(disable-self)
)

(defrule
(goal combat-arm NOTICE)
(random-number <= 3)
=>
(set-goal combat-arm AIR)
(set-goal combat-supp TROOP)
(disable-self)
)

#end-if


#load-if-defined FEDERATION

; Water map: 70% Mech/HW combat-arm, Sea combat-supp
(defrule
(goal special-map WATER)
(goal combat-arm NOTICE)
(random-number > 3)
=>
(set-goal combat-arm MECH/HW)
(set-goal combat-supp SEA)
(disable-self)
)

(defrule
(goal special-map WATER)
(goal combat-arm NOTICE)
(random-number <= 3)
=>
(set-goal combat-arm SEA)
(set-goal combat-supp MECH/HW)
(disable-self)
)

; Not water map: 70% Mech/HW combat-arm, Troop combat-supp
(defrule
(not (goal special-map WATER))
(goal combat-arm NOTICE)
(random-number > 3)
=>
(set-goal combat-arm MECH/HW)
(set-goal combat-supp TROOP)
(disable-self)
)

(defrule
(not (goal special-map WATER))
(goal combat-arm NOTICE)
(random-number <= 3)
=>
(set-goal combat-arm TROOP)
(set-goal combat-supp MECH/HW)
(disable-self)
)

#end-if

What do you guys think? don't they look just a bit familiar enough?
You must be logged in to post messages.
Please login or register

Hop to:    

SWGB Heaven | HeavenGames