747 lines
48 KiB
HTML
747 lines
48 KiB
HTML
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<link rel="stylesheet" href="../../coverage.css"/> <title> the_great_game/gossip/news_items.clj </title>
|
|
</head>
|
|
<body>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
001 (ns the-great-game.gossip.news-items
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
002 "Categories of news events interesting to gossip agents"
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
003 (:require [the-great-game.world.location :refer [distance-between]]
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
004 [the-great-game.time :refer [game-time]]))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
005
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
006 ;; The ideas here are based on the essay 'The spread of knowledge in a large
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
007 ;; game world', q.v.; they've advanced a little beyond that and will doubtless
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
008 ;; advance further in the course of writing and debugging this namespace.
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
009
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
010 ;; A news item is a map with the keys:
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
011 ;;
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
012 ;; * `date` - the date on which the reported event happened;
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
013 ;; * `nth-hand` - the number of agents the news item has passed through;
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
014 ;; * `verb` - what it is that happened (key into `news-topics`);
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
015 ;;
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
016 ;; plus other keys taken from the `keys` value associated with the verb in
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
017 ;; `news-topics`
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
018
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
019 (def news-topics
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
020 "Topics of interest to gossip agents. Topics are keyed in this map by
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
021 their `verbs`. The `keys` associated with each topic are the extra pieces
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
022 of information required to give context to a gossip item. Generally:
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
023
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
024 * `actor` is the id of the character who it is reported performed the
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
025 action;
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
026 * `other` is the id of the character on whom it is reported the action
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
027 was performed;
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
028 * `location` is the place at which the action was performed;
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
029 * `object` is an object (or possibly list of objects?) relevant to the
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
030 action;
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
031 * `price` is special to buy/sell, but of significant interest to merchants.
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
032
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
033 #### Notes:
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
034
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
035 ##### Characters:
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
036
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
037 *TODO* but note that at most all the receiver can learn about a character
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
038 from a news item is what the giver knows about that character, degraded by
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
039 what the receiver finds interesting about them. If we just pass the id here,
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
040 then either the receiver knows everything in the database about the
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
041 character, or else the receiver knows nothing at all about the character.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
042 Neither is desirable. Further thought needed.
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
043
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
044 ##### Locations:
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
045
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
046 A 'location' value is a list comprising at most the x/y coordinate location
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
047 and the ids of the settlement and region (possibly hierarchically) that contain
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
048 the location. If the x/y is not local to the home of the receiving agent, they
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
049 won't remember it and won't pass it on; if any of the ids are not interesting
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
050 So location information will degrade progressively as the item is passed along.
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
051
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
052 It is assumed that the `:home` of a character is a location in this sense.
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
053
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
054 ##### Inferences:
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
055
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
056 If an agent learns that Adam has married Betty, they can infer that Betty has
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
057 married Adam; if they learn that Charles killed Dorothy, that Dorothy has died.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
058 I'm not convinced that my representation of inferences here is ideal.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
059 "
|
|
</span><br/>
|
|
<span class="covered" title="13 out of 13 forms covered">
|
|
060 { ;; A significant attack is interesting whether or not it leads to deaths
|
|
</span><br/>
|
|
<span class="covered" title="8 out of 8 forms covered">
|
|
061 :attack {:verb :attack :keys [:actor :other :location]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
062 ;; Deaths of characters may be interesting
|
|
</span><br/>
|
|
<span class="covered" title="7 out of 7 forms covered">
|
|
063 :die {:verb :attack :keys [:actor :location]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
064 ;; Deliberate killings are interesting.
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
065 :kill {:verb :kill :keys [:actor :other :location]
|
|
</span><br/>
|
|
<span class="covered" title="8 out of 8 forms covered">
|
|
066 :inferences [{:verb :die :actor :other :other :nil}]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
067 ;; Marriages may be interesting
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
068 :marry {:verb :marry :keys [:actor :other :location]
|
|
</span><br/>
|
|
<span class="covered" title="8 out of 8 forms covered">
|
|
069 :inferences [{:verb :marry :actor :other :other :actor}]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
070 ;; The end of ongoing open conflict between to characters may be interesting
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
071 :peace {:verb :peace :keys [:actor :other :location]
|
|
</span><br/>
|
|
<span class="covered" title="8 out of 8 forms covered">
|
|
072 :inferences [{:verb :peace :actor :other :other :actor}]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
073 ;; Things related to the plot are interesting, but will require special
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
074 ;; handling. Extra keys may be required by particular plot events.
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
075 :plot {:verb :plot :keys [:actor :other :object :location]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
076 ;; Rapes are interesting.
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
077 :rape {:verb :rape :keys [:actor :other :location]
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
078 ;; Should you also infer from rape that actor is male and adult?
|
|
</span><br/>
|
|
<span class="covered" title="4 out of 4 forms covered">
|
|
079 :inferences [{:verb :attack}
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
080 {:verb :sex}
|
|
</span><br/>
|
|
<span class="covered" title="7 out of 7 forms covered">
|
|
081 {:verb :sex :actor :other :other :actor}]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
082 ;; Merchants, especially, are interested in prices in other markets
|
|
</span><br/>
|
|
<span class="covered" title="10 out of 10 forms covered">
|
|
083 :sell {:verb :sell :keys [:actor :other :object :location :price]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
084 ;; Sex can juicy gossip, although not normally if the participants are in an
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
085 ;; established sexual relationship.
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
086 :sex {:verb :sex :keys [:actor :other :location]
|
|
</span><br/>
|
|
<span class="covered" title="8 out of 8 forms covered">
|
|
087 :inferences [{:verb :sex :actor :other :other :actor}]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
088 ;; Thefts are interesting
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
089 :steal {:verb :steal :keys [:actor :other :object :location]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
090 ;; The succession of rulers is interesting; of respected craftsmen,
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
091 ;; potentially also interesting.
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
092 :succession {:verb :succession :keys [:actor :other :location :rank]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
093 ;; The start of ongoing open conflict between to characters may be interesting
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
094 :war {:verb :war :keys [:actor :other :location]
|
|
</span><br/>
|
|
<span class="covered" title="8 out of 8 forms covered">
|
|
095 :inferences [{:verb :war :actor :other :other :actor}]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
096 })
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
097
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
098
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
099 (defn interest-in-character
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
100 "Integer representation of how interesting this `character` is to this
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
101 `gossip`.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
102 *TODO:* this assumes that characters are passed as keywords, but, as
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
103 documented above, they probably have to be maps, to allow for degradation."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
104 [gossip character]
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
105 (count
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
106 (concat
|
|
</span><br/>
|
|
<span class="partial" title="6 out of 12 forms covered">
|
|
107 (filter #(= (:actor % character)) (:knowledge gossip))
|
|
</span><br/>
|
|
<span class="partial" title="6 out of 12 forms covered">
|
|
108 (filter #(= (:other % character)) (:knowledge gossip)))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
109
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
110 (defn interesting-character?
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
111 "Boolean representation of whether this `character` is interesting to this
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
112 `gossip`."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
113 [gossip character]
|
|
</span><br/>
|
|
<span class="covered" title="7 out of 7 forms covered">
|
|
114 (> (interest-in-character gossip character) 0))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
115
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
116 (defn interest-in-location
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
117 "Integer representation of how interesting this `location` is to this
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
118 `gossip`."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
119 [gossip location]
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
120 (cond
|
|
</span><br/>
|
|
<span class="partial" title="20 out of 21 forms covered">
|
|
121 (and (map? location) (number? (:x location)) (number? (:y location)))
|
|
</span><br/>
|
|
<span class="partial" title="8 out of 9 forms covered">
|
|
122 (if-let [home (:home gossip)]
|
|
</span><br/>
|
|
<span class="covered" title="5 out of 5 forms covered">
|
|
123 (let [d (distance-between location home)
|
|
</span><br/>
|
|
<span class="covered" title="4 out of 4 forms covered">
|
|
124 i (/ 10000 d) ;; 10000 at metre scale is 10km; interest should
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
125 ;;fall of with distance from home, but possibly on a log scale
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
126 ]
|
|
</span><br/>
|
|
<span class="covered" title="7 out of 7 forms covered">
|
|
127 (if (> i 1) i 0))
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
128 0)
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
129 (coll? location)
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
130 (reduce
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
131 +
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
132 (map
|
|
</span><br/>
|
|
<span class="covered" title="4 out of 4 forms covered">
|
|
133 #(interest-in-location gossip %)
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
134 location))
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
135 :else
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
136 (count
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
137 (filter
|
|
</span><br/>
|
|
<span class="covered" title="10 out of 10 forms covered">
|
|
138 #(some (fn [x] (= x location)) (:location %))
|
|
</span><br/>
|
|
<span class="covered" title="10 out of 10 forms covered">
|
|
139 (cons {:location (:home gossip)} (:knowledge gossip))))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
140
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
141 ;; (interest-in-location {:home [{0, 0} :test-home] :knowledge []} [:test-home])
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
142
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
143 (defn interesting-location?
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
144 "True if the location of this news `item` is interesting to this `gossip`."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
145 [gossip item]
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
146 (> (interest-in-location gossip (:location item)) 0))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
147
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
148 (defn interesting-object?
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
149 [gossip object]
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
150 ;; TODO: Not yet (really) implemented
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
151 true)
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
152
|
|
</span><br/>
|
|
<span class="partial" title="1 out of 2 forms covered">
|
|
153 (defn interesting-topic?
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
154 [gossip topic]
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
155 ;; TODO: Not yet (really) implemented
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
156 true)
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
157
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
158 (defn interesting-item?
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
159 "True if anything about this news `item` is interesting to this `gossip`."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
160 [gossip item]
|
|
</span><br/>
|
|
<span class="partial" title="13 out of 17 forms covered">
|
|
161 (or
|
|
</span><br/>
|
|
<span class="covered" title="6 out of 6 forms covered">
|
|
162 (interesting-character? gossip (:actor item))
|
|
</span><br/>
|
|
<span class="covered" title="6 out of 6 forms covered">
|
|
163 (interesting-character? gossip (:other item))
|
|
</span><br/>
|
|
<span class="covered" title="6 out of 6 forms covered">
|
|
164 (interesting-location? gossip (:location item))
|
|
</span><br/>
|
|
<span class="covered" title="6 out of 6 forms covered">
|
|
165 (interesting-object? gossip (:object item))
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 5 forms covered">
|
|
166 (interesting-topic? gossip (:verb item))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
167
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
168 (defn infer
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
169 "Infer a new knowledge item from this `item`, following this `rule`"
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
170 [item rule]
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
171 (reduce merge
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
172 item
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
173 (cons
|
|
</span><br/>
|
|
<span class="covered" title="5 out of 5 forms covered">
|
|
174 {:verb (:verb rule)}
|
|
</span><br/>
|
|
<span class="covered" title="13 out of 13 forms covered">
|
|
175 (map (fn [k] {k (apply (k rule) (list item))})
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
176 (remove
|
|
</span><br/>
|
|
<span class="covered" title="4 out of 4 forms covered">
|
|
177 #(= % :verb)
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
178 (keys rule))))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
179
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
180 (declare learn-news-item)
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
181
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
182 (defn make-all-inferences
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
183 "Return a list of knowledge entries inferred from this news `item` by this
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
184 `gossip`."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
185 [item]
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
186 (set
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
187 (reduce
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
188 concat
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
189 (map
|
|
</span><br/>
|
|
<span class="covered" title="10 out of 10 forms covered">
|
|
190 #(:knowledge (learn-news-item {} (infer item %) false))
|
|
</span><br/>
|
|
<span class="covered" title="7 out of 7 forms covered">
|
|
191 (:inferences (news-topics (:verb item)))))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
192
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
193 (defn degrade-character
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
194 "Return a character specification like this `character`, but comprising
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
195 only those properties this `gossip` is interested in."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
196 [gossip character]
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
197 ;; TODO: Not yet (really) implemented
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
198 character)
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
199
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
200 (defn degrade-location
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
201 "Return a location specification like this `location`, but comprising
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
202 only those elements this `gossip` is interested in. If none, return
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
203 `nil`."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
204 [gossip location]
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
205 (let [l (if
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
206 (coll? location)
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
207 (filter
|
|
</span><br/>
|
|
<span class="partial" title="5 out of 7 forms covered">
|
|
208 #(when (interesting-location? gossip %) %)
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
209 location))]
|
|
</span><br/>
|
|
<span class="partial" title="5 out of 7 forms covered">
|
|
210 (when-not (empty? l) l)))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
211
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
212 (defn learn-news-item
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
213 "Return a gossip like this `gossip`, which has learned this news `item` if
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
214 it is of interest to them."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
215 ;; TODO: Not yet implemented
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
216 ([gossip item]
|
|
</span><br/>
|
|
<span class="covered" title="5 out of 5 forms covered">
|
|
217 (learn-news-item gossip item true))
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
218 ([gossip item follow-inferences?]
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
219 (if
|
|
</span><br/>
|
|
<span class="covered" title="4 out of 4 forms covered">
|
|
220 (interesting-item? gossip item)
|
|
</span><br/>
|
|
<span class="covered" title="5 out of 5 forms covered">
|
|
221 (let [g (assoc gossip :knowledge
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
222 (cons
|
|
</span><br/>
|
|
<span class="covered" title="5 out of 5 forms covered">
|
|
223 (assoc
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
224 item
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
225 :nth-hand (if
|
|
</span><br/>
|
|
<span class="covered" title="5 out of 5 forms covered">
|
|
226 (number? (:nth-hand item))
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 5 forms covered">
|
|
227 (inc (:nth-hand item))
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
228 1)
|
|
</span><br/>
|
|
<span class="partial" title="8 out of 11 forms covered">
|
|
229 :date (if (number? (:date item)) (:date item) (game-time))
|
|
</span><br/>
|
|
<span class="covered" title="6 out of 6 forms covered">
|
|
230 :location (degrade-location gossip (:location item))
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
231 ;; ought to degratde the location
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
232 ;; ought to maybe-degrade characters we're not yet interested in
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
233 )
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
234 ;; ought not to add knowledge items we already have, except
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
235 ;; to replace if new item is of increased specificity
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
236 (:knowledge gossip)))]
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
237 (if follow-inferences?
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
238 (assoc
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
239 g
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
240 :knowledge
|
|
</span><br/>
|
|
<span class="covered" title="8 out of 8 forms covered">
|
|
241 (concat (:knowledge g) (make-all-inferences item)))
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
242 g))
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
243 gossip)))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
244
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
245
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
246
|
|
</span><br/>
|
|
</body>
|
|
</html>
|