Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (deftemplate unit "combat unit for game AI"
- (slot hitpoints (type NUMBER))
- (slot movespeed (type NUMBER))
- (slot name)
- (slot attack)
- )
- (deftemplate attack "combat weapon for game AI"
- (slot name)
- (slot damage (type NUMBER))
- )
- (deffacts
- (unit
- (name infantry-1)
- (hitpoints 1)
- (movespeed 3)
- (attack fire-rifle))
- (unit
- (name infantry-2)
- (hitpoints 1)
- (movespeed 3)
- (attack fire-rifle))
- (unit
- (name tank-1)
- (hitpoints 10)
- (movespeed 1)
- (attack fire-20mm))
- (attack
- (name fire-rifle)
- (damage 1))
- (attack
- (name fire-20mm)
- (damage 5))
- )
- (defrule resolve-attack
- (resolve ?unit1 ?attack ?unit2) ;unit1 does attack to unit2
- (unit (name ?u1) (hitpoints ?h1) (abilities ?attack) (movespeed ?m1))
- (attack (name ?attack) (damage ?d))
- ?uf1 <- (unit (name ?u1) (hitpoints ?h2) (abilities ?attack) (movespeed ?m1))
- =>
- (retract ?uf1)
- (if (< (- ?h2 ?d) 0) then
- (assert ((unit (name ?u1) (hitpoints (- ?h2 ?d)) (abilities ?attack) (movespeed ?m1)))))
- )
Add Comment
Please, Sign In to add comment