777 lines
50 KiB
HTML
777 lines
50 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 By implication, the character values passed should include *all* the
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
045 information the giver knows about the character; that can then be degraded
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
046 as the receiver stores only that segment which the receiver finds
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
047 interesting.
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
048
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
049 ##### Locations:
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
050
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
051 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">
|
|
052 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">
|
|
053 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">
|
|
054 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">
|
|
055 So location information will degrade progressively as the item is passed along.
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
056
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
057 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">
|
|
058
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
059 ##### Inferences:
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
060
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
061 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">
|
|
062 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">
|
|
063 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">
|
|
064 "
|
|
</span><br/>
|
|
<span class="covered" title="13 out of 13 forms covered">
|
|
065 { ;; A significant attack is interesting whether or not it leads to deaths
|
|
</span><br/>
|
|
<span class="covered" title="8 out of 8 forms covered">
|
|
066 :attack {:verb :attack :keys [:actor :other :location]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
067 ;; Deaths of characters may be interesting
|
|
</span><br/>
|
|
<span class="covered" title="7 out of 7 forms covered">
|
|
068 :die {:verb :die :keys [:actor :location]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
069 ;; Deliberate killings are interesting.
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
070 :kill {:verb :kill :keys [:actor :other :location]
|
|
</span><br/>
|
|
<span class="covered" title="8 out of 8 forms covered">
|
|
071 :inferences [{:verb :die :actor :other :other :nil}]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
072 ;; Marriages may be interesting
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
073 :marry {:verb :marry :keys [:actor :other :location]
|
|
</span><br/>
|
|
<span class="covered" title="8 out of 8 forms covered">
|
|
074 :inferences [{:verb :marry :actor :other :other :actor}]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
075 ;; The end of ongoing open conflict between to characters may be interesting
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
076 :peace {:verb :peace :keys [:actor :other :location]
|
|
</span><br/>
|
|
<span class="covered" title="8 out of 8 forms covered">
|
|
077 :inferences [{:verb :peace :actor :other :other :actor}]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
078 ;; Things related to the plot are interesting, but will require special
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
079 ;; handling. Extra keys may be required by particular plot events.
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
080 :plot {:verb :plot :keys [:actor :other :object :location]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
081 ;; Rapes are interesting.
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
082 :rape {:verb :rape :keys [:actor :other :location]
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
083 ;; Should you also infer from rape that actor is male and adult?
|
|
</span><br/>
|
|
<span class="covered" title="4 out of 4 forms covered">
|
|
084 :inferences [{:verb :attack}
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
085 {:verb :sex}
|
|
</span><br/>
|
|
<span class="covered" title="7 out of 7 forms covered">
|
|
086 {:verb :sex :actor :other :other :actor}]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
087 ;; Merchants, especially, are interested in prices in other markets
|
|
</span><br/>
|
|
<span class="covered" title="10 out of 10 forms covered">
|
|
088 :sell {:verb :sell :keys [:actor :other :object :location :price]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
089 ;; 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">
|
|
090 ;; established sexual relationship.
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
091 :sex {:verb :sex :keys [:actor :other :location]
|
|
</span><br/>
|
|
<span class="covered" title="8 out of 8 forms covered">
|
|
092 :inferences [{:verb :sex :actor :other :other :actor}]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
093 ;; Thefts are interesting
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
094 :steal {:verb :steal :keys [:actor :other :object :location]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
095 ;; The succession of rulers is interesting; of respected craftsmen,
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
096 ;; potentially also interesting.
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
097 :succession {:verb :succession :keys [:actor :other :location :rank]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
098 ;; The start of ongoing open conflict between to characters may be interesting
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
099 :war {:verb :war :keys [:actor :other :location]
|
|
</span><br/>
|
|
<span class="covered" title="8 out of 8 forms covered">
|
|
100 :inferences [{:verb :war :actor :other :other :actor}]}
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
101 })
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
102
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
103
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
104 (defn interest-in-character
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
105 "Integer representation of how interesting this `character` is to this
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
106 `gossip`.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
107 *TODO:* this assumes that characters are passed as keywords, but, as
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
108 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">
|
|
109 [gossip character]
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
110 (count
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
111 (concat
|
|
</span><br/>
|
|
<span class="partial" title="6 out of 12 forms covered">
|
|
112 (filter #(= (:actor % character)) (:knowledge gossip))
|
|
</span><br/>
|
|
<span class="partial" title="6 out of 12 forms covered">
|
|
113 (filter #(= (:other % character)) (:knowledge gossip)))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
114
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
115 (defn interesting-character?
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
116 "Boolean representation of whether this `character` is interesting to this
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
117 `gossip`."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
118 [gossip character]
|
|
</span><br/>
|
|
<span class="covered" title="6 out of 6 forms covered">
|
|
119 (> (interest-in-character gossip character) 0))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
120
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
121 (defn interest-in-location
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
122 "Integer representation of how interesting this `location` is to this
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
123 `gossip`."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
124 [gossip location]
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
125 (cond
|
|
</span><br/>
|
|
<span class="partial" title="20 out of 21 forms covered">
|
|
126 (and (map? location) (number? (:x location)) (number? (:y location)))
|
|
</span><br/>
|
|
<span class="partial" title="8 out of 9 forms covered">
|
|
127 (if-let [home (:home gossip)]
|
|
</span><br/>
|
|
<span class="covered" title="5 out of 5 forms covered">
|
|
128 (let [d (distance-between location home)
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
129 i (/ 10000 d) ;; 10000 at metre scale is 10km; interest should
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
130 ;;fall off with distance from home, but possibly on a log scale
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
131 ]
|
|
</span><br/>
|
|
<span class="covered" title="6 out of 6 forms covered">
|
|
132 (if (> i 1) i 0))
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
133 0)
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
134 (coll? location)
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
135 (reduce
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
136 +
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
137 (map
|
|
</span><br/>
|
|
<span class="covered" title="4 out of 4 forms covered">
|
|
138 #(interest-in-location gossip %)
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
139 location))
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
140 :else
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
141 (count
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
142 (filter
|
|
</span><br/>
|
|
<span class="covered" title="9 out of 9 forms covered">
|
|
143 #(some (fn [x] (= x location)) (:location %))
|
|
</span><br/>
|
|
<span class="covered" title="10 out of 10 forms covered">
|
|
144 (cons {:location (:home gossip)} (:knowledge gossip))))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
145
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
146 ;; (interest-in-location {:home [{0, 0} :test-home] :knowledge []} [:test-home])
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
147
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
148 (defn interesting-location?
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
149 "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">
|
|
150 [gossip item]
|
|
</span><br/>
|
|
<span class="covered" title="8 out of 8 forms covered">
|
|
151 (> (interest-in-location gossip (:location item)) 0))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
152
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
153 (defn interesting-object?
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
154 [gossip object]
|
|
</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="partial" title="1 out of 2 forms covered">
|
|
158 (defn interesting-topic?
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
159 [gossip topic]
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
160 ;; TODO: Not yet (really) implemented
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
161 true)
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
162
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
163 (defn interesting-item?
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
164 "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">
|
|
165 [gossip item]
|
|
</span><br/>
|
|
<span class="partial" title="13 out of 17 forms covered">
|
|
166 (or
|
|
</span><br/>
|
|
<span class="covered" title="6 out of 6 forms covered">
|
|
167 (interesting-character? gossip (:actor item))
|
|
</span><br/>
|
|
<span class="covered" title="6 out of 6 forms covered">
|
|
168 (interesting-character? gossip (:other item))
|
|
</span><br/>
|
|
<span class="covered" title="6 out of 6 forms covered">
|
|
169 (interesting-location? gossip (:location item))
|
|
</span><br/>
|
|
<span class="covered" title="6 out of 6 forms covered">
|
|
170 (interesting-object? gossip (:object item))
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 5 forms covered">
|
|
171 (interesting-topic? gossip (:verb item))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
172
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
173 (defn infer
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
174 "Infer a new knowledge item from this `item`, following this `rule`"
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
175 [item rule]
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
176 (reduce merge
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
177 item
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
178 (cons
|
|
</span><br/>
|
|
<span class="covered" title="5 out of 5 forms covered">
|
|
179 {:verb (:verb rule)}
|
|
</span><br/>
|
|
<span class="covered" title="13 out of 13 forms covered">
|
|
180 (map (fn [k] {k (apply (k rule) (list item))})
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
181 (remove
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
182 #(= % :verb)
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
183 (keys rule))))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
184
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
185 (declare learn-news-item)
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
186
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
187 (defn make-all-inferences
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
188 "Return a list of knowledge entries that can be inferred from this news
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
189 `item`."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
190 [item]
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
191 (set
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
192 (reduce
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
193 concat
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
194 (map
|
|
</span><br/>
|
|
<span class="covered" title="10 out of 10 forms covered">
|
|
195 #(:knowledge (learn-news-item {} (infer item %) false))
|
|
</span><br/>
|
|
<span class="covered" title="7 out of 7 forms covered">
|
|
196 (:inferences (news-topics (:verb item)))))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
197
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
198 (defn degrade-character
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
199 "Return a character specification like this `character`, but comprising
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
200 only those properties this `gossip` is interested in."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
201 [gossip character]
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
202 ;; TODO: Not yet (really) implemented
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
203 character)
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
204
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
205 (defn degrade-location
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
206 "Return a location specification like this `location`, but comprising
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
207 only those elements this `gossip` is interested in. If none, return
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
208 `nil`."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
209 [gossip location]
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
210 (let [l (if
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
211 (coll? location)
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
212 (filter
|
|
</span><br/>
|
|
<span class="partial" title="5 out of 7 forms covered">
|
|
213 #(when (interesting-location? gossip %) %)
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
214 location))]
|
|
</span><br/>
|
|
<span class="partial" title="5 out of 7 forms covered">
|
|
215 (when-not (empty? l) l)))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
216
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
217 (defn learn-news-item
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
218 "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">
|
|
219 it is of interest to them."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
220 ;; TODO: Not yet implemented
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
221 ([gossip item]
|
|
</span><br/>
|
|
<span class="covered" title="5 out of 5 forms covered">
|
|
222 (learn-news-item gossip item true))
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
223 ([gossip item follow-inferences?]
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
224 (if
|
|
</span><br/>
|
|
<span class="covered" title="4 out of 4 forms covered">
|
|
225 (interesting-item? gossip item)
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
226 (let
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
227 [g (assoc
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
228 gossip
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
229 :knowledge
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
230 (cons
|
|
</span><br/>
|
|
<span class="covered" title="5 out of 5 forms covered">
|
|
231 (assoc
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
232 item
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
233 :nth-hand (if
|
|
</span><br/>
|
|
<span class="covered" title="5 out of 5 forms covered">
|
|
234 (number? (:nth-hand item))
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 4 forms covered">
|
|
235 (inc (:nth-hand item))
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
236 1)
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
237 :time-stamp (if
|
|
</span><br/>
|
|
<span class="covered" title="5 out of 5 forms covered">
|
|
238 (number? (:time-stamp item))
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
239 (:time-stamp item)
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
240 (game-time))
|
|
</span><br/>
|
|
<span class="covered" title="6 out of 6 forms covered">
|
|
241 :location (degrade-location gossip (:location item))
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
242 ;; TODO: ought to maybe-degrade characters we're not yet interested in
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
243 )
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
244 ;; TODO: ought not to add knowledge items we already have, except
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
245 ;; to replace if new item is of increased specificity
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
246 (:knowledge gossip)))]
|
|
</span><br/>
|
|
<span class="covered" title="2 out of 2 forms covered">
|
|
247 (if follow-inferences?
|
|
</span><br/>
|
|
<span class="covered" title="3 out of 3 forms covered">
|
|
248 (assoc
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
249 g
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
250 :knowledge
|
|
</span><br/>
|
|
<span class="covered" title="8 out of 8 forms covered">
|
|
251 (concat (:knowledge g) (make-all-inferences item)))
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
252 g))
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
253 gossip)))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
254
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
255
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
256
|
|
</span><br/>
|
|
</body>
|
|
</html>
|