Changeset 904


Ignore:
Timestamp:
02/01/2011 09:11:47 AM (10 years ago)
Author:
dave
Message:

connected game world to fatima

Location:
scenarios/GerminationX/oak
Files:
18 added
11 edited
1 moved

Legend:

Unmodified
Added
Removed
  • scenarios/GerminationX/oak/data/characters/minds/Actions.xml

    r898 r904  
    11<DomainActions> 
    2         <Action name="poke([target])"> 
     2        <Action name="flower([target])"> 
    33                <PreConditions> 
    44                        <Property name="[AGENT](pose)" operator="=" value="standing"/> 
     
    66                <Effects> 
    77                        <Effect probability="0.8"> 
    8                                 <Property name="[target](annoyed)" operator="=" value="True"/> 
     8                <!--            <Property name="[target](annoyed)" operator="=" value="True"/> --> 
    99                        </Effect> 
    1010                </Effects> 
    1111        </Action> 
    1212 
    13         <Action name="sing([target])"> 
     13        <Action name="drop-leaves([target])"> 
    1414                <PreConditions> 
    1515                        <Property name="[AGENT](pose)" operator="=" value="standing"/> 
     
    1717                <Effects> 
    1818                        <Effect probability="0.8"> 
    19                                 <Property name="[target](annoyed)" operator="=" value="True"/> 
     19                <!--            <Property name="[target](annoyed)" operator="=" value="True"/> --> 
    2020                        </Effect> 
    2121                </Effects> 
  • scenarios/GerminationX/oak/data/characters/minds/roles/CanopySpirit/CanopySpirit.xml

    r903 r904  
    1 <Character role="Canopy"> 
     1<Character role="CanopySpirit"> 
    22        <EmotionalThresholds> 
    33                <EmotionalThreshold emotion="Love" threshold="1" decay="10"/> 
     
    3030         
    3131        <InterpersonalRelations> 
    32                 <Relation target="Vertical" like="10" respect="10"/> 
    33                 <Relation target="Cover" like="2" respect="1"/> 
     32                <Relation target="VerticalSpirit" like="3" respect="10"/> 
     33                <Relation target="CoverSpirit" like="2" respect="1"/> 
    3434        <Relation target="canopy-grow-a" like="3" respect="1"/> 
    3535        <Relation target="canopy-fruit-a" like="1" respect="1"/> 
  • scenarios/GerminationX/oak/data/characters/minds/roles/CoverSpirit/CoverSpirit.xml

    r903 r904  
    1 <Character role="Cover"> 
     1<Character role="CoverSpirit"> 
    22        <EmotionalThresholds> 
    33                <EmotionalThreshold emotion="Love" threshold="3" decay="5"/> 
     
    3030         
    3131        <InterpersonalRelations> 
    32                 <Relation target="Vertical" like="10" respect="10"/> 
    33                 <Relation target="Canopy" like="-5" respect="-3"/> 
     32                <Relation target="VerticalSpirit" like="3" respect="1"/> 
     33                <Relation target="CanopySpirit" like="-5" respect="-3"/> 
    3434        <Relation target="cover-grow-a" like="3" respect="1"/> 
    3535        <Relation target="cover-fruit-a" like="1" respect="1"/> 
  • scenarios/GerminationX/oak/data/characters/minds/roles/VerticalSpirit/VerticalSpirit.xml

    r903 r904  
    1 <Character role="Vertical"> 
     1<Character role="VerticalSpirit"> 
    22        <EmotionalThresholds> 
    33                <EmotionalThreshold emotion="Love" threshold="3" decay="5"/> 
     
    3030         
    3131        <InterpersonalRelations> 
    32                 <Relation target="Canopy" like="5" respect="5"/> 
    33                 <Relation target="Cover" like="2" respect="1"/> 
     32                <Relation target="CanopySpirit" like="3" respect="5"/> 
     33                <Relation target="CoverSpirit" like="1" respect="1"/> 
    3434        <Relation target="vertical-grow-a" like="3" respect="1"/> 
    3535        <Relation target="vertical-fruit-a" like="1" respect="1"/> 
  • scenarios/GerminationX/oak/run.sh

    r898 r904  
    22sleep 50 
    33echo starting agents... 
    4 java -cp lib/FAtiMA.jar FAtiMA.Agent localhost 46874 false Canopy M Canopy Canopy strength:4 hurt:false pose:standing & 
    5 #sleep 1 
    6 #java -cp lib/FAtiMA.jar FAtiMA.Agent localhost 46874 false Cover M Cover Cover strength:8 hurt:false pose:standing & 
     4java -cp lib/FAtiMA.jar FAtiMA.Agent localhost 46874 false CanopySpirit F CanopySpirit CanopySpirit strength:4 hurt:false pose:standing & 
    75sleep 1 
    8 java -cp lib/FAtiMA.jar FAtiMA.Agent localhost 46874 false Vertical M Vertical Vertical strength:9 hurt:false pose:standing & 
     6java -cp lib/FAtiMA.jar FAtiMA.Agent localhost 46874 false CoverSpirit F CoverSpirit CoverSpirit strength:8 hurt:false pose:standing & 
     7sleep 1 
     8java -cp lib/FAtiMA.jar FAtiMA.Agent localhost 46874 false VerticalSpirit M VerticalSpirit VerticalSpirit strength:9 hurt:false pose:standing & 
    99 
    10 #sleep 30 
    11 #java -cp lib/FAtiMA.jar FAtiMA.Agent localhost 46874 false Luke M Bully Luke strength:9 hurt:false pose:standing & 
    12 #sleep 1 
    13 #java -cp lib/FAtiMA.jar FAtiMA.Agent localhost 46874 false John M Victim John strength:4 hurt:false pose:standing & 
  • scenarios/GerminationX/oak/src/oak/core.clj

    r899 r904  
    3535       "data/characters/minds/language/agent/en/language-set-1" 
    3636       "data/characters/minds/Actions.xml" 
    37        (list  
    38         "WiltedVine" 
    39         "AppleTree" 
    40              )))) 
     37       (list)))) 
    4138 
    4239;(def my-game-world (ref (game-world-load state-filename))) 
    43 (def my-game-world (ref (make-game-world 5000 4))) 
     40(def my-game-world (ref (make-game-world 100 1))) 
    4441 
    4542(append-spit log-filename (str (str (Date.)) " server started\n")) 
     
    6158                      time 1)))) 
    6259  (recur)) 
     60 
     61(tick) 
    6362 
    6463(defroutes main-routes 
     
    8786       ;(println (deref my-game-world)) 
    8887       (json/encode-to-str '("ok"))) 
    89   (GET "/spirit-sprites" [] 
    90        (update-islands "./islands" "./public/") 
    91        (read-islands "./public/islands")) 
     88  (GET "/spirit-sprites/:name" [name] 
     89       (update-islands (str "./" name) (str "./" name)) 
     90       (read-islands "./public/" name)) 
    9291 
    93   (comment 
    94   (GET "/agent-info" [] 
     92  (GET "/spirit-info" [] 
    9593       (json/encode-to-str (map 
    9694                            (fn [a] 
     
    10199  (GET "/perceive" [] 
    102100       (world-perceive-all (deref myworld))) 
    103   
     101   
     102  (comment  
    104103  (GET "/add-object/:obj" [obj] 
    105104       (println (str "adding " obj)) 
  • scenarios/GerminationX/oak/src/oak/forms.clj

    r871 r904  
    1717(defn modify [what f thing] 
    1818  (merge thing {what (f (what thing))})) 
     19 
     20(defn discard [l n] 
     21  (cond 
     22   (empty? l) l 
     23   (= 0 n) l 
     24   :else (cons (first l) (discard (rest l) (- n 1))))) 
     25 
     26(defn max-cons [o l m] 
     27  (cons o (discard l m))) 
  • scenarios/GerminationX/oak/src/oak/game_world.clj

    r898 r904  
    118118 
    119119(defn game-world-sync->fatima [fatima-world game-world] 
    120   fatima-world) 
     120  (let [tile (game-world-get-tile game-world (make-vec2 0 0))]  
     121    (reduce 
     122     (fn [fw entity] 
     123       (cond 
     124        (or 
     125         (= (:state entity) 'grow-a) 
     126         (= (:state entity) 'fruit-a) 
     127         (= (:state entity) 'fruit-b) 
     128         (= (:state entity) 'fruit-c) 
     129         (= (:state entity) 'ill-a) 
     130         (= (:state entity) 'ill-b) 
     131         (= (:state entity) 'ill-c)) 
     132        (do 
     133          (world-add-object fw 
     134                            {"name" (str (:layer entity) "-" (:state entity)) 
     135                             "owner" (:layer entity) 
     136                             "position" (str (:x (:pos entity)) "," (:y (:pos entity))) 
     137                             "tile" "0,0" 
     138                             "type" "object"})) 
     139        :else fw)) 
     140     fatima-world 
     141     (:entities tile)))) 
  • scenarios/GerminationX/oak/src/oak/io.clj

    r898 r904  
    9898(defn read-msg [reader] 
    9999  (let [r (.readLine reader)] 
    100     ;(println "<-----------------" r) 
     100    (println "<----------------- " r) 
    101101    r)) 
    102102 
    103103(defn send-msg [sc msg] 
    104   ;(println "-----------------------> sending:" msg) 
     104  (println "----------------> " msg) 
    105105  (let [msg (str msg "\n") 
    106106        enc (.newEncoder (Charset/forName "US-ASCII"))]   
    107107    (.write sc (.encode enc (CharBuffer/wrap msg))))) 
     108 
     109(let [i (atom 0)] 
     110  (defn generate-id [] 
     111    (swap! i inc))) 
    108112 
    109113(defn load-object [fname] 
     
    122126   objects)) 
    123127 
    124 (defn parse-xml [str] 
    125   (parse (ByteArrayInputStream. (.getBytes str "UTF-8")))) 
     128(defn parse-xml [s] 
     129  (try 
     130    (parse (ByteArrayInputStream. (.getBytes s "UTF-8")))  
     131    (catch org.xml.sax.SAXParseException e 
     132      (println (str "xml error with " s))))) 
  • scenarios/GerminationX/oak/src/oak/plant.clj

    r873 r904  
    4646(defn plant-size [plant] (:size plant)) 
    4747 
     48(defn plant-type->layer [type] 
     49  (cond 
     50   (= type "plant-001") "canopy" 
     51   (= type "plant-002") "vertical" 
     52   (= type "plant-003") "cover")) 
     53   
    4854(defn make-plant [pos type owner size] 
    49   (plant. pos type "" 'grow-a '() owner size 0 (+ 30 (Math/floor (rand 10))) start-health)) 
     55  (plant. pos type (plant-type->layer type) 
     56          'grow-a '() owner size 0 (+ 30 (Math/floor (rand 10))) start-health)) 
    5057 
    5158(defn make-random-plant [] 
  • scenarios/GerminationX/oak/src/oak/world.clj

    r898 r904  
    6363 
    6464(defn make-world [port agent-language-file actions-file objects] 
    65   (println "make-world") 
    6665  (struct world 
    6766          (load-objects objects) 
     
    128127                        (world-objects world)))))) 
    129128 
     129(defn world-get-object [world name pos] 
     130  (reduce 
     131   (fn [r obj] 
     132     (if (and (not r) (and (= name (get obj "name")) 
     133                           (= pos (get obj "position")))) 
     134       obj r)) 
     135   false 
     136   (world-objects world))) 
    130137 
    131138(defn world-add-object [world object] 
    132   (world-broadcast-all world (str "ENTITY-ADDED " (get object "name"))) 
    133   (merge world {:objects (cons object (world-objects world))})) 
     139  (if (not (world-get-object world (get object "name") (get object "position"))) 
     140    (do 
     141      (println (str "adding " (get object "name") " " (get object "position"))) 
     142      (world-broadcast-all world (str "ENTITY-ADDED " (get object "name"))) 
     143      (merge world {:objects (cons object (world-objects world))})) 
     144    world)) 
    134145 
    135146(defn list->commas [l] 
Note: See TracChangeset for help on using the changeset viewer.