Changeset 917
- Timestamp:
- 02/03/2011 11:33:48 AM (10 years ago)
- Location:
- scenarios/GerminationX
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
scenarios/GerminationX/fungi/src/Fungi.hx
r909 r917 26 26 import truffle.SpriteEntity; 27 27 import truffle.SkeletonEntity; 28 29 // todo: remove this 30 import flash.display.Graphics; 31 import flash.display.Shape; 32 28 33 29 34 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 81 86 tf.height=40; 82 87 tf.background = true; 83 //tf.autoSize = true;84 88 //tf.backgroundColor = 0x8dd788; 85 89 tf.border = true; … … 151 155 public var Name:String; 152 156 var Debug:flash.text.TextField; 153 157 var BG:Graphics; 158 154 159 public function new(world:World, name:String, pos) 155 160 { … … 165 170 tf.y=Pos.y-25; 166 171 tf.height=150; 167 tf.width=1 00;168 tf.background = true;172 tf.width=140; 173 tf.background = false; 169 174 tf.autoSize = flash.text.TextFieldAutoSize.LEFT; 170 175 //tf.backgroundColor = 0x8dd788; … … 176 181 t.color= 0x000000; 177 182 tf.setTextFormat(t); 183 184 var figures:Shape = new Shape(); 185 BG = figures.graphics; 186 BG.beginFill(0xffffff,0.5); 187 BG.drawRect(tf.x,tf.y,tf.width,tf.height); 188 BG.endFill(); 189 cast(c,truffle.flash.FlashWorld).addChild(figures); 190 178 191 c.addChild(tf); 179 192 Debug=tf; … … 195 208 196 209 var text=Name+"\nMood:"+ee[0].content[0]+"\n"; 197 210 text+="Emotions:\n"; 198 211 for (i in 1...ee.length) 199 212 { 200 213 text+=ee[i].attrs.type+" "+ee[i].attrs.direction+"\n"; 201 text+=ee[i].attrs.cause+"\n"; 214 //text+=ee[i].attrs.cause+"\n"; 215 } 216 217 text+="Actions:\n"; 218 var acs = cast(e.actions,Array<Dynamic>); 219 for (i in 0...acs.length) 220 { 221 text+=acs[i]+"\n"; 202 222 } 203 223 … … 210 230 Debug.setTextFormat(t); 211 231 232 BG.clear(); 233 BG.beginFill(0xffffff,0.5); 234 BG.drawRect(Debug.x,Debug.y,Debug.width,Debug.height); 235 BG.endFill(); 212 236 213 237 //trace(text); -
scenarios/GerminationX/oak/data/characters/minds/roles/CanopySpirit/CanopySpirit.xml
r905 r917 36 36 <Relation target="canopy-fruit-b" like="2" respect="1"/> 37 37 <Relation target="canopy-fruit-c" like="3" respect="1"/> 38 <Relation target="canopy-ill-a" like="- 1" respect="1"/>39 <Relation target="canopy-ill-b" like="- 2" respect="1"/>40 <Relation target="canopy-ill-c" like="- 3" respect="1"/>38 <Relation target="canopy-ill-a" like="-4" respect="1"/> 39 <Relation target="canopy-ill-b" like="-6" respect="1"/> 40 <Relation target="canopy-ill-c" like="-8" respect="1"/> 41 41 </InterpersonalRelations> 42 42 … … 44 44 45 45 <!-- General emotional reactions used in more than one episode --> 46 <!--46 47 47 <EmotionalReaction desirability="6" desirabilityForOther="1" praiseworthiness="5"> 48 48 <Event subject="*" action="flower"/> … … 52 52 <Event subject="*" action="drop-leaves"/> 53 53 </EmotionalReaction> 54 -->54 55 55 </EventReactions> 56 56 … … 61 61 <Preconditions> 62 62 </Preconditions> 63 <ElicitingEmotion type="Love" minIntensity=" 2">63 <ElicitingEmotion type="Love" minIntensity="4"> 64 64 <CauseEvent/> 65 65 </ElicitingEmotion> … … 69 69 <Preconditions> 70 70 </Preconditions> 71 <ElicitingEmotion type="Hate" minIntensity=" 2">71 <ElicitingEmotion type="Hate" minIntensity="3"> 72 72 <CauseEvent/> 73 73 </ElicitingEmotion> -
scenarios/GerminationX/oak/data/characters/minds/roles/CoverSpirit/CoverSpirit.xml
r905 r917 44 44 45 45 <!-- General emotional reactions used in more than one episode --> 46 <!--<EmotionalReaction desirability="6" desirabilityForOther="1" praiseworthiness="5">46 <EmotionalReaction desirability="6" desirabilityForOther="1" praiseworthiness="5"> 47 47 <Event subject="*" action="flower"/> 48 48 </EmotionalReaction> … … 51 51 <Event subject="*" action="drop-leaves"/> 52 52 </EmotionalReaction> 53 -->53 54 54 </EventReactions> 55 55 … … 59 59 <Preconditions> 60 60 </Preconditions> 61 <ElicitingEmotion type="Love" minIntensity=" 2">61 <ElicitingEmotion type="Love" minIntensity="4"> 62 62 <CauseEvent/> 63 63 </ElicitingEmotion> … … 67 67 <Preconditions> 68 68 </Preconditions> 69 <ElicitingEmotion type="Hate" minIntensity=" 2">69 <ElicitingEmotion type="Hate" minIntensity="4"> 70 70 <CauseEvent/> 71 71 </ElicitingEmotion> -
scenarios/GerminationX/oak/data/characters/minds/roles/VerticalSpirit/VerticalSpirit.xml
r905 r917 42 42 43 43 <EventReactions> 44 <!--45 44 46 45 <EmotionalReaction desirability="6" desirabilityForOther="1" praiseworthiness="5"> … … 51 50 <Event subject="*" action="drop-leaves"/> 52 51 </EmotionalReaction> 53 --> 52 54 53 </EventReactions> 55 54 … … 61 60 <Preconditions> 62 61 </Preconditions> 63 <ElicitingEmotion type="Love" minIntensity=" 2">62 <ElicitingEmotion type="Love" minIntensity="4"> 64 63 <CauseEvent/> 65 64 </ElicitingEmotion> … … 69 68 <Preconditions> 70 69 </Preconditions> 71 <ElicitingEmotion type="Hate" minIntensity=" 2">70 <ElicitingEmotion type="Hate" minIntensity="4"> 72 71 <CauseEvent/> 73 72 </ElicitingEmotion> -
scenarios/GerminationX/oak/src/oak/core.clj
r905 r917 44 44 (defn tick [] 45 45 (Thread/sleep 1000) 46 (println ".")46 ;(println ".") 47 47 ;(game-world-print (deref my-game-world)) 48 (let [time ( .getTime (java.util.Date.))]48 (let [time (/ (.getTime (java.util.Date.)) 1000.0)] 49 49 (dosync (ref-set fatima-world 50 50 (world-run 51 51 (game-world-sync->fatima 52 52 (deref fatima-world) 53 (deref my-game-world))))) 53 (deref my-game-world) 54 time) time))) 54 55 (dosync (ref-set my-game-world 55 56 (game-world-update … … 96 97 (fn [a] 97 98 {:name (remote-agent-name a) 98 :emotions (remote-agent-emotions a)}) 99 :emotions (remote-agent-emotions a) 100 :actions (remote-agent-done a)}) 99 101 (world-agents (deref fatima-world))) 100 102 :indent 2)) -
scenarios/GerminationX/oak/src/oak/forms.clj
r905 r917 20 20 (defn discard [l n] 21 21 (cond 22 (empty? l) l23 (= 0 n) l22 (empty? l) '() 23 (= 0 n) '() 24 24 :else (cons (first l) (discard (rest l) (- n 1))))) 25 25 -
scenarios/GerminationX/oak/src/oak/game_world.clj
r905 r917 117 117 game-world)) 118 118 119 (defn game-world-sync->fatima [fatima-world game-world ]119 (defn game-world-sync->fatima [fatima-world game-world time] 120 120 (let [tile (game-world-get-tile game-world (make-vec2 0 0))] 121 121 (reduce … … 132 132 (do 133 133 (world-add-object fw 134 {"name" (str (:layer entity) "-" (:state entity) "-" (str (:id entity)))134 {"name" (str (:layer entity) "-" (:state entity)) 135 135 "owner" (:layer entity) 136 136 "position" (str (:x (:pos entity)) "," (:y (:pos entity))) 137 137 "tile" "0,0" 138 "type" "object"})) 138 "type" "object" 139 "time" time})) 139 140 :else fw)) 140 141 fatima-world -
scenarios/GerminationX/oak/src/oak/io.clj
r905 r917 83 83 (.readObject inp))) 84 84 85 ( comment (def buf (ByteBuffer/allocateDirect 4096))85 (def buf (ByteBuffer/allocateDirect 409600)) 86 86 87 87 (defn read-msg [sc] 88 88 (.clear buf) 89 (let [r (.read Linesc buf)]89 (let [r (.read sc buf)] 90 90 (if (> r 0) 91 91 (do … … 94 94 (.get buf bytearr) 95 95 (new String bytearr))) 96 false))) )96 false))) 97 97 98 (defn read-msg [reader] 98 (comment defn read-msg [reader] 99 (defn _ [] 100 (println "inner reader") 101 (let [s (.readLine reader)] 102 (println (str "[" s "]")) 103 (if (not s) 104 "" 105 (str s "\n" (_))))) 106 (println "read-msg in") 107 (_) 108 (println "read-msg out")) 109 110 (comment defn read-msg [reader] 99 111 (let [r (.readLine reader)] 100 ;(println "<----------------- " r)112 ;(println "<----------------- " r) 101 113 r)) 102 114 -
scenarios/GerminationX/oak/src/oak/remote_agent.clj
r898 r917 59 59 (InputStreamReader. 60 60 (.getInputStream (.socket socket)))) 61 toks (.split (read-msg reader) " ")]61 toks (.split (read-msg socket) " ")] 62 62 (send-msg socket "OK") 63 63 (struct -
scenarios/GerminationX/oak/src/oak/spirit.clj
r905 r917 35 35 36 36 (defn spirit-update [spirit remote-agent] 37 (println (:name spirit)) 38 (println (map 37 (comment println (:name spirit)) 38 (comment println (remote-agent-done remote-agent)) 39 (comment println (map 39 40 (fn [emotion] 40 41 (if (= (:tag emotion) :Mood) -
scenarios/GerminationX/oak/src/oak/world.clj
r905 r917 15 15 (ns oak.world 16 16 (:use 17 oak.forms 17 18 oak.remote-agent 18 19 oak.io) … … 130 131 (reduce 131 132 (fn [r obj] 132 (if (and (not r) (= pos (get obj "position")) )133 (if (and (not r) (= pos (get obj "position")) (= name (get obj "name"))) 133 134 obj r)) 134 135 false … … 140 141 (println (str "adding " (get object "name") " " (get object "position"))) 141 142 (world-broadcast-all world (str "ENTITY-ADDED " (get object "name"))) 143 (println (str (count (world-objects world)) "objects stored")) 142 144 (merge world {:objects (cons object (world-objects world))})) 143 145 world)) … … 181 183 (properties-changed world agent (.getEffects gstep))))))) 182 184 183 184 185 (defn world-process-agent [world agent msg] 185 ; (println (str "world-process-agentgot " msg))186 ;(println (str "world-process-agent for " (remote-agent-name agent) " got " msg)) 186 187 (let [toks (.split msg " ") 187 188 type (nth toks 0)] … … 192 193 (= type "look-at") 193 194 (do 195 ;(println (str (remote-agent-name agent) " -----------> LOOKING AT: " (nth toks 1))) 194 196 (send-msg (remote-agent-socket agent) 195 197 (str "LOOK-AT " (nth toks 1) " " 196 198 (hash-map-to-string 197 199 (world-get-properties world (nth toks 1))))) 198 agent) 200 (merge agent {:done (max-cons (str (world-time world) ": " msg) 201 (remote-agent-done agent) 4)})) 199 202 (= type "say") 200 203 (do (println "say") … … 219 222 :else 220 223 (do 221 (println "action")222 (println msg)224 ;(println "action") 225 ;(println msg) 223 226 (update-action-effects 224 227 world agent … … 235 238 (apply str (concat "ACTION-FINISHED " (remote-agent-name agent) " " 236 239 (map (fn [s] (str s " ")) toks)))) 237 (merge agent {:done ( cons (str (world-time world) ": " msg)238 (remote-agent-done agent))})))))240 (merge agent {:done (max-cons (str (world-time world) ": " msg) 241 (remote-agent-done agent) 4)}))))) 239 242 240 243 (defn world-check-for-new-agents [world] … … 257 260 258 261 (defn world-update-agent [world agent] 259 (let [msgs (read-msg (remote-agent- readeragent))]262 (let [msgs (read-msg (remote-agent-socket agent))] 260 263 (if msgs 261 264 (reduce … … 276 279 (world-update-agent world agent)) 277 280 (world-agents world)))})) 278 279 (defn world-run [world] 281 282 (def object-max-age 100) 283 284 (defn world-remove-old-objects [world time] 285 (merge world 286 {:objects 287 (doall 288 (filter 289 (fn [obj] 290 (< (- time (get obj "time")) object-max-age)) 291 (world-objects world)))})) 292 293 (defn world-run [world time] 280 294 (world-update-agents 281 (world-check-for-new-agents 282 (merge world {:time (+ (world-time world) 1)})))) 283 284 (defn world-crank [world] 285 (Thread/sleep 1000) 286 (println (map (fn [a] (remote-agent-said a)) (world-agents world))) 287 (println (map (fn [a] (remote-agent-done a)) (world-agents world))) 288 ;(println (world-agents world)) 289 (recur (world-run world))) 290 291 (defn thing [] 292 "<h1>ewewew!</h1>") 295 (world-remove-old-objects 296 (world-check-for-new-agents 297 (merge world {:time (+ (world-time world) 1)})) 298 time))) 299
Note: See TracChangeset
for help on using the changeset viewer.