Today is the Fifth Plough of the Plough
Implemented almost the whole of the Myth of the God Incarnate calendar
This commit is contained in:
parent
bd76e93568
commit
7e7a55c8ec
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -17,5 +17,3 @@ pom.xml.asc
|
|||
.nrepl-port
|
||||
.cpcache/
|
||||
*~
|
||||
|
||||
docs/cloverage/
|
||||
|
|
|
@ -15,19 +15,15 @@
|
|||
<td class="with-number">Total</td><td class="with-number">Blank</td><td class="with-number">Instrumented</td>
|
||||
</tr></thead>
|
||||
<tr>
|
||||
<td><a href="the_great_game/core.clj.html">the-great-game.core</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:33.333333333333336%;
|
||||
float:left;"> 2 </div><div class="not-covered"
|
||||
style="width:66.66666666666667%;
|
||||
float:left;"> 4 </div></td>
|
||||
<td class="with-number">33.33 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:66.66666666666667%;
|
||||
float:left;"> 2 </div><div class="not-covered"
|
||||
style="width:33.333333333333336%;
|
||||
<td><a href="the_great_game/agent/agent.clj.html">the-great-game.agent.agent</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:100.0%;
|
||||
float:left;"> 1 </div></td>
|
||||
<td class="with-number">66.67 %</td>
|
||||
<td class="with-number">6</td><td class="with-number">1</td><td class="with-number">3</td>
|
||||
<td class="with-number">100.00 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:100.0%;
|
||||
float:left;"> 1 </div></td>
|
||||
<td class="with-number">100.00 %</td>
|
||||
<td class="with-number">7</td><td class="with-number">2</td><td class="with-number">1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="the_great_game/gossip/gossip.clj.html">the-great-game.gossip.gossip</a></td><td class="with-bar"><div class="covered"
|
||||
|
@ -45,38 +41,55 @@
|
|||
<td class="with-number">65</td><td class="with-number">5</td><td class="with-number">39</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="the_great_game/merchants/markets.clj.html">the-great-game.merchants.markets</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:75.11737089201878%;
|
||||
float:left;"> 160 </div><div class="not-covered"
|
||||
style="width:24.88262910798122%;
|
||||
float:left;"> 53 </div></td>
|
||||
<td class="with-number">75.12 %</td>
|
||||
<td><a href="the_great_game/gossip/news_items.clj.html">the-great-game.gossip.news-items</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:89.34108527131782%;
|
||||
float:left;"> 461 </div><div class="not-covered"
|
||||
style="width:10.65891472868217%;
|
||||
float:left;"> 55 </div></td>
|
||||
<td class="with-number">89.34 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:56.81818181818182%;
|
||||
float:left;"> 25 </div><div class="partial"
|
||||
style="width:11.363636363636363%;
|
||||
float:left;"> 5 </div><div class="not-covered"
|
||||
style="width:31.818181818181817%;
|
||||
float:left;"> 14 </div></td>
|
||||
<td class="with-number">68.18 %</td>
|
||||
style="width:83.65384615384616%;
|
||||
float:left;"> 87 </div><div class="partial"
|
||||
style="width:8.653846153846153%;
|
||||
float:left;"> 9 </div><div class="not-covered"
|
||||
style="width:7.6923076923076925%;
|
||||
float:left;"> 8 </div></td>
|
||||
<td class="with-number">92.31 %</td>
|
||||
<td class="with-number">244</td><td class="with-number">29</td><td class="with-number">104</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="the_great_game/merchants/markets.clj.html">the-great-game.merchants.markets</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:96.71361502347418%;
|
||||
float:left;"> 206 </div><div class="not-covered"
|
||||
style="width:3.2863849765258215%;
|
||||
float:left;"> 7 </div></td>
|
||||
<td class="with-number">96.71 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:93.18181818181819%;
|
||||
float:left;"> 41 </div><div class="partial"
|
||||
style="width:4.545454545454546%;
|
||||
float:left;"> 2 </div><div class="not-covered"
|
||||
style="width:2.272727272727273%;
|
||||
float:left;"> 1 </div></td>
|
||||
<td class="with-number">97.73 %</td>
|
||||
<td class="with-number">84</td><td class="with-number">8</td><td class="with-number">44</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="the_great_game/merchants/merchant_utils.clj.html">the-great-game.merchants.merchant-utils</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:46.017699115044245%;
|
||||
float:left;"> 104 </div><div class="not-covered"
|
||||
style="width:53.982300884955755%;
|
||||
float:left;"> 122 </div></td>
|
||||
<td class="with-number">46.02 %</td>
|
||||
style="width:66.12377850162866%;
|
||||
float:left;"> 203 </div><div class="not-covered"
|
||||
style="width:33.876221498371336%;
|
||||
float:left;"> 104 </div></td>
|
||||
<td class="with-number">66.12 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:54.09836065573771%;
|
||||
float:left;"> 33 </div><div class="partial"
|
||||
style="width:4.918032786885246%;
|
||||
float:left;"> 3 </div><div class="not-covered"
|
||||
style="width:40.98360655737705%;
|
||||
float:left;"> 25 </div></td>
|
||||
<td class="with-number">59.02 %</td>
|
||||
<td class="with-number">92</td><td class="with-number">7</td><td class="with-number">61</td>
|
||||
style="width:66.66666666666667%;
|
||||
float:left;"> 48 </div><div class="partial"
|
||||
style="width:5.555555555555555%;
|
||||
float:left;"> 4 </div><div class="not-covered"
|
||||
style="width:27.77777777777778%;
|
||||
float:left;"> 20 </div></td>
|
||||
<td class="with-number">72.22 %</td>
|
||||
<td class="with-number">106</td><td class="with-number">7</td><td class="with-number">72</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="the_great_game/merchants/merchants.clj.html">the-great-game.merchants.merchants</a></td><td class="with-bar"><div class="covered"
|
||||
|
@ -125,6 +138,23 @@
|
|||
<td class="with-number">4.03 %</td>
|
||||
<td class="with-number">173</td><td class="with-number">6</td><td class="with-number">124</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="the_great_game/time.clj.html">the-great-game.time</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:98.10606060606061%;
|
||||
float:left;"> 259 </div><div class="not-covered"
|
||||
style="width:1.893939393939394%;
|
||||
float:left;"> 5 </div></td>
|
||||
<td class="with-number">98.11 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:96.66666666666667%;
|
||||
float:left;"> 58 </div><div class="partial"
|
||||
style="width:1.6666666666666667%;
|
||||
float:left;"> 1 </div><div class="not-covered"
|
||||
style="width:1.6666666666666667%;
|
||||
float:left;"> 1 </div></td>
|
||||
<td class="with-number">98.33 %</td>
|
||||
<td class="with-number">144</td><td class="with-number">21</td><td class="with-number">60</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="the_great_game/utils.clj.html">the-great-game.utils</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:100.0%;
|
||||
|
@ -136,6 +166,23 @@
|
|||
<td class="with-number">100.00 %</td>
|
||||
<td class="with-number">35</td><td class="with-number">3</td><td class="with-number">19</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="the_great_game/world/location.clj.html">the-great-game.world.location</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:88.37209302325581%;
|
||||
float:left;"> 76 </div><div class="not-covered"
|
||||
style="width:11.627906976744185%;
|
||||
float:left;"> 10 </div></td>
|
||||
<td class="with-number">88.37 %</td>
|
||||
<td class="with-bar"><div class="covered"
|
||||
style="width:70.58823529411765%;
|
||||
float:left;"> 12 </div><div class="partial"
|
||||
style="width:17.647058823529413%;
|
||||
float:left;"> 3 </div><div class="not-covered"
|
||||
style="width:11.764705882352942%;
|
||||
float:left;"> 2 </div></td>
|
||||
<td class="with-number">88.24 %</td>
|
||||
<td class="with-number">37</td><td class="with-number">4</td><td class="with-number">17</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="the_great_game/world/routes.clj.html">the-great-game.world.routes</a></td><td class="with-bar"><div class="covered"
|
||||
style="width:99.21875%;
|
||||
|
@ -183,9 +230,9 @@
|
|||
</tr>
|
||||
<tr><td>Totals:</td>
|
||||
<td class="with-bar"></td>
|
||||
<td class="with-number">51.99 %</td>
|
||||
<td class="with-number">66.14 %</td>
|
||||
<td class="with-bar"></td>
|
||||
<td class="with-number">54.62 %</td>
|
||||
<td class="with-number">67.89 %</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
|
|
29
docs/cloverage/the_great_game/agent/agent.clj.html
Normal file
29
docs/cloverage/the_great_game/agent/agent.clj.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" href="../../coverage.css"/> <title> the_great_game/agent/agent.clj </title>
|
||||
</head>
|
||||
<body>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
001 (ns the-great-game.agent.agent
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
002 "Anything in the game world with agency")
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
003
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
004 ;; hierarchy of needs probably gets implemented here
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 ;; I'm probably going to want to defprotocol stuff, to define the hierarchy
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 ;; of things in the gameworld; either that or drop to Java, wich I'd rather not do.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
007
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
|
@ -8,7 +8,7 @@
|
|||
001 (ns the-great-game.gossip.gossip
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
002 "Interchange of news events between agents agents"
|
||||
002 "Interchange of news events between gossip agents"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
003 (:require [the-great-game.utils :refer [deep-merge]]))
|
||||
|
@ -140,7 +140,7 @@
|
|||
045 `new-location`. Many gossips are essentially shadow-records of agents of
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
046 other types, and the movement if the gossip should be controlled by the
|
||||
046 other types, and the movement of the gossip should be controlled by the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
047 run function of the type of the record they shadow. The [[#run]] function
|
||||
|
|
740
docs/cloverage/the_great_game/gossip/news_items.clj.html
Normal file
740
docs/cloverage/the_great_game/gossip/news_items.clj.html
Normal file
|
@ -0,0 +1,740 @@
|
|||
<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 [now]]))
|
||||
</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="3 out of 3 forms covered">
|
||||
139 (:knowledge gossip)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
140
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
141 (defn interesting-location?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
142 "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">
|
||||
143 [gossip item]
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
144 (> (interest-in-location gossip (:location item)) 1))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
145
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
146 (defn interesting-object?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
147 [gossip object]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
148 ;; TODO: Not yet (really) implemented
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
149 true)
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
150
|
||||
</span><br/>
|
||||
<span class="partial" title="1 out of 2 forms covered">
|
||||
151 (defn interesting-topic?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
152 [gossip topic]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
153 ;; TODO: Not yet (really) implemented
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
154 true)
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
155
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
156 (defn interesting-item?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
157 "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">
|
||||
158 [gossip item]
|
||||
</span><br/>
|
||||
<span class="partial" title="13 out of 17 forms covered">
|
||||
159 (or
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
160 (interesting-character? gossip (:actor item))
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
161 (interesting-character? gossip (:other item))
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
162 (interesting-location? gossip (:location item))
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
163 (interesting-object? gossip (:object item))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
164 (interesting-topic? gossip (:verb item))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
165
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
166 (defn infer
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
167 "Infer a new knowledge item from this `item`, following this `rule`"
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
168 [item rule]
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
169 (reduce merge
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
170 item
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
171 (cons
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
172 {:verb (:verb rule)}
|
||||
</span><br/>
|
||||
<span class="covered" title="13 out of 13 forms covered">
|
||||
173 (map (fn [k] {k (apply (k rule) (list item))})
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
174 (remove
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
175 #(= % :verb)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
176 (keys rule))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
177
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
178 (declare learn-news-item)
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
179
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
180 (defn make-all-inferences
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
181 "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">
|
||||
182 `gossip`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
183 [item]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
184 (set
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
185 (reduce
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
186 concat
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
187 (map
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
188 #(:knowledge (learn-news-item {} (infer item %) false))
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
189 (:inferences (news-topics (:verb item)))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
190
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
191 (defn degrade-character
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
192 "Return a character specification like this `character`, but comprising
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
193 only those properties this `gossip` is interested in."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
194 [gossip character]
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
195 ;; TODO: Not yet (really) implemented
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
196 character)
|
||||
</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-location
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
199 "Return a location specification like this `location`, but comprising
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
200 only those elements this `gossip` is interested in. If none, return
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
201 `nil`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
202 [gossip location]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
203 (let [l (if
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
204 (coll? location)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
205 (filter
|
||||
</span><br/>
|
||||
<span class="partial" title="5 out of 7 forms covered">
|
||||
206 #(when (interesting-location? gossip %) %)
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
207 location))]
|
||||
</span><br/>
|
||||
<span class="partial" title="5 out of 7 forms covered">
|
||||
208 (when-not (empty? l) l)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
209
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
210 (defn learn-news-item
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
211 "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">
|
||||
212 it is of interest to them."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
213 ;; TODO: Not yet implemented
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
214 ([gossip item]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
215 (learn-news-item gossip item true))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
216 ([gossip item follow-inferences?]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
217 (if
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
218 (interesting-item? gossip item)
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
219 (let [g (assoc gossip :knowledge
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
220 (cons
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
221 (assoc
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
222 item
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
223 :nth-hand (if
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
224 (number? (:nth-hand item))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
225 (inc (:nth-hand item))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
226 1)
|
||||
</span><br/>
|
||||
<span class="partial" title="8 out of 11 forms covered">
|
||||
227 :date (if (number? (:date item)) (:date item) (now))
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
228 :location (degrade-location gossip (:location item))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
229 ;; ought to degratde the location
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
230 ;; ought to maybe-degrade characters we're not yet interested in
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
231 )
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
232 ;; ought not to add knowledge items we already have, except
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
233 ;; to replace if new item is of increased specificity
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
234 (:knowledge gossip)))]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
235 (if follow-inferences?
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
236 (assoc
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
237 g
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
238 :knowledge
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
239 (concat (:knowledge g) (make-all-inferences item)))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
240 g))
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
241 gossip)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
242
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
243
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
244
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
|
@ -79,22 +79,22 @@
|
|||
<span class="covered" title="3 out of 3 forms covered">
|
||||
025 id (:id c)
|
||||
</span><br/>
|
||||
<span class="partial" title="9 out of 10 forms covered">
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
026 p (or (-> c :prices commodity) 0)
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
027 d (or (-> c :demands commodity) 0)
|
||||
</span><br/>
|
||||
<span class="partial" title="9 out of 10 forms covered">
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
028 st (or (-> c :stock commodity) 0)
|
||||
</span><br/>
|
||||
<span class="partial" title="9 out of 10 forms covered">
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
029 su (or (-> c :supplies commodity) 0)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
030 decrement (min st d)
|
||||
</span><br/>
|
||||
<span class="partial" title="3 out of 6 forms covered">
|
||||
<span class="partial" title="5 out of 6 forms covered">
|
||||
031 increment (cond
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
|
@ -190,46 +190,46 @@
|
|||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
062 ([world]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
063 (reduce
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
064 deep-merge
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
065 world
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
066 (map
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
067 #(update-markets world %)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
068 (keys (:cities world)))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
069 ([world city]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 2 forms covered">
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
070 (reduce
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
071 deep-merge
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
072 {}
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 8 forms covered">
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
073 (map #(update-markets world city %)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
074 (keys (:commodities world)))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
075 ([world city commodity]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 5 forms covered">
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
076 (adjust-quantity-and-price world city commodity)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
|
@ -250,7 +250,7 @@
|
|||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
082 [world]
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
083 (update-markets world))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
|
|
440
docs/cloverage/the_great_game/time.clj.html
Normal file
440
docs/cloverage/the_great_game/time.clj.html
Normal file
|
@ -0,0 +1,440 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" href="../coverage.css"/> <title> the_great_game/time.clj </title>
|
||||
</head>
|
||||
<body>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
001 (ns the-great-game.time
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
002 (:require [clojure.string :as s]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
003
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
004 (def game-start-time
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 "The start time of this run."
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
006 (System/currentTimeMillis))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
007
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
008 (def ^:const game-day-length
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 "The Java clock advances in milliseconds, which is fine.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 But we need game-days to be shorter than real world days.
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 A Witcher 3 game day is 1 hour 36 minutes, or 96 minutes, which is
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
012 presumably researched. Round it up to 100 minutes for easier
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
013 calculation."
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
014 (* 100 ;; minutes per game day
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
015 60 ;; seconds per minute
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
016 1000)) ;; milliseconds per second
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
017
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
018 (defn now
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
019 "For now, we'll use Java timestamp for time; ultimately, we need a
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
020 concept of game-time which allows us to drive day/night cycle, seasons,
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
021 et cetera, but what matters about time is that it is a value which
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
022 increases."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
023 []
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
024 (System/currentTimeMillis))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
025
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
026 (def ^:const canonical-ordering-of-houses
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
027 "The canonical ordering of religious houses."
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
028 [:eye
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
029 :foot
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
030 :nose
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
031 :hand
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
032 :ear
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
033 :mouth
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
034 :stomach
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
035 :furrow
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
036 :plough])
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
037
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
038 (def ^:const days-of-week
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
039 "The eight-day week of the game world. This differs from the canonical
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
040 ordering of houses in that it omits the eye."
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
041 (rest canonical-ordering-of-houses))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
042
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
043 (def ^:const days-in-week
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
044 "This world has an eight day week."
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
045 (count days-of-week))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
046
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
047 (def ^:const seasons-of-year
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
048 "The ordering of seasons in the year is different from the canonical
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
049 ordering of the houses, for reasons of the agricultural cycle."
|
||||
</span><br/>
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
050 [:foot
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
051 :nose
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
052 :hand
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
053 :ear
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
054 :mouth
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
055 :stomach
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
056 :plough
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
057 :furrow
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
058 :eye])
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
059
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
060 (def ^:const seasons-in-year
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
061 "Nine seasons in a year, one for each house (although the order is
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
062 different."
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
063 (count seasons-of-year))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
064
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
065 (def ^:const weeks-of-season
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
066 "To fit nine seasons of eight day weeks into 365 days, each must be of
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
067 five weeks."
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
068 [:first :second :third :fourth :fifth])
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
069
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
070 (def ^:const weeks-in-season
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
071 "To fit nine seasons of eight day weeks into 365 days, each must be of
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
072 five weeks."
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
073 (count weeks-of-season))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
074
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
075 (def ^:const days-in-season
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
076 (* weeks-in-season days-in-week))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
077
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
078 (defn game-time
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
079 "With no arguments, the current game time. If a Java `timestamp` value is
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
080 passed (as a `long`), the game time represented by that value."
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 4 forms covered">
|
||||
081 ([] (game-time (now)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
082 ([timestamp]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
083 (- timestamp game-start-time)))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
084
|
||||
</span><br/>
|
||||
<span class="covered" title="63 out of 63 forms covered">
|
||||
085 (defmacro day-of-year
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
086 "The day of the year represented by this `game-time`, ignoring leap years."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
087 [game-time]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
088 `(mod (long (/ ~game-time game-day-length)) 365))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
089
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
090 (def waiting-day?
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
091 "Does this `game-time` represent a waiting day?"
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
092 (memoize
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
093 ;; we're likely to call this several times in quick succession on the
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
094 ;; same timestamp
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
095 (fn [game-time]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
096 (>=
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
097 (day-of-year game-time)
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
098 (* seasons-in-year weeks-in-season days-in-week)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
099
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
100 (defn day
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
101 "Day of the eight-day week represented by this `game-time`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
102 [game-time]
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
103 (let [day-of-week (mod (day-of-year game-time) days-in-week)]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
104 (if (waiting-day? game-time)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
105 (nth weeks-of-season day-of-week)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
106 (nth days-of-week day-of-week))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
107
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
108 (defn week
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
109 "Week of season represented by this `game-time`."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
110 [game-time]
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
111 (let [day-of-season (mod (day-of-year game-time) days-in-season)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
112 week (/ day-of-season days-in-week)]
|
||||
</span><br/>
|
||||
<span class="partial" title="4 out of 5 forms covered">
|
||||
113 (if (waiting-day? game-time)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
114 :waiting
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
115 (nth weeks-of-season week))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
116
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
117 (defn season
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
118 [game-time]
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
119 (let [season (int (/ (day-of-year game-time) days-in-season))]
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
120 (if (waiting-day? game-time)
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
121 :waiting
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
122 (nth seasons-of-year season))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
123
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
124 (defn date-string
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
125 "Return a correctly formatted date for this `game-time` in the calendar of
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
126 the Great Place."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
127 [game-time]
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
128 (s/join
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
129 " "
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
130 (if
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
131 (waiting-day? game-time)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
132 [(s/capitalize
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
133 (name
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
134 (nth
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
135 weeks-of-season
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
136 (mod (day-of-year game-time) days-in-week))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
137 "waiting day"]
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
138 [(s/capitalize (name (week game-time)))
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
139 (s/capitalize (name (day game-time)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
140 "of the"
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
141 (s/capitalize (name (season game-time)))])))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
142
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
143
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
144
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
119
docs/cloverage/the_great_game/world/location.clj.html
Normal file
119
docs/cloverage/the_great_game/world/location.clj.html
Normal file
|
@ -0,0 +1,119 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" href="../../coverage.css"/> <title> the_great_game/world/location.clj </title>
|
||||
</head>
|
||||
<body>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
001 (ns the-great-game.world.location
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
002 "Functions dealing with location in the world."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
003 (:require [clojure.math.numeric-tower :refer [expt sqrt]]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
004
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 ;; 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">
|
||||
006 ;; 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">
|
||||
007 ;; 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">
|
||||
008 ;; 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">
|
||||
009 ;; So location information will degrade progressively as the item is passed along.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
010
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 ;; 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">
|
||||
012
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
013 (defn get-coords
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
014 "Return the coordinates in the game world of `location`, which may be
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
015 1. A coordinate pair in the format {:x 5 :y 32};
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
016 2. A location, as discussed above;
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
017 3. Any other gameworld object, having a `:location` property whose value
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
018 is one of the above."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
019 [location]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
020 (cond
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
021 (empty? location) nil
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
022 (map? location)
|
||||
</span><br/>
|
||||
<span class="partial" title="1 out of 3 forms covered">
|
||||
023 (cond
|
||||
</span><br/>
|
||||
<span class="partial" title="13 out of 14 forms covered">
|
||||
024 (and (number? (:x location)) (number? (:y location)))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
025 location
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
026 (:location location)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
027 (:location location))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
028 :else
|
||||
</span><br/>
|
||||
<span class="covered" title="8 out of 8 forms covered">
|
||||
029 (get-coords (first (remove keyword? location)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
030
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
031 (defn distance-between
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
032 [location-1 location-2]
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
033 (let [c1 (get-coords location-1)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
034 c2 (get-coords location-2)]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
035 (when
|
||||
</span><br/>
|
||||
<span class="partial" title="5 out of 6 forms covered">
|
||||
036 (and c1 c2)
|
||||
</span><br/>
|
||||
<span class="covered" title="26 out of 26 forms covered">
|
||||
037 (sqrt (+ (expt (- (:x c1) (:x c2)) 2) (expt (- (:y c1) (:y c2)) 2))))))
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
26
docs/codox/naming-of-characters.html
Normal file
26
docs/codox/naming-of-characters.html
Normal file
File diff suppressed because one or more lines are too long
34
docs/codox/orgnic-quests.html
Normal file
34
docs/codox/orgnic-quests.html
Normal file
File diff suppressed because one or more lines are too long
39
docs/codox/sandbox.html
Normal file
39
docs/codox/sandbox.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
3
docs/codox/the-great-game.agent.agent.html
Normal file
3
docs/codox/the-great-game.agent.agent.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
18
docs/codox/the-great-game.gossip.news-items.html
Normal file
18
docs/codox/the-great-game.gossip.news-items.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
3
docs/codox/the-great-game.time.html
Normal file
3
docs/codox/the-great-game.time.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
3
docs/codox/the-great-game.world.location.html
Normal file
3
docs/codox/the-great-game.world.location.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -2,3 +2,6 @@
|
|||
"Anything in the game world with agency")
|
||||
|
||||
;; hierarchy of needs probably gets implemented here
|
||||
;; I'm probably going to want to defprotocol stuff, to define the hierarchy
|
||||
;; of things in the gameworld; either that or drop to Java, wich I'd rather not do.
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
(ns the-great-game.gossip.gossip
|
||||
"Interchange of news events between gossip agents"
|
||||
(:require [the-great-game.utils :refer [deep-merge]]))
|
||||
(:require [the-great-game.utils :refer [deep-merge]]
|
||||
[the-great-game.gossip.news-items :refer [learn-news-item]]))
|
||||
|
||||
;; Note that habitual travellers are all gossip agents; specifically, at this
|
||||
;; stage, that means merchants. When merchants are moved we also need to
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
(ns the-great-game.gossip.news-items
|
||||
"Categories of news events interesting to gossip agents"
|
||||
(:require [clojure.math.numeric-tower :refer [expt sqrt]]))
|
||||
(:require [the-great-game.world.location :refer [distance-between]]
|
||||
[the-great-game.time :refer [now]]))
|
||||
|
||||
;; The ideas here are based on the essay 'The spread of knowledge in a large
|
||||
;; game world', q.v.; they've advanced a little beyond that and will doubtless
|
||||
|
@ -20,14 +21,26 @@
|
|||
their `verbs`. The `keys` associated with each topic are the extra pieces
|
||||
of information required to give context to a gossip item. Generally:
|
||||
|
||||
* `actor` is the id of the character who performed the action;
|
||||
* `other` is the id of the character on whom the action was performed;
|
||||
* `actor` is the id of the character who it is reported performed the
|
||||
action;
|
||||
* `other` is the id of the character on whom it is reported the action
|
||||
was performed;
|
||||
* `location` is the place at which the action was performed;
|
||||
* `object` is an object (or possibly list of objects?) relevant to the action;
|
||||
* `object` is an object (or possibly list of objects?) relevant to the
|
||||
action;
|
||||
* `price` is special to buy/sell, but of significant interest to merchants.
|
||||
|
||||
#### Notes:
|
||||
|
||||
##### Characters:
|
||||
|
||||
*TODO* but note that at most all the receiver can learn about a character
|
||||
from a news item is what the giver knows about that character, degraded by
|
||||
what the receiver finds interesting about them. If we just pass the id here,
|
||||
then either the receiver knows everything in the database about the
|
||||
character, or else the receiver knows nothing at all about the character.
|
||||
Neither is desirable. Further thought needed.
|
||||
|
||||
##### Locations:
|
||||
|
||||
A 'location' value is a list comprising at most the x/y coordinate location
|
||||
|
@ -62,6 +75,7 @@
|
|||
:plot {:verb :plot :keys [:actor :other :object :location]}
|
||||
;; Rapes are interesting.
|
||||
:rape {:verb :rape :keys [:actor :other :location]
|
||||
;; Should you also infer from rape that actor is male and adult?
|
||||
:inferences [{:verb :attack}
|
||||
{:verb :sex}
|
||||
{:verb :sex :actor :other :other :actor}]}
|
||||
|
@ -84,7 +98,9 @@
|
|||
|
||||
(defn interest-in-character
|
||||
"Integer representation of how interesting this `character` is to this
|
||||
`gossip`."
|
||||
`gossip`.
|
||||
*TODO:* this assumes that characters are passed as keywords, but, as
|
||||
documented above, they probably have to be maps, to allow for degradation."
|
||||
[gossip character]
|
||||
(count
|
||||
(concat
|
||||
|
@ -97,99 +113,46 @@
|
|||
[gossip character]
|
||||
(> (interest-in-character gossip character) 0))
|
||||
|
||||
(defn get-coords
|
||||
"Return the coordinates in the game world of `location`, which may be
|
||||
1. A coordinate pair in the format {:x 5 :y 32};
|
||||
2. A location, as discussed above;
|
||||
3. Any other gameworld object, having a `:location` property whose value
|
||||
is one of the above."
|
||||
[location]
|
||||
(cond
|
||||
(empty? location) nil
|
||||
(map? location)
|
||||
(cond
|
||||
(and (number? (:x location)) (number? (:y location)))
|
||||
location
|
||||
(:location location)
|
||||
(:location location))
|
||||
:else
|
||||
(get-coords (first (remove keyword? location)))))
|
||||
|
||||
;; (get-coords {:x 5 :y 7})
|
||||
;; (get-coords [{:x -4 :y 55} :auchencairn :galloway :scotland])
|
||||
|
||||
(defn distance-between
|
||||
[location-1 location-2]
|
||||
(let [c1 (get-coords location-1)
|
||||
c2 (get-coords location-2)]
|
||||
(if
|
||||
(and c1 c2)
|
||||
(sqrt (+ (expt (- (:x c1) (:x c2)) 2) (expt (- (:y c1) (:y c2)) 2))))))
|
||||
|
||||
;; (distance-between {:x 5 :y 5} {:x 2 :y 2})
|
||||
;; (distance-between {:x 5 :y 5} {:x 2 :y 5})
|
||||
;; (distance-between {:x 5 :y 5} [{:x -4 :y 55} :auchencairn :galloway :scotland])
|
||||
;; (distance-between {:x 5 :y 5} [:auchencairn :galloway :scotland])
|
||||
|
||||
(defn interest-in-location
|
||||
"Integer representation of how interesting this `location` is to this
|
||||
`gossip`."
|
||||
[gossip location]
|
||||
(cond
|
||||
(and (map? location) (number? (:x location)) (number? (:y location)))
|
||||
(if-let [home (:home gossip)]
|
||||
(let [d (distance-between location home)
|
||||
i (/ 10000 d) ;; 10000 at metre scale is 10km; interest should
|
||||
;;fall of with distance from home, but possibly on a log scale
|
||||
]
|
||||
(if (> i 1) i 0))
|
||||
0)
|
||||
(coll? location)
|
||||
(reduce
|
||||
+
|
||||
(map
|
||||
#(interest-in-location gossip %)
|
||||
location))
|
||||
(and (map? location) (:x location) (:y location))
|
||||
(if-let [home (:home gossip)]
|
||||
(let [d (distance-between location home)
|
||||
i (/ 10000 d) ;; 10000 at metre scale is 10km; interest should
|
||||
;;fall of with distance from home, but possibly on a log scale
|
||||
]
|
||||
(if (i > 1) i 0)
|
||||
i))
|
||||
:else
|
||||
(count
|
||||
(filter
|
||||
#(some (fn [x] (= x location)) (:location %))
|
||||
(:knowledge gossip)))))
|
||||
|
||||
;; (interest-in-location
|
||||
;; {:knowledge [{:verb :steal
|
||||
;; :actor :albert
|
||||
;; :other :belinda
|
||||
;; :object :foo
|
||||
;; :location [{:x 35 :y 23} :auchencairn :galloway]}]}
|
||||
;; :galloway)
|
||||
|
||||
;; (interest-in-location
|
||||
;; {:knowledge [{:verb :steal
|
||||
;; :actor :albert
|
||||
;; :other :belinda
|
||||
;; :object :foo
|
||||
;; :location [{:x 35 :y 23} :auchencairn :galloway]}]}
|
||||
;; [:galloway :scotland])
|
||||
|
||||
|
||||
;; (interest-in-location
|
||||
;; {:knowledge [{:verb :steal
|
||||
;; :actor :albert
|
||||
;; :other :belinda
|
||||
;; :object :foo
|
||||
;; :location [{:x 35 :y 23} :auchencairn :galloway]}]}
|
||||
;; :dumfries)
|
||||
|
||||
;; (interest-in-location
|
||||
;; {:home {:x 35 :y 23}}
|
||||
;; {:x 35 :y 24})
|
||||
|
||||
(defn interesting-location?
|
||||
"True if the location of this news `item` is interesting to this `gossip`."
|
||||
[gossip item]
|
||||
(> (interest-in-location gossip (:location item)) 1))
|
||||
|
||||
(defn interesting-object?
|
||||
[gossip object]
|
||||
;; TODO: Not yet (really) implemented
|
||||
true)
|
||||
|
||||
(defn interesting-topic?
|
||||
[gossip topic]
|
||||
;; TODO: Not yet (really) implemented
|
||||
true)
|
||||
|
||||
(defn interesting-item?
|
||||
"True if anything about this news `item` is interesting to this `gossip`."
|
||||
[gossip item]
|
||||
|
@ -212,18 +175,44 @@
|
|||
#(= % :verb)
|
||||
(keys rule))))))
|
||||
|
||||
;; (infer {:verb :marry :actor :adam :other :belinda}
|
||||
;; {:verb :marry :actor :other :other :actor})
|
||||
;; (infer {:verb :rape :actor :adam :other :belinda}
|
||||
;; {:verb :attack})
|
||||
;; (infer {:verb :rape :actor :adam :other :belinda}
|
||||
;; {:verb :sex :actor :other :other :actor})
|
||||
(declare learn-news-item)
|
||||
|
||||
(defn make-all-inferences
|
||||
"Return a list of knowledge entries inferred from this news `item` by this
|
||||
`gossip`."
|
||||
[item]
|
||||
(set
|
||||
(reduce
|
||||
concat
|
||||
(map
|
||||
#(:knowledge (learn-news-item {} (infer item %) false))
|
||||
(:inferences (news-topics (:verb item)))))))
|
||||
|
||||
(defn degrade-character
|
||||
"Return a character specification like this `character`, but comprising
|
||||
only those properties this `gossip` is interested in."
|
||||
[gossip character]
|
||||
;; TODO: Not yet (really) implemented
|
||||
character)
|
||||
|
||||
(defn degrade-location
|
||||
"Return a location specification like this `location`, but comprising
|
||||
only those elements this `gossip` is interested in. If none, return
|
||||
`nil`."
|
||||
[gossip location]
|
||||
(let [l (if
|
||||
(coll? location)
|
||||
(filter
|
||||
#(when (interesting-location? gossip %) %)
|
||||
location))]
|
||||
(when-not (empty? l) l)))
|
||||
|
||||
(defn learn-news-item
|
||||
"Return a gossip like this `gossip`, which has learned this news `item` if
|
||||
it is of interest to them."
|
||||
;; TODO: Not yet implemented
|
||||
([gossip item]
|
||||
(learn-news-item gossip item false))
|
||||
(learn-news-item gossip item true))
|
||||
([gossip item follow-inferences?]
|
||||
(if
|
||||
(interesting-item? gossip item)
|
||||
|
@ -235,17 +224,21 @@
|
|||
(number? (:nth-hand item))
|
||||
(inc (:nth-hand item))
|
||||
1)
|
||||
;; ought to degrate the location
|
||||
:date (if (number? (:date item)) (:date item) (now))
|
||||
:location (degrade-location gossip (:location item))
|
||||
;; ought to degratde the location
|
||||
;; ought to maybe-degrade characters we're not yet interested in
|
||||
)
|
||||
;; ought not to add knowledge items we already have, except
|
||||
;; to replace if new item is of increased specificity
|
||||
(:knowledge gossip)))]
|
||||
(if follow-inferences?
|
||||
(reduce
|
||||
merge
|
||||
(assoc
|
||||
g
|
||||
(map
|
||||
#(learn-news-item gossip (infer item %) false)
|
||||
(:inferences (news-topics (:verb item))))))))))
|
||||
:knowledge
|
||||
(concat (:knowledge g) (make-all-inferences item)))
|
||||
g))
|
||||
gossip)))
|
||||
|
||||
|
||||
|
||||
|
|
144
src/the_great_game/time.clj
Normal file
144
src/the_great_game/time.clj
Normal file
|
@ -0,0 +1,144 @@
|
|||
(ns the-great-game.time
|
||||
(:require [clojure.string :as s]))
|
||||
|
||||
(def game-start-time
|
||||
"The start time of this run."
|
||||
(System/currentTimeMillis))
|
||||
|
||||
(def ^:const game-day-length
|
||||
"The Java clock advances in milliseconds, which is fine.
|
||||
But we need game-days to be shorter than real world days.
|
||||
A Witcher 3 game day is 1 hour 36 minutes, or 96 minutes, which is
|
||||
presumably researched. Round it up to 100 minutes for easier
|
||||
calculation."
|
||||
(* 100 ;; minutes per game day
|
||||
60 ;; seconds per minute
|
||||
1000)) ;; milliseconds per second
|
||||
|
||||
(defn now
|
||||
"For now, we'll use Java timestamp for time; ultimately, we need a
|
||||
concept of game-time which allows us to drive day/night cycle, seasons,
|
||||
et cetera, but what matters about time is that it is a value which
|
||||
increases."
|
||||
[]
|
||||
(System/currentTimeMillis))
|
||||
|
||||
(def ^:const canonical-ordering-of-houses
|
||||
"The canonical ordering of religious houses."
|
||||
[:eye
|
||||
:foot
|
||||
:nose
|
||||
:hand
|
||||
:ear
|
||||
:mouth
|
||||
:stomach
|
||||
:furrow
|
||||
:plough])
|
||||
|
||||
(def ^:const days-of-week
|
||||
"The eight-day week of the game world. This differs from the canonical
|
||||
ordering of houses in that it omits the eye."
|
||||
(rest canonical-ordering-of-houses))
|
||||
|
||||
(def ^:const days-in-week
|
||||
"This world has an eight day week."
|
||||
(count days-of-week))
|
||||
|
||||
(def ^:const seasons-of-year
|
||||
"The ordering of seasons in the year is different from the canonical
|
||||
ordering of the houses, for reasons of the agricultural cycle."
|
||||
[:foot
|
||||
:nose
|
||||
:hand
|
||||
:ear
|
||||
:mouth
|
||||
:stomach
|
||||
:plough
|
||||
:furrow
|
||||
:eye])
|
||||
|
||||
(def ^:const seasons-in-year
|
||||
"Nine seasons in a year, one for each house (although the order is
|
||||
different."
|
||||
(count seasons-of-year))
|
||||
|
||||
(def ^:const weeks-of-season
|
||||
"To fit nine seasons of eight day weeks into 365 days, each must be of
|
||||
five weeks."
|
||||
[:first :second :third :fourth :fifth])
|
||||
|
||||
(def ^:const weeks-in-season
|
||||
"To fit nine seasons of eight day weeks into 365 days, each must be of
|
||||
five weeks."
|
||||
(count weeks-of-season))
|
||||
|
||||
(def ^:const days-in-season
|
||||
(* weeks-in-season days-in-week))
|
||||
|
||||
(defn game-time
|
||||
"With no arguments, the current game time. If a Java `timestamp` value is
|
||||
passed (as a `long`), the game time represented by that value."
|
||||
([] (game-time (now)))
|
||||
([timestamp]
|
||||
(- timestamp game-start-time)))
|
||||
|
||||
(defmacro day-of-year
|
||||
"The day of the year represented by this `game-time`, ignoring leap years."
|
||||
[game-time]
|
||||
`(mod (long (/ ~game-time game-day-length)) 365))
|
||||
|
||||
(def waiting-day?
|
||||
"Does this `game-time` represent a waiting day?"
|
||||
(memoize
|
||||
;; we're likely to call this several times in quick succession on the
|
||||
;; same timestamp
|
||||
(fn [game-time]
|
||||
(>=
|
||||
(day-of-year game-time)
|
||||
(* seasons-in-year weeks-in-season days-in-week)))))
|
||||
|
||||
(defn day
|
||||
"Day of the eight-day week represented by this `game-time`."
|
||||
[game-time]
|
||||
(let [day-of-week (mod (day-of-year game-time) days-in-week)]
|
||||
(if (waiting-day? game-time)
|
||||
(nth weeks-of-season day-of-week)
|
||||
(nth days-of-week day-of-week))))
|
||||
|
||||
(defn week
|
||||
"Week of season represented by this `game-time`."
|
||||
[game-time]
|
||||
(let [day-of-season (mod (day-of-year game-time) days-in-season)
|
||||
week (/ day-of-season days-in-week)]
|
||||
(if (waiting-day? game-time)
|
||||
:waiting
|
||||
(nth weeks-of-season week))))
|
||||
|
||||
(defn season
|
||||
[game-time]
|
||||
(let [season (int (/ (day-of-year game-time) days-in-season))]
|
||||
(if (waiting-day? game-time)
|
||||
:waiting
|
||||
(nth seasons-of-year season))))
|
||||
|
||||
(defn date-string
|
||||
"Return a correctly formatted date for this `game-time` in the calendar of
|
||||
the Great Place."
|
||||
[game-time]
|
||||
(s/join
|
||||
" "
|
||||
(if
|
||||
(waiting-day? game-time)
|
||||
[(s/capitalize
|
||||
(name
|
||||
(nth
|
||||
weeks-of-season
|
||||
(mod (day-of-year game-time) days-in-week))))
|
||||
"waiting day"]
|
||||
[(s/capitalize (name (week game-time)))
|
||||
(s/capitalize (name (day game-time)))
|
||||
"of the"
|
||||
(s/capitalize (name (season game-time)))])))
|
||||
|
||||
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
(ns the-great-game.world.location
|
||||
"Functions dealing with location in the world.")
|
||||
"Functions dealing with location in the world."
|
||||
(:require [clojure.math.numeric-tower :refer [expt sqrt]]))
|
||||
|
||||
;; A 'location' value is a list comprising at most the x/y coordinate location
|
||||
;; and the ids of the settlement and region (possibly hierarchically) that contain
|
||||
|
@ -8,3 +9,29 @@
|
|||
;; So location information will degrade progressively as the item is passed along.
|
||||
|
||||
;; It is assumed that the `:home` of a character is a location in this sense.
|
||||
|
||||
(defn get-coords
|
||||
"Return the coordinates in the game world of `location`, which may be
|
||||
1. A coordinate pair in the format {:x 5 :y 32};
|
||||
2. A location, as discussed above;
|
||||
3. Any other gameworld object, having a `:location` property whose value
|
||||
is one of the above."
|
||||
[location]
|
||||
(cond
|
||||
(empty? location) nil
|
||||
(map? location)
|
||||
(cond
|
||||
(and (number? (:x location)) (number? (:y location)))
|
||||
location
|
||||
(:location location)
|
||||
(:location location))
|
||||
:else
|
||||
(get-coords (first (remove keyword? location)))))
|
||||
|
||||
(defn distance-between
|
||||
[location-1 location-2]
|
||||
(let [c1 (get-coords location-1)
|
||||
c2 (get-coords location-2)]
|
||||
(when
|
||||
(and c1 c2)
|
||||
(sqrt (+ (expt (- (:x c1) (:x c2)) 2) (expt (- (:y c1) (:y c2)) 2))))))
|
||||
|
|
4
test/the_great_game/gossip/gossip_test.clj
Normal file
4
test/the_great_game/gossip/gossip_test.clj
Normal file
|
@ -0,0 +1,4 @@
|
|||
(ns the-great-game.gossip.gossip-test
|
||||
(:require [clojure.test :refer :all]
|
||||
[the-great-game.gossip.gossip :refer :all]))
|
||||
|
132
test/the_great_game/gossip/news_items_test.clj
Normal file
132
test/the_great_game/gossip/news_items_test.clj
Normal file
|
@ -0,0 +1,132 @@
|
|||
(ns the-great-game.gossip.news-items-test
|
||||
(:require [clojure.test :refer :all]
|
||||
[the-great-game.gossip.news-items :refer :all]))
|
||||
|
||||
|
||||
(deftest location-test
|
||||
(testing "Interest in locations"
|
||||
(let [expected 1
|
||||
actual (interest-in-location
|
||||
{:knowledge [{:verb :steal
|
||||
:actor :albert
|
||||
:other :belinda
|
||||
:object :foo
|
||||
:location [{:x 35 :y 23} :auchencairn :galloway]}]}
|
||||
:galloway)]
|
||||
(is (= actual expected)))
|
||||
(let [expected 2
|
||||
actual (interest-in-location
|
||||
{:knowledge [{:verb :steal
|
||||
:actor :albert
|
||||
:other :belinda
|
||||
:object :foo
|
||||
:location [{:x 35 :y 23} :auchencairn :galloway :scotland]}]}
|
||||
[:galloway :scotland])]
|
||||
(is (= actual expected)))
|
||||
(let [expected 0
|
||||
actual (interest-in-location
|
||||
{:knowledge [{:verb :steal
|
||||
:actor :albert
|
||||
:other :belinda
|
||||
:object :foo
|
||||
:location [{:x 35 :y 23} :auchencairn :galloway]}]}
|
||||
[:dumfries])]
|
||||
(is (= actual expected)))
|
||||
(let [expected 7071.067811865475
|
||||
actual (interest-in-location
|
||||
{:home [{:x 35 :y 23}]}
|
||||
[{:x 34 :y 24}])]
|
||||
(is (= actual expected)
|
||||
"TODO: 7071.067811865475 is actually a bad answer."))
|
||||
(let [expected 0
|
||||
actual (interest-in-location
|
||||
{:home [{:x 35 :y 23}]}
|
||||
[{:x 34 :y 24000}])]
|
||||
(is (= actual expected)
|
||||
"Too far apart (> 10000)."))
|
||||
(let [expected true
|
||||
actual (interesting-location?
|
||||
{:knowledge [{:verb :steal
|
||||
:actor :albert
|
||||
:other :belinda
|
||||
:object :foo
|
||||
:location [{:x 35 :y 23} :auchencairn :galloway]}]}
|
||||
:galloway)]
|
||||
(is (= actual expected)))
|
||||
(let [expected true
|
||||
actual (interesting-location?
|
||||
{:knowledge [{:verb :steal
|
||||
:actor :albert
|
||||
:other :belinda
|
||||
:object :foo
|
||||
:location [{:x 35 :y 23} :auchencairn :galloway]}]}
|
||||
[:galloway :scotland])]
|
||||
(is (= actual expected)))
|
||||
(let [expected false
|
||||
actual (interesting-location?
|
||||
{:knowledge [{:verb :steal
|
||||
:actor :albert
|
||||
:other :belinda
|
||||
:object :foo
|
||||
:location [{:x 35 :y 23} :auchencairn :galloway]}]}
|
||||
[:dumfries])]
|
||||
(is (= actual expected)))
|
||||
(let [expected true
|
||||
actual (interesting-location?
|
||||
{:home [{:x 35 :y 23}]}
|
||||
[{:x 34 :y 24}])]
|
||||
(is (= actual expected)))
|
||||
(let [expected false
|
||||
actual (interesting-location?
|
||||
{:home [{:x 35 :y 23}]}
|
||||
[{:x 34 :y 240000}])]
|
||||
(is (= actual expected))))
|
||||
(testing "Degrading locations"
|
||||
(let [expected [:galloway]
|
||||
actual (degrade-location
|
||||
{:home [{0 0} :test-home :galloway]}
|
||||
[{-4 55} :auchencairn :galloway])]
|
||||
(is (= actual expected)))
|
||||
(let [expected nil
|
||||
actual (degrade-location
|
||||
{:home [{0 0} :test-home :galloway]}
|
||||
[:froboz])]
|
||||
(is (= actual expected)))))
|
||||
|
||||
(deftest inference-tests
|
||||
(testing "Ability to infer new knowledge from news items: single rule tests"
|
||||
(let [expected {:verb :marry, :actor :belinda, :other :adam}
|
||||
actual (infer {:verb :marry :actor :adam :other :belinda}
|
||||
{:verb :marry :actor :other :other :actor})]
|
||||
(is (= actual expected)))
|
||||
(let [expected {:verb :attack, :actor :adam, :other :belinda}
|
||||
actual (infer {:verb :rape :actor :adam :other :belinda}
|
||||
{:verb :attack})]
|
||||
(is (= actual expected)))
|
||||
(let [expected {:verb :sex, :actor :belinda, :other :adam}
|
||||
actual (infer {:verb :rape :actor :adam :other :belinda}
|
||||
{:verb :sex :actor :other :other :actor})]
|
||||
(is (= actual expected))))
|
||||
(testing "Ability to infer new knowledge from news items: all applicable rules"
|
||||
(let [expected #{{:verb :sex, :actor :belinda, :other :adam, :location nil, :nth-hand 1}
|
||||
{:verb :sex, :actor :adam, :other :belinda, :location nil, :nth-hand 1}
|
||||
{:verb :attack, :actor :adam, :other :belinda, :location nil, :nth-hand 1}}
|
||||
;; dates will not be and cannot be expected to be equal
|
||||
actual (make-all-inferences
|
||||
{:verb :rape :actor :adam :other :belinda :location :test-home})
|
||||
actual' (map #(dissoc % :date) actual)]
|
||||
(is (= actual' expected)))))
|
||||
|
||||
;; (deftest learn-tests
|
||||
;; (testing "Learning from an interesting news item."
|
||||
;; (let [expected {:home [{0 0} :test-home],
|
||||
;; :knowledge ({:verb :rape, :actor :adam, :other :belinda, :location nil, :nth-hand 1}
|
||||
;; {:verb :sex, :actor :belinda, :other :adam, :location nil, :nth-hand 1}
|
||||
;; {:verb :attack, :actor :adam, :other :belinda, :location nil, :nth-hand 1}
|
||||
;; {:verb :sex, :actor :adam, :other :belinda, :location nil, :nth-hand 1})}
|
||||
;; actual (learn-news-item
|
||||
;; {:home [{0, 0} :test-home]
|
||||
;; :knowledge []}
|
||||
;; {:verb :rape :actor :adam :other :belinda :location [:test-home]})
|
||||
;; actual' (assoc actual :knowledge (map #(dissoc % :date) (:knowledge actual)))]
|
||||
;; (is (= actual' expected)))))
|
79
test/the_great_game/time_test.clj
Normal file
79
test/the_great_game/time_test.clj
Normal file
|
@ -0,0 +1,79 @@
|
|||
(ns the-great-game.time-test
|
||||
(:require [clojure.test :refer :all]
|
||||
;; [clojure.core.async :refer [thread <!]]
|
||||
[the-great-game.time :refer :all]))
|
||||
|
||||
(deftest now-tests
|
||||
(testing "Time progresses"
|
||||
(let [t1 (now)]
|
||||
(is (> t1 game-start-time))
|
||||
(Thread/sleep 1000)
|
||||
(is (> (now) t1)))))
|
||||
|
||||
(deftest game-time-tests
|
||||
(testing "Getting game-time"
|
||||
(is (= (game-time (inc game-start-time)) 1))))
|
||||
|
||||
(deftest calendar-tests
|
||||
(testing "In-game calendar functions"
|
||||
(let [expected :foot
|
||||
actual (day 0)]
|
||||
(is (= actual expected)))
|
||||
(let [expected :stomach
|
||||
actual (day (* 5 game-day-length))]
|
||||
(is (= actual expected)))
|
||||
(let [expected :foot
|
||||
actual (day (* days-in-week game-day-length))]
|
||||
(is (= actual expected)))
|
||||
(let [expected :first ;; waiting day
|
||||
actual (day (* 360 game-day-length))]
|
||||
(is (= actual expected)))
|
||||
(let [expected :first
|
||||
actual (week 0)]
|
||||
(is (= actual expected)))
|
||||
(let [expected :second
|
||||
actual (week (* days-in-week game-day-length))]
|
||||
(is (= actual expected)))
|
||||
(let [expected :first
|
||||
actual (week (* days-in-season game-day-length))]
|
||||
(is (= actual expected)))
|
||||
(let [expected :foot
|
||||
actual (season 0)]
|
||||
(is (= actual expected)))
|
||||
(let [expected :mouth
|
||||
actual (season (* 180 game-day-length))]
|
||||
(is (= actual expected)))
|
||||
(let [expected :eye
|
||||
actual (season (* 359 game-day-length))]
|
||||
(is (= actual expected)))
|
||||
(let [expected :waiting
|
||||
actual (season (* 360 game-day-length))]
|
||||
(is (= actual expected)))
|
||||
(let [expected :foot
|
||||
actual (season (* 365 game-day-length))]
|
||||
(is (= actual expected)))))
|
||||
|
||||
(deftest date-string-tests
|
||||
(testing "Date-string formatting"
|
||||
(let [expected "First Foot of the Foot"
|
||||
actual (date-string 0)]
|
||||
(is (= actual expected)))
|
||||
(let [expected "First Foot of the Nose"
|
||||
actual (date-string
|
||||
(* days-in-season game-day-length))]
|
||||
(is (= actual expected)))
|
||||
(let [expected "Third Mouth of the Mouth"
|
||||
actual (date-string (* 180 game-day-length))]
|
||||
(is (= actual expected)))
|
||||
(let [expected "Fifth Plough of the Eye"
|
||||
actual (date-string (* 359 game-day-length))]
|
||||
(is (= actual expected)))
|
||||
(let [expected "First waiting day"
|
||||
actual (date-string (* 360 game-day-length))]
|
||||
(is (= actual expected)))
|
||||
(let [expected "First Foot of the Foot"
|
||||
actual (date-string (* 365 game-day-length))]
|
||||
(is (= actual expected)))))
|
||||
|
||||
|
||||
|
36
test/the_great_game/world/location_test.clj
Normal file
36
test/the_great_game/world/location_test.clj
Normal file
|
@ -0,0 +1,36 @@
|
|||
(ns the-great-game.world.location-test
|
||||
(:require [clojure.test :refer :all]
|
||||
[the-great-game.world.location :refer :all]))
|
||||
|
||||
(deftest get-coords-test
|
||||
(testing "Get coordinates of location"
|
||||
(let [expected {:x 5 :y 7}
|
||||
actual (get-coords {:x 5 :y 7})]
|
||||
(is (= actual expected)))
|
||||
(let [expected {:x -4 :y 55}
|
||||
actual (get-coords [{:x -4 :y 55} :auchencairn :galloway :scotland])]
|
||||
(is (= actual expected)))
|
||||
(let [expected nil
|
||||
actual (get-coords [:auchencairn :galloway :scotland])]
|
||||
(is (= actual expected)))
|
||||
))
|
||||
|
||||
(deftest distance-test
|
||||
(testing "Distance between two locations"
|
||||
(let [expected 4.242640687119285
|
||||
actual (distance-between {:x 5 :y 5} {:x 2 :y 2})]
|
||||
(is (= actual expected)))
|
||||
(let [expected 3
|
||||
actual (distance-between {:x 5 :y 5} {:x 2 :y 5})]
|
||||
(is (= actual expected)))
|
||||
(let [expected 50.80354318352215
|
||||
actual (distance-between
|
||||
{:x 5 :y 5}
|
||||
[{:x -4 :y 55} :auchencairn :galloway :scotland])]
|
||||
(is (= actual expected)))
|
||||
(let [expected nil
|
||||
actual (distance-between
|
||||
{:x 5 :y 5}
|
||||
[:auchencairn :galloway :scotland])]
|
||||
(is (= actual expected)))
|
||||
))
|
Loading…
Reference in a new issue