Merge branch 'master' of github.com:simon-brooke/the-great-game

This commit is contained in:
Simon Brooke 2019-07-05 18:56:58 +01:00
commit 58589d2da4
64 changed files with 3967 additions and 517 deletions

5
.gitignore vendored
View file

@ -2,13 +2,18 @@ pom.xml
pom.xml.asc
*.jar
*.class
*.log
[0-9a-f]*-init.clj
/lib/
/classes/
/target/
/checkouts/
/.clj-kondo/
.eastwood
.lein-deps-sum
.lein-repl-history
.lein-plugins/
.lein-failures
.nrepl-port
.cpcache/
*~

BIN
doc/Population.ods Normal file

Binary file not shown.

49
doc/economy.md Normal file
View file

@ -0,0 +1,49 @@
# Game world economy
Broadly this essay extends ideas presented in [Populating a game world](https://blog.journeyman.cc/2013/07/populating-game-world.html), q.v.
## Primary producers
### Herdsfolk
Herdsfolk are nomadic; it's reasonable to think they'll bring their herds to market, rather than selling it lots of tiny markets. So in the spring, shepherds will visit specific towns at the edge of open land, to hold a shearing festival/carnevale; and that both shepherds and cattle herders will visit towns on the edge of open land to sell fatstock in the autumn.
### Miners
Miners mine. They're settled, but they're settled usually in specialist settlements at the location where the ore body is accessible, usually in mountenous territory. They'll consume a lot of food, so there will be a local market for foodstuffs encouraging local farming. Different mines obviously mine different ores, but, for example, lead and silver are frequently found together.
### Foresters
Foresters are more or less settled at the edge of forests, at locations from which timber can be moved by navigable water; again in specialist settlements. In addition to timber, foresters hunt and produce both meat and furs, so have less need for other food producers locally.
### Farmers
Farmers are settled. Farmers occupy standard runrig plots, but because they don't employ journeymen or apprentices, and don't have workshops, the plots are mostly open with little building. Most farmers are 'mixed farmers', producing cereals, meat, eggs and milk. Some will be more specialist. Farm produce, taken broadly to include orchardsfolk, include:
* meat
* milk and milk products
* hides
* eggs
* cereals
* root vegetables, onions, etc
* peas and beans
* leaf vegetables
* fruits
* fibres: linen, hemp and silk (from silk-moths in mulberry orchards)
* possibly other stuff I've forgotten.
Farmers are all basically subsistence farmers, farming first to feed their own household and selling only surplus in the market.
## Crafts
Crafts generally process primary goods into secondary goods - whether intermediate stages or final consumer items. Some elite 'crafts' deal with abstract primary goods like law and knowledge, and they may be seen as somewhat separate.
A master craftsperson occupies a standard runrig plot, much like a farmer's plot. Like a farmer, a poor master crafter household will cultivate part of the plot to produce food for the house - at least grow vegetables and keep hens. However, as the crafter takes on apprentices and journeymen - and gets richer - more buildings will be required as accommodation, workshop space and materials stores.
Generally, primary goods aren't transported over land - because overland transport is expensive, by the time they've been transported they're no longer low cost goods. So often the craftspeople who process primary produce into at least commodity intermediate forms will live close to the source of the primary goods.
So, for example, the town(s) where the shepherds hold their shearing fairs will tend to have a lot of weavers. While around mines there will be smelters producing ingots and bar stock to be marketed to smiths all over the place, there will also be smiths close to the mines producing commodity tools and weapons.
See the table in Populating a game world.

View file

@ -0,0 +1,9 @@
# Modelling trading cost and risk
In a dynamic pre-firearms world with many small states and contested regions, trade is not going to be straightforward. Not only will different routes have different physical characteristics - more or less mountainous, more or fewer unbridged river crossings - they will also have different political characteristics: more of less taxed, more or less effectively policed.
Raids by outlaws are expected to be part of the game economy. News of raids are the sort of things which may propagate through the [[gossip]] system. So are changes in taxation regime. Obviously, knowledge items can affect merchants' trading strategy; in existing prototype code, individual merchants already each keep their own cache of known historical prices, and exchange historical price data with one another; and use this price data to select trades to make.
So: to what extent is it worth modelling the spread of knowledge of trade cost and risk?
Obviously the more we model, the more compute power modelling consumes. If the core objective is a Role Playing Games as currently understood, then there is no need to model very complex trade risk assessment behaviour.

66
doc/sandbox.md Normal file
View file

@ -0,0 +1,66 @@
# Sandbox
Up to now I've been thinking of the Great Game as essentially an RPG with some sandbox-like elements; but I think it may be better to think of it as a sandbox game with some RPG like elements.
Why?
The core of the game is a world in which non-player characters have enough individual knowledge of the world and their immediate surroundings that they can sensibly answer questions like
* Where is the nearest craftsman of this craft?
* What price can I expect to get for this item in the local market?
* What news have you heard recently?
* Where does this person from your village live?
and where there's a sufficiently sophisticated and robust economy simulation that buying goods in one market and selling them in another is viable.
The original BBC Micro space trading game Elite had very little more in terms of game mechanics than a sandbox with a means to navigate it and an economy simulation, which wasn't even nearly as sophisticated as the one I have working now. Yet that combination resulted in engaging game play.
## Main sandbox roles
The idea of a sandbox is that the player character should be able to do pretty much anything they like within the mechanics of the game. From that, it seems to me reasonable that the player ought to be able to do more or less everything a non-player character can do. But creating the game mechanics to make each additional task doable takes time and investment, so there's a need to prioritise.
So, as Elite did, I propose to make the first available sandbox roles
### Merchant
Someone who travels from city to city, buying goods cheap in one and selling them for more in another; and
### Outlaw
Someone who intercepts and steals from merchants (and may also attack outlying farms and villages)
## Second tier playable roles
The next tier of playable roles rotates around issues arising from the mercantile ecosystem.
### Aristocracy
Aristocrats are basically settled outlaws who seek to establish a monopoly on extracting taxes from inhabitants and travellers in a particular region by driving out all other outlaws. Within the comain of an aristocrat, you have to pay tax but you're reasonably safe from being attacked by other outlaws and losing everything. Aristocrats may also maintain and improve roads and bridges and do other things to boost the economy of their territory, may expant into adjoining territory with no current aristocratic control, and may wage war on other aristocrats.
An outlaw ought to be able to become an aristocrat, by dominating an ungoverned area or by defeating an existing aristocrat.
### Soldiery
Soldiers, like aristocrats, are basically on the same spectrum as outlaws. Outlaws may hire themselves out to merchants as caravan guards, or to aristocrats as soldiers. Soldiers or guards, falling on bad times, may revert to outlawry.
## Routine, Discretion and Playability
There's a term that's used in criticism of many computer games which is worth thinking about hard here: that term is 'farming'. 'Farming', in this sense, is doing something repetitive and dull to earn credits in a game. Generally this is not fun. What makes roles in a game-world fun is having individual discretion - the ability to choose between actions and strategies - and a lack of routine.
Most craft skills - especially in the learning phase - are not like this, and crafts which are sophisticated enough to be actually engaging are very hard to model in a game. Learning a craft is essentially, inherently, repetitive and dull, and if you take that repetition out of it you probably don't have enough left to yield the feeling of mastery which would reward success; so it doesn't seem to me that making craft roles playable should be a priority.
## Cruise control
One of the most enjoyable aspects of The Witcher 3 - still my go-to game for ideas I want to improve on - is simply travelling through the world. Although fast travel is possible I find I rarely use it, and a journey which takes fifteen minutes of real world wall clock time can be enjoyable in and of itself. This is, of course, a credit to the beautiful way the world is realised.
But nevertheless, in The Witcher 3, a decision was made to pack incident fairly densely - because players would find just travelling boring. This leads to a situation where peaceful villages exist two minutes travel from dangerous monsters or bandit camps, and the suspension of disbelief gets a little strained. Building a world big enough that a market simulation is believable means that for the individual, the travel time to a market where a particular desired good is likely to be cheaper becomes costly in itself. Otherwise, there's no arbitrage between markets and no ecological niche for a merchant to fill. The journey time from market to market has to be several in-game days.
An in-game day doesn't have to be as long as a wall clock day, and, indeed, typically isn't. But nevertheless, doing several game days of incident-free travel, even in beautiful scenery, is not going to be engaging - which implies a fast-travel mechanic.
I don't like fast travel, I find it a too-obvious breaking of immersion. Also, of course, one of the interesting things about a game in a merchant/outlaw ecosystem is the risk of interception on a journey. The Dragon Age series handled interrupted travel in 'fast travel' by randomly interacting the loading screen you get when moving from location to location in Dragon Age's patchwork worlds by dumping you into a tiny arena with enemies. That's really, really bad - there's no other way to say this. Everything about it shouts artifice.
So I'm thinking of a different mechanism: one I'm calling cruise control.
You set out on a task which will take a long time - such as a journey, but also such as any routine task. You're shown either a 'fast forward' of your character carrying out this task, or a series of cinematic 'shots along the way'. This depends, of course, on their being continuous renderable landscape between your departure and your destination, but there will be. This fast-forward proceeds at a substantially higher time gearing than normal game time - ten times as fast perhaps; we need it to, because as well as doing backgound scenery loading to move from one location to another, we're also simulating lots of non-player agents actions in parts of the world where the player currently isn't. So a 'jump cut' from one location to another isn't going to work anyway.
The player can interrupt 'fast forward' at any time. But also, the game itself may bring you out of fast forward when it anticipates that there may be action which requires decision - for example, when there are outlaws in the vicinity. And it will do this **before** the player's party is under immediate attack - the player will have time to take stock of the situation and prepare appropriately. Finally, this will take place in the full open world; the player will have the option to choose *not* to enter the narrow defile, for example, to ask local people (if there are any) for any news of outlaw activity, or, if they are available, to send forward scouts.

45
doc/sexual-dimorphism.md Normal file
View file

@ -0,0 +1,45 @@
# Sexual dimorphism
This essay is going to upset a lot of people, so let's start with a statement of what it is about: it is an attempt to describe the systematically different behaviours of men and women, in sufficient detail that this can be represented by agents in a game world. It's trying to allow as broad as possible a range of cultures to be represented, so when I'm talking about what I consider to be behaviours of particular cultures, I'll say that.
Of course, I'm writing this from the view point of an old white male. It's not possible to write about these things from a totally neutral viewpoint, and every one of us will have prejudices.
OK? Let's start.
When a man and a woman have sex, there's a non-zero chance that the woman will get pregnant. There's a zero chance that the male will get pregnant.
A woman can typically give birth to of the order of twelve children in the course of her life, and each childbirth involves a non-zero risk of death. If modelling the sort of bronze-age-to-late-medieval cultures I'm generally considering, there are no available reliable methods of contraception, although their may be, for example, known spermicidal or abortifacient spells or potions. If it's abortifacient, that's pretty unpleasant for the woman, too.
Children, especially when young, are very vulnerable and need protection. Children with good protection are much more likely to survive to adulthood. Raising children involves a fair amount of work.
For all sorts of reasons, some of which are clearly cultural but others of which are fundamental, it's much easier for men to walk away from responsibility for their children than it is for women. For example, considering a pre-modern world, women would always know for certain which children were theirs, and men would not.
For a woman, consequently, the best breeding strategy is to have sex only with men who will be 'good fathers', where there are three essential parameters to "good fathers":
1. Desirable genetic traits;
2. Preparedness to stick around and share the work;
3. Ability to provide and protect.
The essential trade-off in the traditional western marriage is that the man gets to have sex, and the woman gets to have protection for her progeny.
Another significant point is that women's ability to bear children ceases at a much younger age than men's ability to father them.
## Why have sex at all?
If a character has 'having children' - the **Ancestor** aspiration, in my typology - as their key aim, then they will want to have sex. But to have children in this sense is to have acknowledged children, so while a male character may be motivated to have multiple female partners, he will never the less have some degree of long term committment to them, and will want both to feel confident that the children are his and to be recognised by their father.
From the point of view of seeking to become an Ancestor, there is little benefit to the woman in having multiple partners, except in very harsh environments. It will be easier to give one partner confidence that all your children are his, and while a man can increase his number of potential progeny by having multiple wives, mistresses or other classes of long-term female sexual partners, a woman cannot.
## Why have children?
In modern Scotland, I have met a lot of women with a strong drive to have children for the sake of having children, where the best explanation they could give is that it's instinctual; it may be so. But beyond that, in many cultures children provide their (acknowledged) parents with care and security in their old age, may tend their graves and perform belief-related services after they die, and carry on their name and their stories into the future.
Not everyone wants to have children; in thinking about the driving aspirations of game characters, I view having children one of six potential key aspirations.
## Why else have sex?
Sex, done right, is an extremely pleasant pastime. Sex can also be used to create and maintain bonds of committment, to demonstrate social status, to defuse tense situations, and transactionally in many ways, both formal and informal.
For women, sex with other women carries with it no risk of pregnancy, so can be enjoyed or used for any of these purposes in very much the same way as it can by men; in other words, particularly for women, homosexual sex can be more lighthearted and carefree than heterosexual sex. To what extend our notions of homosexuality and heterosexuality are cultural I simply don't know. But because no children will result, a woman can afford to be more promiscuous with other women than she can with men.
## How does this impact on

View file

@ -1 +0,0 @@
theme: jekyll-theme-slate

View file

@ -0,0 +1,40 @@
.covered {
font-family: 'Bitstream Vera Sans Mono', 'Courier', monospace;
background-color: #558B55;
}
.not-covered {
font-family: 'Bitstream Vera Sans Mono', 'Courier', monospace;
background-color: red;
}
.partial {
font-family: 'Bitstream Vera Sans Mono', 'Courier', monospace;
background-color: orange;
}
.not-tracked {
font-family: 'Bitstream Vera Sans Mono', 'Courier', monospace;
}
.blank {
font-family: 'Bitstream Vera Sans Mono', 'Courier', monospace;
}
td {
padding-right: 10px;
}
td.with-bar {
width: 250px;
text-align: center;
}
td.with-number {
text-align: right;
}
td.ns-name {
min-width: 150px;
padding-right: 25px;
}

192
docs/cloverage/index.html Normal file
View file

@ -0,0 +1,192 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="./coverage.css"/>
<title>Coverage Summary</title>
</head>
<body>
<table>
<thead><tr>
<td class="ns-name"> Namespace </td>
<td class="with-bar"> Forms </td>
<td class="with-number">Forms %</td>
<td class="with-bar"> Lines </td>
<td class="with-number">Lines %</td>
<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%;
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>
</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"
style="width:4.545454545454546%;
float:left;"> 5 </div><div class="not-covered"
style="width:95.45454545454545%;
float:left;"> 105 </div></td>
<td class="with-number">4.55 %</td>
<td class="with-bar"><div class="covered"
style="width:12.820512820512821%;
float:left;"> 5 </div><div class="not-covered"
style="width:87.17948717948718%;
float:left;"> 34 </div></td>
<td class="with-number">12.82 %</td>
<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 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>
<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>
<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>
</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"
style="width:2.816901408450704%;
float:left;"> 2 </div><div class="not-covered"
style="width:97.1830985915493%;
float:left;"> 69 </div></td>
<td class="with-number">2.82 %</td>
<td class="with-bar"><div class="covered"
style="width:12.5%;
float:left;"> 2 </div><div class="not-covered"
style="width:87.5%;
float:left;"> 14 </div></td>
<td class="with-number">12.50 %</td>
<td class="with-number">28</td><td class="with-number">3</td><td class="with-number">16</td>
</tr>
<tr>
<td><a href="the_great_game/merchants/planning.clj.html">the-great-game.merchants.planning</a></td><td class="with-bar"><div class="covered"
style="width:88.88888888888889%;
float:left;"> 264 </div><div class="not-covered"
style="width:11.11111111111111%;
float:left;"> 33 </div></td>
<td class="with-number">88.89 %</td>
<td class="with-bar"><div class="covered"
style="width:83.52941176470588%;
float:left;"> 71 </div><div class="partial"
style="width:4.705882352941177%;
float:left;"> 4 </div><div class="not-covered"
style="width:11.764705882352942%;
float:left;"> 10 </div></td>
<td class="with-number">88.24 %</td>
<td class="with-number">159</td><td class="with-number">11</td><td class="with-number">85</td>
</tr>
<tr>
<td><a href="the_great_game/merchants/strategies/simple.clj.html">the-great-game.merchants.strategies.simple</a></td><td class="with-bar"><div class="covered"
style="width:0.8103727714748784%;
float:left;"> 5 </div><div class="not-covered"
style="width:99.18962722852513%;
float:left;"> 612 </div></td>
<td class="with-number">0.81 %</td>
<td class="with-bar"><div class="covered"
style="width:4.032258064516129%;
float:left;"> 5 </div><div class="not-covered"
style="width:95.96774193548387%;
float:left;"> 119 </div></td>
<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/utils.clj.html">the-great-game.utils</a></td><td class="with-bar"><div class="covered"
style="width:100.0%;
float:left;"> 72 </div></td>
<td class="with-number">100.00 %</td>
<td class="with-bar"><div class="covered"
style="width:100.0%;
float:left;"> 19 </div></td>
<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/routes.clj.html">the-great-game.world.routes</a></td><td class="with-bar"><div class="covered"
style="width:99.21875%;
float:left;"> 127 </div><div class="not-covered"
style="width:0.78125%;
float:left;"> 1 </div></td>
<td class="with-number">99.22 %</td>
<td class="with-bar"><div class="covered"
style="width:97.61904761904762%;
float:left;"> 41 </div><div class="partial"
style="width:2.380952380952381%;
float:left;"> 1 </div></td>
<td class="with-number">100.00 %</td>
<td class="with-number">55</td><td class="with-number">2</td><td class="with-number">42</td>
</tr>
<tr>
<td><a href="the_great_game/world/run.clj.html">the-great-game.world.run</a></td><td class="with-bar"><div class="covered"
style="width:4.918032786885246%;
float:left;"> 3 </div><div class="not-covered"
style="width:95.08196721311475%;
float:left;"> 58 </div></td>
<td class="with-number">4.92 %</td>
<td class="with-bar"><div class="covered"
style="width:15.0%;
float:left;"> 3 </div><div class="not-covered"
style="width:85.0%;
float:left;"> 17 </div></td>
<td class="with-number">15.00 %</td>
<td class="with-number">39</td><td class="with-number">2</td><td class="with-number">20</td>
</tr>
<tr>
<td><a href="the_great_game/world/world.clj.html">the-great-game.world.world</a></td><td class="with-bar"><div class="covered"
style="width:95.89041095890411%;
float:left;"> 420 </div><div class="not-covered"
style="width:4.109589041095891%;
float:left;"> 18 </div></td>
<td class="with-number">95.89 %</td>
<td class="with-bar"><div class="covered"
style="width:97.01492537313433%;
float:left;"> 65 </div><div class="not-covered"
style="width:2.985074626865672%;
float:left;"> 2 </div></td>
<td class="with-number">97.01 %</td>
<td class="with-number">192</td><td class="with-number">4</td><td class="with-number">67</td>
</tr>
<tr><td>Totals:</td>
<td class="with-bar"></td>
<td class="with-number">51.99 %</td>
<td class="with-bar"></td>
<td class="with-number">54.62 %</td>
</tr>
</table>
</body>
</html>

View file

@ -0,0 +1,26 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../coverage.css"/> <title> the_great_game/core.clj </title>
</head>
<body>
<span class="covered" title="1 out of 1 forms covered">
001&nbsp;&nbsp;(ns&nbsp;the-great-game.core)
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
002&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
003&nbsp;&nbsp;(defn&nbsp;foo
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
004&nbsp;&nbsp;&nbsp;&nbsp;&quot;I&nbsp;don&#x27;t&nbsp;do&nbsp;a&nbsp;whole&nbsp;lot.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
005&nbsp;&nbsp;&nbsp;&nbsp;[x]
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
006&nbsp;&nbsp;&nbsp;&nbsp;(println&nbsp;x&nbsp;&quot;Hello,&nbsp;World!&quot;))
</span><br/>
</body>
</html>

View file

@ -0,0 +1,203 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../../coverage.css"/> <title> the_great_game/gossip/gossip.clj </title>
</head>
<body>
<span class="covered" title="1 out of 1 forms covered">
001&nbsp;&nbsp;(ns&nbsp;the-great-game.gossip.gossip
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
002&nbsp;&nbsp;&nbsp;&nbsp;&quot;Interchange&nbsp;of&nbsp;news&nbsp;events&nbsp;between&nbsp;agents&nbsp;agents&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
003&nbsp;&nbsp;&nbsp;&nbsp;(:require&nbsp;[the-great-game.utils&nbsp;:refer&nbsp;[deep-merge]]))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
004&nbsp;&nbsp;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
005&nbsp;&nbsp;;;&nbsp;Note&nbsp;that&nbsp;habitual&nbsp;travellers&nbsp;are&nbsp;all&nbsp;gossip&nbsp;agents;&nbsp;specifically,&nbsp;at&nbsp;this
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
006&nbsp;&nbsp;;;&nbsp;stage,&nbsp;that&nbsp;means&nbsp;merchants.&nbsp;When&nbsp;merchants&nbsp;are&nbsp;moved&nbsp;we&nbsp;also&nbsp;need&nbsp;to
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
007&nbsp;&nbsp;;;&nbsp;update&nbsp;the&nbsp;location&nbsp;of&nbsp;the&nbsp;gossip&nbsp;with&nbsp;the&nbsp;same&nbsp;key.
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
008&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
009&nbsp;&nbsp;(defn&nbsp;dialogue
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
010&nbsp;&nbsp;&nbsp;&nbsp;&quot;Dialogue&nbsp;between&nbsp;an&nbsp;`enquirer`&nbsp;and&nbsp;an&nbsp;`agent`&nbsp;in&nbsp;this&nbsp;`world`;&nbsp;returns&nbsp;a
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
011&nbsp;&nbsp;&nbsp;&nbsp;map&nbsp;identical&nbsp;to&nbsp;`enquirer`&nbsp;except&nbsp;that&nbsp;its&nbsp;`:gossip`&nbsp;collection&nbsp;may&nbsp;have
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
012&nbsp;&nbsp;&nbsp;&nbsp;additional&nbsp;entries.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
013&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;TODO:&nbsp;not&nbsp;yet&nbsp;written,&nbsp;this&nbsp;is&nbsp;a&nbsp;stub.
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
014&nbsp;&nbsp;&nbsp;&nbsp;[enquirer&nbsp;respondent&nbsp;world]
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
015&nbsp;&nbsp;&nbsp;&nbsp;enquirer)
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
016&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
017&nbsp;&nbsp;(defn&nbsp;gather-news
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
018&nbsp;&nbsp;&nbsp;&nbsp;([world]
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
019&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(reduce
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
020&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;deep-merge
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
021&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;world
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
022&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
023&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#(gather-news&nbsp;world&nbsp;%)
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
024&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(keys&nbsp;(:gossips&nbsp;world)))))
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
025&nbsp;&nbsp;&nbsp;&nbsp;([world&nbsp;gossip]
</span><br/>
<span class="not-covered" title="0 out of 7 forms covered">
026&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[g&nbsp;(cond&nbsp;(keyword?&nbsp;gossip)
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
027&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(-&gt;&nbsp;world&nbsp;:gossips&nbsp;gossip)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
028&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map?&nbsp;gossip)
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
029&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gossip)]
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
030&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:gossips
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
031&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{(:id&nbsp;g)
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
032&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(reduce
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
033&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;deep-merge
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
034&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{}
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
035&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
036&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#(dialogue&nbsp;g&nbsp;%&nbsp;world)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
037&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(remove
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
038&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#(&nbsp;=&nbsp;g&nbsp;%)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
039&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(filter
</span><br/>
<span class="not-covered" title="0 out of 8 forms covered">
040&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#(=&nbsp;(:location&nbsp;%)&nbsp;(:location&nbsp;g))
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
041&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(vals&nbsp;(:gossips&nbsp;world))))))}})))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
042&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
043&nbsp;&nbsp;(defn&nbsp;move-gossip
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
044&nbsp;&nbsp;&nbsp;&nbsp;&quot;Return&nbsp;a&nbsp;world&nbsp;like&nbsp;this&nbsp;`world`&nbsp;but&nbsp;with&nbsp;this&nbsp;`gossip`&nbsp;moved&nbsp;to&nbsp;this
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
045&nbsp;&nbsp;&nbsp;&nbsp;`new-location`.&nbsp;Many&nbsp;gossips&nbsp;are&nbsp;essentially&nbsp;shadow-records&nbsp;of&nbsp;agents&nbsp;of
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
046&nbsp;&nbsp;&nbsp;&nbsp;other&nbsp;types,&nbsp;and&nbsp;the&nbsp;movement&nbsp;if&nbsp;the&nbsp;gossip&nbsp;should&nbsp;be&nbsp;controlled&nbsp;by&nbsp;the
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
047&nbsp;&nbsp;&nbsp;&nbsp;run&nbsp;function&nbsp;of&nbsp;the&nbsp;type&nbsp;of&nbsp;the&nbsp;record&nbsp;they&nbsp;shadow.&nbsp;The&nbsp;[[#run]]&nbsp;function
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
048&nbsp;&nbsp;&nbsp;&nbsp;below&nbsp;does&nbsp;NOT&nbsp;call&nbsp;this&nbsp;function.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
049&nbsp;&nbsp;&nbsp;&nbsp;[gossip&nbsp;world&nbsp;new-location]
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
050&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[id&nbsp;(cond
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
051&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map?&nbsp;gossip)
</span><br/>
<span class="not-covered" title="0 out of 7 forms covered">
052&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(-&gt;&nbsp;world&nbsp;:gossips&nbsp;gossip&nbsp;:id)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
053&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(keyword?&nbsp;gossip)
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
054&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gossip)]
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
055&nbsp;&nbsp;&nbsp;&nbsp;(deep-merge
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
056&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;world
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
057&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:gossips
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
058&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{id
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
059&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:location&nbsp;new-location}}})))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
060&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
061&nbsp;&nbsp;(defn&nbsp;run
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
062&nbsp;&nbsp;&nbsp;&nbsp;&quot;Return&nbsp;a&nbsp;world&nbsp;like&nbsp;this&nbsp;`world`,&nbsp;with&nbsp;news&nbsp;items&nbsp;exchanged&nbsp;between&nbsp;gossip
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
063&nbsp;&nbsp;&nbsp;&nbsp;agents.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
064&nbsp;&nbsp;&nbsp;&nbsp;[world]
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
065&nbsp;&nbsp;&nbsp;&nbsp;(gather-news&nbsp;world))
</span><br/>
</body>
</html>

View file

@ -0,0 +1,260 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../../coverage.css"/> <title> the_great_game/merchants/markets.clj </title>
</head>
<body>
<span class="covered" title="1 out of 1 forms covered">
001&nbsp;&nbsp;(ns&nbsp;the-great-game.merchants.markets
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
002&nbsp;&nbsp;&nbsp;&nbsp;&quot;Adjusting&nbsp;quantities&nbsp;and&nbsp;prices&nbsp;in&nbsp;markets.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
003&nbsp;&nbsp;&nbsp;&nbsp;(:require&nbsp;[taoensso.timbre&nbsp;:as&nbsp;l&nbsp;:refer&nbsp;[info&nbsp;error]]
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
004&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[the-great-game.utils&nbsp;:refer&nbsp;[deep-merge]]))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
005&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
006&nbsp;&nbsp;(defn&nbsp;new-price
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
007&nbsp;&nbsp;&nbsp;&nbsp;&quot;If&nbsp;`stock`&nbsp;is&nbsp;greater&nbsp;than&nbsp;the&nbsp;maximum&nbsp;of&nbsp;`supply`&nbsp;and&nbsp;`demand`,&nbsp;then
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
008&nbsp;&nbsp;&nbsp;&nbsp;there&nbsp;is&nbsp;surplus&nbsp;and&nbsp;`old`&nbsp;price&nbsp;is&nbsp;too&nbsp;high,&nbsp;so&nbsp;shold&nbsp;be&nbsp;reduced.&nbsp;If
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
009&nbsp;&nbsp;&nbsp;&nbsp;lower,&nbsp;then&nbsp;it&nbsp;is&nbsp;too&nbsp;low&nbsp;and&nbsp;should&nbsp;be&nbsp;increased.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
010&nbsp;&nbsp;&nbsp;&nbsp;[old&nbsp;stock&nbsp;supply&nbsp;demand]
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
011&nbsp;&nbsp;&nbsp;&nbsp;(let
</span><br/>
<span class="covered" title="13 out of 13 forms covered">
012&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[delta&nbsp;(dec&#x27;&nbsp;(&#x2F;&nbsp;(max&nbsp;supply&nbsp;demand&nbsp;1)&nbsp;(max&nbsp;stock&nbsp;1)))
</span><br/>
<span class="covered" title="4 out of 4 forms covered">
013&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scaled&nbsp;(&#x2F;&nbsp;delta&nbsp;100)]
</span><br/>
<span class="covered" title="4 out of 4 forms covered">
014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(+&nbsp;old&nbsp;scaled)))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
015&nbsp;&nbsp;
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
016&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
017&nbsp;&nbsp;(defn&nbsp;adjust-quantity-and-price
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
018&nbsp;&nbsp;&nbsp;&nbsp;&quot;Adjust&nbsp;the&nbsp;quantity&nbsp;of&nbsp;this&nbsp;`commodity`&nbsp;currently&nbsp;in&nbsp;stock&nbsp;in&nbsp;this&nbsp;`city`
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
019&nbsp;&nbsp;&nbsp;&nbsp;of&nbsp;this&nbsp;`world`.&nbsp;Return&nbsp;a&nbsp;fragmentary&nbsp;world&nbsp;which&nbsp;can&nbsp;be&nbsp;deep-merged&nbsp;into
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
020&nbsp;&nbsp;&nbsp;&nbsp;this&nbsp;world.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
021&nbsp;&nbsp;&nbsp;&nbsp;[world&nbsp;city&nbsp;commodity]
</span><br/>
<span class="partial" title="2 out of 4 forms covered">
022&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[c&nbsp;(cond
</span><br/>
<span class="covered" title="8 out of 8 forms covered">
023&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(keyword?&nbsp;city)&nbsp;(-&gt;&nbsp;world&nbsp;:cities&nbsp;city)
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
024&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map?&nbsp;city)&nbsp;city)
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
025&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id&nbsp;(:id&nbsp;c)
</span><br/>
<span class="partial" title="9 out of 10 forms covered">
026&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;(or&nbsp;(-&gt;&nbsp;c&nbsp;:prices&nbsp;commodity)&nbsp;0)
</span><br/>
<span class="covered" title="10 out of 10 forms covered">
027&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d&nbsp;(or&nbsp;(-&gt;&nbsp;c&nbsp;:demands&nbsp;commodity)&nbsp;0)
</span><br/>
<span class="partial" title="9 out of 10 forms covered">
028&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;st&nbsp;(or&nbsp;(-&gt;&nbsp;c&nbsp;:stock&nbsp;commodity)&nbsp;0)
</span><br/>
<span class="partial" title="9 out of 10 forms covered">
029&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;su&nbsp;(or&nbsp;(-&gt;&nbsp;c&nbsp;:supplies&nbsp;commodity)&nbsp;0)
</span><br/>
<span class="covered" title="4 out of 4 forms covered">
030&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;decrement&nbsp;(min&nbsp;st&nbsp;d)
</span><br/>
<span class="partial" title="3 out of 6 forms covered">
031&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;increment&nbsp;(cond
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
032&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;if&nbsp;we&#x27;ve&nbsp;two&nbsp;turns&#x27;&nbsp;production&nbsp;of&nbsp;this&nbsp;commodity&nbsp;in
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
033&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;stock,&nbsp;halt&nbsp;production
</span><br/>
<span class="covered" title="7 out of 7 forms covered">
034&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&gt;&nbsp;st&nbsp;(*&nbsp;su&nbsp;2))
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
035&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
036&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;if&nbsp;it&nbsp;is&nbsp;profitable&nbsp;to&nbsp;produce&nbsp;this&nbsp;commodity,&nbsp;the
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
037&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;craftspeople&nbsp;of&nbsp;the&nbsp;city&nbsp;will&nbsp;do&nbsp;so.
</span><br/>
<span class="covered" title="5 out of 5 forms covered">
038&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&gt;&nbsp;p&nbsp;1)&nbsp;su
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
039&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;otherwise,&nbsp;if&nbsp;there&nbsp;isn&#x27;t&nbsp;a&nbsp;turn&#x27;s&nbsp;production&nbsp;in
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
040&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;stock,&nbsp;top&nbsp;up&nbsp;the&nbsp;stock,&nbsp;so&nbsp;that&nbsp;there&#x27;s&nbsp;something&nbsp;for
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
041&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;incoming&nbsp;merchants&nbsp;to&nbsp;buy
</span><br/>
<span class="covered" title="4 out of 4 forms covered">
042&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&gt;&nbsp;su&nbsp;st)
</span><br/>
<span class="covered" title="4 out of 4 forms covered">
043&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(-&nbsp;su&nbsp;st)
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
044&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:else
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
045&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0)
</span><br/>
<span class="covered" title="6 out of 6 forms covered">
046&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;n&nbsp;(new-price&nbsp;p&nbsp;st&nbsp;su&nbsp;d)]
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
047&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(if
</span><br/>
<span class="covered" title="4 out of 4 forms covered">
048&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(not=&nbsp;p&nbsp;n)
</span><br/>
<span class="covered" title="26 out of 26 forms covered">
049&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(l&#x2F;info&nbsp;&quot;Price&nbsp;of&quot;&nbsp;commodity&nbsp;&quot;at&quot;&nbsp;id&nbsp;&quot;has&nbsp;changed&nbsp;from&quot;&nbsp;(float&nbsp;p)&nbsp;&quot;to&quot;&nbsp;(float&nbsp;n)))
</span><br/>
<span class="covered" title="4 out of 4 forms covered">
050&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:cities&nbsp;{id
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
051&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:stock
</span><br/>
<span class="covered" title="9 out of 9 forms covered">
052&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{commodity&nbsp;(+&nbsp;(-&nbsp;st&nbsp;decrement)&nbsp;increment)}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
053&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:prices
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
054&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{commodity&nbsp;n}}}}))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
055&nbsp;&nbsp;
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
056&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
057&nbsp;&nbsp;(defn&nbsp;update-markets
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
058&nbsp;&nbsp;&nbsp;&nbsp;&quot;Return&nbsp;a&nbsp;world&nbsp;like&nbsp;this&nbsp;`world`,&nbsp;with&nbsp;quantities&nbsp;and&nbsp;prices&nbsp;in&nbsp;markets
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
059&nbsp;&nbsp;&nbsp;&nbsp;updated&nbsp;to&nbsp;reflect&nbsp;supply&nbsp;and&nbsp;demand.&nbsp;If&nbsp;`city`&nbsp;or&nbsp;`city`&nbsp;and&nbsp;`commodity`
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
060&nbsp;&nbsp;&nbsp;&nbsp;are&nbsp;specified,&nbsp;return&nbsp;a&nbsp;fragmentary&nbsp;world&nbsp;with&nbsp;only&nbsp;the&nbsp;changes&nbsp;for&nbsp;that
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
061&nbsp;&nbsp;&nbsp;&nbsp;`city`&nbsp;(and&nbsp;`commodity`&nbsp;if&nbsp;specified)&nbsp;populated.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
062&nbsp;&nbsp;&nbsp;&nbsp;([world]
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
063&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(reduce
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
064&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;deep-merge
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
065&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;world
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
066&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
067&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#(update-markets&nbsp;world&nbsp;%)
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
068&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(keys&nbsp;(:cities&nbsp;world)))))
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
069&nbsp;&nbsp;&nbsp;&nbsp;([world&nbsp;city]
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
070&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(reduce
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
071&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;deep-merge
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
072&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{}
</span><br/>
<span class="not-covered" title="0 out of 8 forms covered">
073&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map&nbsp;#(update-markets&nbsp;world&nbsp;city&nbsp;%)
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
074&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(keys&nbsp;(:commodities&nbsp;world)))))
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
075&nbsp;&nbsp;&nbsp;&nbsp;([world&nbsp;city&nbsp;commodity]
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
076&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(adjust-quantity-and-price&nbsp;world&nbsp;city&nbsp;commodity)))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
077&nbsp;&nbsp;
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
078&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
079&nbsp;&nbsp;(defn&nbsp;run
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
080&nbsp;&nbsp;&nbsp;&nbsp;&quot;Return&nbsp;a&nbsp;world&nbsp;like&nbsp;this&nbsp;`world`,&nbsp;with&nbsp;quantities&nbsp;and&nbsp;prices&nbsp;in&nbsp;markets
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
081&nbsp;&nbsp;&nbsp;&nbsp;updated&nbsp;to&nbsp;reflect&nbsp;supply&nbsp;and&nbsp;demand.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
082&nbsp;&nbsp;&nbsp;&nbsp;[world]
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
083&nbsp;&nbsp;&nbsp;&nbsp;(update-markets&nbsp;world))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
084&nbsp;&nbsp;
</span><br/>
</body>
</html>

View file

@ -0,0 +1,284 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../../coverage.css"/> <title> the_great_game/merchants/merchant_utils.clj </title>
</head>
<body>
<span class="covered" title="1 out of 1 forms covered">
001&nbsp;&nbsp;(ns&nbsp;the-great-game.merchants.merchant-utils
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
002&nbsp;&nbsp;&nbsp;&nbsp;&quot;Useful&nbsp;functions&nbsp;for&nbsp;doing&nbsp;low-level&nbsp;things&nbsp;with&nbsp;merchants.&quot;)
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
003&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
004&nbsp;&nbsp;(defn&nbsp;expected-price
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
005&nbsp;&nbsp;&nbsp;&nbsp;&quot;Find&nbsp;the&nbsp;price&nbsp;anticipated,&nbsp;given&nbsp;this&nbsp;`world`,&nbsp;by&nbsp;this&nbsp;`merchant`&nbsp;for
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
006&nbsp;&nbsp;&nbsp;&nbsp;this&nbsp;`commodity`&nbsp;in&nbsp;this&nbsp;`city`.&nbsp;If&nbsp;no&nbsp;information,&nbsp;assume&nbsp;1.
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
007&nbsp;&nbsp;&nbsp;&nbsp;`merchant`&nbsp;should&nbsp;be&nbsp;passed&nbsp;as&nbsp;a&nbsp;map,&nbsp;`commodity`&nbsp;and&nbsp;`city`&nbsp;should&nbsp;be&nbsp;passed&nbsp;as&nbsp;keywords.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
008&nbsp;&nbsp;&nbsp;&nbsp;[merchant&nbsp;commodity&nbsp;city]
</span><br/>
<span class="covered" title="5 out of 5 forms covered">
009&nbsp;&nbsp;&nbsp;&nbsp;(or
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
010&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(:price
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
011&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(last
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
012&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(sort-by
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
013&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:date
</span><br/>
<span class="covered" title="7 out of 7 forms covered">
014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(-&gt;&nbsp;merchant&nbsp;:known-prices&nbsp;city&nbsp;commodity))))
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
015&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
016&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
017&nbsp;&nbsp;(defn&nbsp;burden
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
018&nbsp;&nbsp;&nbsp;&nbsp;&quot;The&nbsp;total&nbsp;weight&nbsp;of&nbsp;the&nbsp;current&nbsp;cargo&nbsp;carried&nbsp;by&nbsp;this&nbsp;`merchant`&nbsp;in&nbsp;this
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
019&nbsp;&nbsp;&nbsp;&nbsp;`world`.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
020&nbsp;&nbsp;&nbsp;&nbsp;[merchant&nbsp;world]
</span><br/>
<span class="partial" title="3 out of 4 forms covered">
021&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[m&nbsp;(cond
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
022&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(keyword?&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
023&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(-&gt;&nbsp;world&nbsp;:merchants&nbsp;merchant)
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
024&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map?&nbsp;merchant)
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
025&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;merchant)
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
026&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cargo&nbsp;(:stock&nbsp;m)]
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
027&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(reduce
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
028&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
029&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
030&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map
</span><br/>
<span class="not-covered" title="0 out of 12 forms covered">
031&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#(*&nbsp;(cargo&nbsp;%)&nbsp;(-&gt;&nbsp;world&nbsp;:commodities&nbsp;%&nbsp;:weight))
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
032&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(keys&nbsp;cargo)))))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
033&nbsp;&nbsp;
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
034&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
035&nbsp;&nbsp;(defn&nbsp;can-carry
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
036&nbsp;&nbsp;&nbsp;&nbsp;&quot;Return&nbsp;the&nbsp;number&nbsp;of&nbsp;units&nbsp;of&nbsp;this&nbsp;`commodity`&nbsp;which&nbsp;this&nbsp;`merchant`
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
037&nbsp;&nbsp;&nbsp;&nbsp;can&nbsp;carry&nbsp;in&nbsp;this&nbsp;`world`,&nbsp;given&nbsp;their&nbsp;current&nbsp;burden.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
038&nbsp;&nbsp;&nbsp;&nbsp;[merchant&nbsp;world&nbsp;commodity]
</span><br/>
<span class="partial" title="3 out of 4 forms covered">
039&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[m&nbsp;(cond
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
040&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(keyword?&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
041&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(-&gt;&nbsp;world&nbsp;:merchants&nbsp;merchant)
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
042&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map?&nbsp;merchant)
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
043&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;merchant)]
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
044&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(quot
</span><br/>
<span class="covered" title="9 out of 9 forms covered">
045&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(-&nbsp;(:capacity&nbsp;m)&nbsp;(burden&nbsp;m&nbsp;world))
</span><br/>
<span class="covered" title="7 out of 7 forms covered">
046&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(-&gt;&nbsp;world&nbsp;:commodities&nbsp;commodity&nbsp;:weight))))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
047&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
048&nbsp;&nbsp;(defn&nbsp;can-afford
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
049&nbsp;&nbsp;&nbsp;&nbsp;&quot;Return&nbsp;the&nbsp;number&nbsp;of&nbsp;units&nbsp;of&nbsp;this&nbsp;`commodity`&nbsp;which&nbsp;this&nbsp;`merchant`
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
050&nbsp;&nbsp;&nbsp;&nbsp;can&nbsp;afford&nbsp;to&nbsp;buy&nbsp;in&nbsp;this&nbsp;`world`.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
051&nbsp;&nbsp;&nbsp;&nbsp;[merchant&nbsp;world&nbsp;commodity]
</span><br/>
<span class="partial" title="3 out of 4 forms covered">
052&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[m&nbsp;(cond
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
053&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(keyword?&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
054&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(-&gt;&nbsp;world&nbsp;:merchants&nbsp;merchant)
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
055&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map?&nbsp;merchant)
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
056&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;merchant)
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
057&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;l&nbsp;(:location&nbsp;m)]
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
058&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(quot
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
059&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(:cash&nbsp;m)
</span><br/>
<span class="covered" title="9 out of 9 forms covered">
060&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(-&gt;&nbsp;world&nbsp;:cities&nbsp;l&nbsp;:prices&nbsp;commodity))))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
061&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
062&nbsp;&nbsp;(defn&nbsp;add-stock
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
063&nbsp;&nbsp;&nbsp;&nbsp;&quot;Where&nbsp;`a`&nbsp;and&nbsp;`b`&nbsp;are&nbsp;both&nbsp;maps&nbsp;all&nbsp;of&nbsp;whose&nbsp;values&nbsp;are&nbsp;numbers,&nbsp;return
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
064&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;map&nbsp;whose&nbsp;keys&nbsp;are&nbsp;a&nbsp;union&nbsp;of&nbsp;the&nbsp;keys&nbsp;of&nbsp;`a`&nbsp;and&nbsp;`b`&nbsp;and&nbsp;whose&nbsp;values
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
065&nbsp;&nbsp;&nbsp;&nbsp;are&nbsp;the&nbsp;sums&nbsp;of&nbsp;their&nbsp;respective&nbsp;values.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
066&nbsp;&nbsp;&nbsp;&nbsp;[a&nbsp;b]
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
067&nbsp;&nbsp;&nbsp;&nbsp;(reduce
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
068&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;merge
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
069&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
070&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map
</span><br/>
<span class="not-covered" title="0 out of 21 forms covered">
071&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#(hash-map&nbsp;%&nbsp;(+&nbsp;(or&nbsp;(a&nbsp;%)&nbsp;0)&nbsp;(or&nbsp;(b&nbsp;%)&nbsp;0)))
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
072&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(keys&nbsp;b))))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
073&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
074&nbsp;&nbsp;(defn&nbsp;add-known-prices
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
075&nbsp;&nbsp;&nbsp;&nbsp;&quot;Add&nbsp;the&nbsp;current&nbsp;prices&nbsp;at&nbsp;this&nbsp;`merchant`&#x27;s&nbsp;location&nbsp;in&nbsp;the&nbsp;`world`
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
076&nbsp;&nbsp;&nbsp;&nbsp;to&nbsp;a&nbsp;new&nbsp;cacke&nbsp;of&nbsp;known&nbsp;prices,&nbsp;and&nbsp;return&nbsp;it.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
077&nbsp;&nbsp;&nbsp;&nbsp;[merchant&nbsp;world]
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
078&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[m&nbsp;(cond
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
079&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(keyword?&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
080&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(-&gt;&nbsp;world&nbsp;:merchants&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
081&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map?&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
082&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
083&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;k&nbsp;(:known-prices&nbsp;m)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
084&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;l&nbsp;(:location&nbsp;m)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
085&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d&nbsp;(:date&nbsp;world)
</span><br/>
<span class="not-covered" title="0 out of 7 forms covered">
086&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;(-&gt;&nbsp;world&nbsp;:cities&nbsp;l&nbsp;:prices)]
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
087&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(reduce
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
088&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;merge
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
089&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;k
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
090&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map
</span><br/>
<span class="not-covered" title="0 out of 17 forms covered">
091&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#(hash-map&nbsp;%&nbsp;(apply&nbsp;vector&nbsp;cons&nbsp;{:price&nbsp;(p&nbsp;%)&nbsp;:date&nbsp;d}&nbsp;(k&nbsp;%)))
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
092&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(-&gt;&nbsp;world&nbsp;:commodities&nbsp;keys)))))
</span><br/>
</body>
</html>

View file

@ -0,0 +1,92 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../../coverage.css"/> <title> the_great_game/merchants/merchants.clj </title>
</head>
<body>
<span class="covered" title="1 out of 1 forms covered">
001&nbsp;&nbsp;(ns&nbsp;the-great-game.merchants.merchants
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
002&nbsp;&nbsp;&nbsp;&nbsp;&quot;Trade&nbsp;planning&nbsp;for&nbsp;merchants,&nbsp;primarily.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
003&nbsp;&nbsp;&nbsp;&nbsp;(:require&nbsp;[taoensso.timbre&nbsp;:as&nbsp;l&nbsp;:refer&nbsp;[info&nbsp;error&nbsp;spy]]
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
004&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[the-great-game.utils&nbsp;:refer&nbsp;[deep-merge]]
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
005&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[the-great-game.merchants.strategies.simple&nbsp;:refer&nbsp;[move-merchant]]))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
006&nbsp;&nbsp;
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
007&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
008&nbsp;&nbsp;(defn&nbsp;run
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
009&nbsp;&nbsp;&nbsp;&nbsp;&quot;Return&nbsp;a&nbsp;partial&nbsp;world&nbsp;based&nbsp;on&nbsp;this&nbsp;`world`,&nbsp;but&nbsp;with&nbsp;each&nbsp;merchant&nbsp;moved.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
010&nbsp;&nbsp;&nbsp;&nbsp;[world]
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
011&nbsp;&nbsp;&nbsp;&nbsp;(try
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
012&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(reduce
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
013&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;deep-merge
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;world
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
015&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
016&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#(try
</span><br/>
<span class="not-covered" title="0 out of 6 forms covered">
017&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[move-fn&nbsp;(or
</span><br/>
<span class="not-covered" title="0 out of 7 forms covered">
018&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(-&gt;&nbsp;world&nbsp;:merchants&nbsp;%&nbsp;:move-fn)
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
019&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;move-merchant)]
</span><br/>
<span class="not-covered" title="0 out of 7 forms covered">
020&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(apply&nbsp;move-fn&nbsp;(list&nbsp;%&nbsp;world)))
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
021&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(catch&nbsp;Exception&nbsp;any
</span><br/>
<span class="not-covered" title="0 out of 17 forms covered">
022&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(l&#x2F;error&nbsp;any&nbsp;&quot;Failure&nbsp;while&nbsp;moving&nbsp;merchant&nbsp;&quot;&nbsp;%)
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
023&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{}))
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
024&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(keys&nbsp;(:merchants&nbsp;world))))
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
025&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(catch&nbsp;Exception&nbsp;any
</span><br/>
<span class="not-covered" title="0 out of 16 forms covered">
026&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(l&#x2F;error&nbsp;any&nbsp;&quot;Failure&nbsp;while&nbsp;moving&nbsp;merchants&quot;)
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
027&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;world)))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
028&nbsp;&nbsp;
</span><br/>
</body>
</html>

View file

@ -0,0 +1,485 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../../coverage.css"/> <title> the_great_game/merchants/planning.clj </title>
</head>
<body>
<span class="covered" title="1 out of 1 forms covered">
001&nbsp;&nbsp;(ns&nbsp;the-great-game.merchants.planning
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
002&nbsp;&nbsp;&nbsp;&nbsp;&quot;Trade&nbsp;planning&nbsp;for&nbsp;merchants,&nbsp;primarily.&nbsp;This&nbsp;follows&nbsp;a&nbsp;simple-minded
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
003&nbsp;&nbsp;&nbsp;&nbsp;generate-and-test&nbsp;strategy&nbsp;and&nbsp;currently&nbsp;generates&nbsp;plans&nbsp;for&nbsp;all&nbsp;possible
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
004&nbsp;&nbsp;&nbsp;&nbsp;routes&nbsp;from&nbsp;the&nbsp;current&nbsp;location.&nbsp;This&nbsp;may&nbsp;not&nbsp;scale.&nbsp;Also,&nbsp;routes&nbsp;do&nbsp;not
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
005&nbsp;&nbsp;&nbsp;&nbsp;currently&nbsp;have&nbsp;cost&nbsp;or&nbsp;risk&nbsp;associated&nbsp;with&nbsp;them.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
006&nbsp;&nbsp;&nbsp;&nbsp;(:require&nbsp;[the-great-game.utils&nbsp;:refer&nbsp;[deep-merge&nbsp;make-target-filter]]
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
007&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[the-great-game.merchants.merchant-utils&nbsp;:refer&nbsp;:all]
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
008&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[the-great-game.world.routes&nbsp;:refer&nbsp;[find-route]]
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
009&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[the-great-game.world.world&nbsp;:refer&nbsp;[actual-price&nbsp;default-world]]))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
010&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
011&nbsp;&nbsp;(defn&nbsp;generate-trade-plans
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
012&nbsp;&nbsp;&nbsp;&nbsp;&quot;Generate&nbsp;all&nbsp;possible&nbsp;trade&nbsp;plans&nbsp;for&nbsp;this&nbsp;`merchant`&nbsp;and&nbsp;this&nbsp;`commodity`
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
013&nbsp;&nbsp;&nbsp;&nbsp;in&nbsp;this&nbsp;`world`.
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
014&nbsp;&nbsp;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
015&nbsp;&nbsp;&nbsp;&nbsp;Returned&nbsp;plans&nbsp;are&nbsp;maps&nbsp;with&nbsp;keys:
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
016&nbsp;&nbsp;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
017&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;:merchant&nbsp;-&nbsp;the&nbsp;id&nbsp;of&nbsp;the&nbsp;`merchant`&nbsp;for&nbsp;whom&nbsp;the&nbsp;plan&nbsp;was&nbsp;created;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
018&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;:origin&nbsp;-&nbsp;the&nbsp;city&nbsp;from&nbsp;which&nbsp;the&nbsp;trade&nbsp;starts;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
019&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;:destination&nbsp;-&nbsp;the&nbsp;city&nbsp;to&nbsp;which&nbsp;the&nbsp;trade&nbsp;is&nbsp;planned;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
020&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;:commodity&nbsp;-&nbsp;the&nbsp;`commodity`&nbsp;to&nbsp;be&nbsp;carried;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
021&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;:buy-price&nbsp;-&nbsp;the&nbsp;price&nbsp;at&nbsp;which&nbsp;that&nbsp;`commodity`&nbsp;can&nbsp;be&nbsp;bought;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
022&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;:expected-price&nbsp;-&nbsp;the&nbsp;price&nbsp;at&nbsp;which&nbsp;the&nbsp;`merchant`&nbsp;anticipates
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
023&nbsp;&nbsp;&nbsp;&nbsp;that&nbsp;`commodity`&nbsp;can&nbsp;be&nbsp;sold;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
024&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;:distance&nbsp;-&nbsp;the&nbsp;number&nbsp;of&nbsp;stages&nbsp;in&nbsp;the&nbsp;planned&nbsp;journey
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
025&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;:dist-to-home&nbsp;-&nbsp;the&nbsp;distance&nbsp;from&nbsp;`destination`&nbsp;to&nbsp;the&nbsp;`merchant`&#x27;s
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
026&nbsp;&nbsp;&nbsp;&nbsp;home&nbsp;city.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
027&nbsp;&nbsp;&nbsp;&nbsp;[merchant&nbsp;world&nbsp;commodity]
</span><br/>
<span class="partial" title="3 out of 4 forms covered">
028&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[m&nbsp;(cond
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
029&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(keyword?&nbsp;merchant)
</span><br/>
<span class="covered" title="5 out of 5 forms covered">
030&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(-&gt;&nbsp;world&nbsp;:merchants&nbsp;merchant)
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
031&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map?&nbsp;merchant)
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
032&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;merchant)
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
033&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;origin&nbsp;(:location&nbsp;m)]
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
034&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map
</span><br/>
<span class="covered" title="11 out of 11 forms covered">
035&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#(hash-map
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
036&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:merchant&nbsp;(:id&nbsp;m)
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
037&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:origin&nbsp;origin
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
038&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:destination&nbsp;%
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
039&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:commodity&nbsp;commodity
</span><br/>
<span class="covered" title="5 out of 5 forms covered">
040&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:buy-price&nbsp;(actual-price&nbsp;world&nbsp;commodity&nbsp;origin)
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
041&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:expected-price&nbsp;(expected-price
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
042&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
043&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;commodity
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
044&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%)
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
045&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:distance&nbsp;(count
</span><br/>
<span class="covered" title="5 out of 5 forms covered">
046&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(find-route&nbsp;world&nbsp;origin&nbsp;%))
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
047&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:dist-to-home&nbsp;(count
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
048&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(find-route
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
049&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;world
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
050&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(:home&nbsp;m)
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
051&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%)))
</span><br/>
<span class="covered" title="12 out of 12 forms covered">
052&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(remove&nbsp;#(=&nbsp;%&nbsp;origin)&nbsp;(-&gt;&nbsp;world&nbsp;:cities&nbsp;keys)))))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
053&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
054&nbsp;&nbsp;(defn&nbsp;nearest-with-targets
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
055&nbsp;&nbsp;&nbsp;&nbsp;&quot;Return&nbsp;the&nbsp;distance&nbsp;to&nbsp;the&nbsp;nearest&nbsp;destination&nbsp;among&nbsp;those&nbsp;of&nbsp;these
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
056&nbsp;&nbsp;&nbsp;&nbsp;`plans`&nbsp;which&nbsp;match&nbsp;these&nbsp;`targets`.&nbsp;Plans&nbsp;are&nbsp;expected&nbsp;to&nbsp;be&nbsp;plans
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
057&nbsp;&nbsp;&nbsp;&nbsp;as&nbsp;returned&nbsp;by&nbsp;`generate-trade-plans`,&nbsp;q.v.;&nbsp;`targets`&nbsp;are&nbsp;expected&nbsp;to&nbsp;be
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
058&nbsp;&nbsp;&nbsp;&nbsp;as&nbsp;accepted&nbsp;by&nbsp;`make-target-filter`,&nbsp;q.v.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
059&nbsp;&nbsp;&nbsp;&nbsp;[plans&nbsp;targets]
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
060&nbsp;&nbsp;&nbsp;&nbsp;(apply
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
061&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;min
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
062&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
063&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:distance
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
064&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(filter
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
065&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(make-target-filter&nbsp;targets)
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
066&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;plans))))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
067&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
068&nbsp;&nbsp;(defn&nbsp;plan-trade
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
069&nbsp;&nbsp;&nbsp;&nbsp;&quot;Find&nbsp;the&nbsp;best&nbsp;destination&nbsp;in&nbsp;this&nbsp;`world`&nbsp;for&nbsp;this&nbsp;`commodity`&nbsp;given&nbsp;this
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
070&nbsp;&nbsp;&nbsp;&nbsp;`merchant`&nbsp;and&nbsp;this&nbsp;`origin`.&nbsp;If&nbsp;two&nbsp;cities&nbsp;are&nbsp;anticipated&nbsp;to&nbsp;offer&nbsp;the
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
071&nbsp;&nbsp;&nbsp;&nbsp;same&nbsp;price,&nbsp;the&nbsp;nearer&nbsp;should&nbsp;be&nbsp;preferred;&nbsp;if&nbsp;two&nbsp;are&nbsp;equally&nbsp;distant,&nbsp;the
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
072&nbsp;&nbsp;&nbsp;&nbsp;ones&nbsp;nearer&nbsp;to&nbsp;the&nbsp;merchant&#x27;s&nbsp;home&nbsp;should&nbsp;be&nbsp;preferred.
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
073&nbsp;&nbsp;&nbsp;&nbsp;`merchant`&nbsp;may&nbsp;be&nbsp;passed&nbsp;as&nbsp;a&nbsp;map&nbsp;or&nbsp;a&nbsp;keyword;&nbsp;`commodity`&nbsp;should&nbsp;&nbsp;be
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
074&nbsp;&nbsp;&nbsp;&nbsp;passed&nbsp;as&nbsp;a&nbsp;keyword.
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
075&nbsp;&nbsp;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
076&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;returned&nbsp;plan&nbsp;is&nbsp;a&nbsp;map&nbsp;with&nbsp;keys:
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
077&nbsp;&nbsp;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
078&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;:merchant&nbsp;-&nbsp;the&nbsp;id&nbsp;of&nbsp;the&nbsp;`merchant`&nbsp;for&nbsp;whom&nbsp;the&nbsp;plan&nbsp;was&nbsp;created;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
079&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;:origin&nbsp;-&nbsp;the&nbsp;city&nbsp;from&nbsp;which&nbsp;the&nbsp;trade&nbsp;starts;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
080&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;:destination&nbsp;-&nbsp;the&nbsp;city&nbsp;to&nbsp;which&nbsp;the&nbsp;trade&nbsp;is&nbsp;planned;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
081&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;:commodity&nbsp;-&nbsp;the&nbsp;`commodity`&nbsp;to&nbsp;be&nbsp;carried;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
082&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;:buy-price&nbsp;-&nbsp;the&nbsp;price&nbsp;at&nbsp;which&nbsp;that&nbsp;`commodity`&nbsp;can&nbsp;be&nbsp;bought;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
083&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;:expected-price&nbsp;-&nbsp;the&nbsp;price&nbsp;at&nbsp;which&nbsp;the&nbsp;`merchant`&nbsp;anticipates
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
084&nbsp;&nbsp;&nbsp;&nbsp;that&nbsp;`commodity`&nbsp;can&nbsp;be&nbsp;sold;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
085&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;:distance&nbsp;-&nbsp;the&nbsp;number&nbsp;of&nbsp;stages&nbsp;in&nbsp;the&nbsp;planned&nbsp;journey
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
086&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;:dist-to-home&nbsp;-&nbsp;the&nbsp;distance&nbsp;from&nbsp;`destination`&nbsp;to&nbsp;the&nbsp;`merchant`&#x27;s
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
087&nbsp;&nbsp;&nbsp;&nbsp;home&nbsp;city.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
088&nbsp;&nbsp;&nbsp;&nbsp;[merchant&nbsp;world&nbsp;commodity]
</span><br/>
<span class="covered" title="6 out of 6 forms covered">
089&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[plans&nbsp;(generate-trade-plans&nbsp;merchant&nbsp;world&nbsp;commodity)
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
090&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;best-prices&nbsp;(filter
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
091&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(make-target-filter
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
092&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[[:expected-price
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
093&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(apply
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
094&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;max
</span><br/>
<span class="covered" title="7 out of 7 forms covered">
095&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(filter&nbsp;number?&nbsp;(map&nbsp;:expected-price&nbsp;plans)))]])
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
096&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;plans)]
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
097&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(first
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
098&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(sort-by
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
099&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;all&nbsp;other&nbsp;things&nbsp;being&nbsp;equal,&nbsp;a&nbsp;merchant&nbsp;would&nbsp;prefer&nbsp;to&nbsp;end&nbsp;closer
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
100&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;to&nbsp;home.
</span><br/>
<span class="not-covered" title="0 out of 6 forms covered">
101&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#(-&nbsp;0&nbsp;(:dist-to-home&nbsp;%))
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
102&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;a&nbsp;merchant&nbsp;will&nbsp;seek&nbsp;the&nbsp;best&nbsp;price,&nbsp;but&nbsp;won&#x27;t&nbsp;go&nbsp;further&nbsp;than
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
103&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;needed&nbsp;to&nbsp;get&nbsp;it.
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
104&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(filter
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
105&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(make-target-filter
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
106&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[[:distance
</span><br/>
<span class="covered" title="10 out of 10 forms covered">
107&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(apply&nbsp;min&nbsp;(filter&nbsp;number?&nbsp;(map&nbsp;:distance&nbsp;best-prices)))]])
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
108&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;best-prices)))))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
109&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
110&nbsp;&nbsp;(defn&nbsp;augment-plan
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
111&nbsp;&nbsp;&nbsp;&nbsp;&quot;Augment&nbsp;this&nbsp;`plan`&nbsp;constructed&nbsp;in&nbsp;this&nbsp;`world`&nbsp;for&nbsp;this&nbsp;`merchant`&nbsp;with
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
112&nbsp;&nbsp;&nbsp;&nbsp;the&nbsp;`:quantity`&nbsp;of&nbsp;goods&nbsp;which&nbsp;should&nbsp;be&nbsp;bought&nbsp;and&nbsp;the&nbsp;`:expected-profit`
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
113&nbsp;&nbsp;&nbsp;&nbsp;of&nbsp;the&nbsp;trade.
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
114&nbsp;&nbsp;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
115&nbsp;&nbsp;&nbsp;&nbsp;Returns&nbsp;the&nbsp;augmented&nbsp;plan.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
116&nbsp;&nbsp;&nbsp;&nbsp;[merchant&nbsp;world&nbsp;plan]
</span><br/>
<span class="covered" title="4 out of 4 forms covered">
117&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[c&nbsp;(:commodity&nbsp;plan)
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
118&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;o&nbsp;(:origin&nbsp;plan)
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
119&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;q&nbsp;(min
</span><br/>
<span class="partial" title="4 out of 5 forms covered">
120&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(or
</span><br/>
<span class="covered" title="9 out of 9 forms covered">
121&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(-&gt;&nbsp;world&nbsp;:cities&nbsp;o&nbsp;:stock&nbsp;c)
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
122&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0)
</span><br/>
<span class="covered" title="5 out of 5 forms covered">
123&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(can-carry&nbsp;merchant&nbsp;world&nbsp;c)
</span><br/>
<span class="covered" title="5 out of 5 forms covered">
124&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(can-afford&nbsp;merchant&nbsp;world&nbsp;c))
</span><br/>
<span class="covered" title="11 out of 11 forms covered">
125&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;(*&nbsp;q&nbsp;(-&nbsp;(:expected-price&nbsp;plan)&nbsp;(:buy-price&nbsp;plan)))]
</span><br/>
<span class="covered" title="7 out of 7 forms covered">
126&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(assoc&nbsp;plan&nbsp;:quantity&nbsp;q&nbsp;:expected-profit&nbsp;p)))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
127&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
128&nbsp;&nbsp;(defn&nbsp;select-cargo
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
129&nbsp;&nbsp;&nbsp;&nbsp;&quot;A&nbsp;`merchant`,&nbsp;in&nbsp;a&nbsp;given&nbsp;location&nbsp;in&nbsp;a&nbsp;`world`,&nbsp;will&nbsp;choose&nbsp;to&nbsp;buy&nbsp;a&nbsp;cargo
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
130&nbsp;&nbsp;&nbsp;&nbsp;within&nbsp;the&nbsp;limit&nbsp;they&nbsp;are&nbsp;capable&nbsp;of&nbsp;carrying,&nbsp;which&nbsp;they&nbsp;can&nbsp;anticipate
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
131&nbsp;&nbsp;&nbsp;&nbsp;selling&nbsp;for&nbsp;a&nbsp;profit&nbsp;at&nbsp;a&nbsp;destination.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
132&nbsp;&nbsp;&nbsp;&nbsp;[merchant&nbsp;world]
</span><br/>
<span class="partial" title="2 out of 4 forms covered">
133&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[m&nbsp;(cond
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
134&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(keyword?&nbsp;merchant)
</span><br/>
<span class="covered" title="5 out of 5 forms covered">
135&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(-&gt;&nbsp;world&nbsp;:merchants&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
136&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map?&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
137&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;merchant)
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
138&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;origin&nbsp;(:location&nbsp;m)
</span><br/>
<span class="covered" title="7 out of 7 forms covered">
139&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;available&nbsp;(-&gt;&nbsp;world&nbsp;:cities&nbsp;origin&nbsp;:stock)
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
140&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;plans&nbsp;(map
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
141&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#(augment-plan
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
142&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
143&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;world
</span><br/>
<span class="covered" title="5 out of 5 forms covered">
144&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(plan-trade&nbsp;m&nbsp;world&nbsp;%))
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
145&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(filter
</span><br/>
<span class="covered" title="10 out of 10 forms covered">
146&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#(let&nbsp;[q&nbsp;(-&gt;&nbsp;world&nbsp;:cities&nbsp;origin&nbsp;:stock&nbsp;%)]
</span><br/>
<span class="partial" title="9 out of 10 forms covered">
147&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(and&nbsp;(number?&nbsp;q)&nbsp;(pos?&nbsp;q)))
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
148&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(keys&nbsp;available)))]
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
149&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(if
</span><br/>
<span class="covered" title="5 out of 5 forms covered">
150&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(not&nbsp;(empty?&nbsp;plans))
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
151&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(first
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
152&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(sort-by
</span><br/>
<span class="not-covered" title="0 out of 6 forms covered">
153&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#(-&nbsp;0&nbsp;(:dist-to-home&nbsp;%))
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
154&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(filter
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
155&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(make-target-filter
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
156&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[[:expected-profit
</span><br/>
<span class="covered" title="10 out of 10 forms covered">
157&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(apply&nbsp;max&nbsp;(filter&nbsp;number?&nbsp;(map&nbsp;:expected-profit&nbsp;plans)))]])
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
158&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;plans))))))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
159&nbsp;&nbsp;
</span><br/>
</body>
</html>

View file

@ -0,0 +1,527 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../../../coverage.css"/> <title> the_great_game/merchants/strategies/simple.clj </title>
</head>
<body>
<span class="covered" title="1 out of 1 forms covered">
001&nbsp;&nbsp;(ns&nbsp;the-great-game.merchants.strategies.simple
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
002&nbsp;&nbsp;&nbsp;&nbsp;&quot;Default&nbsp;trading&nbsp;strategy&nbsp;for&nbsp;merchants.
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
003&nbsp;&nbsp;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
004&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;simple&nbsp;strategy&nbsp;buys&nbsp;a&nbsp;single&nbsp;product&nbsp;in&nbsp;the&nbsp;local&nbsp;market&nbsp;if&nbsp;there&nbsp;is
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
005&nbsp;&nbsp;&nbsp;&nbsp;one&nbsp;which&nbsp;can&nbsp;be&nbsp;traded&nbsp;profitably,&nbsp;trades&nbsp;it&nbsp;to&nbsp;the&nbsp;chosen&nbsp;target&nbsp;market,
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
006&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;sells&nbsp;it&nbsp;there.&nbsp;If&nbsp;there&nbsp;is&nbsp;no&nbsp;commodity&nbsp;locally&nbsp;which&nbsp;can&nbsp;be&nbsp;traded
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
007&nbsp;&nbsp;&nbsp;&nbsp;profitably,&nbsp;moves&nbsp;towards&nbsp;home&nbsp;with&nbsp;no&nbsp;cargo.&nbsp;If&nbsp;at&nbsp;home&nbsp;and&nbsp;no&nbsp;commodity
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
008&nbsp;&nbsp;&nbsp;&nbsp;can&nbsp;be&nbsp;traded&nbsp;profitably,&nbsp;does&nbsp;not&nbsp;move.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
009&nbsp;&nbsp;&nbsp;&nbsp;(:require&nbsp;[taoensso.timbre&nbsp;:as&nbsp;l&nbsp;:refer&nbsp;[info&nbsp;error&nbsp;spy]]
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
010&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[the-great-game.utils&nbsp;:refer&nbsp;[deep-merge]]
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
011&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[the-great-game.gossip.gossip&nbsp;:refer&nbsp;[move-gossip]]
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
012&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[the-great-game.merchants.planning&nbsp;:refer&nbsp;:all]
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
013&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[the-great-game.merchants.merchant-utils&nbsp;:refer
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[add-stock&nbsp;add-known-prices]]
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
015&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[the-great-game.world.routes&nbsp;:refer&nbsp;[find-route]]))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
016&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
017&nbsp;&nbsp;(defn&nbsp;plan-and-buy
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
018&nbsp;&nbsp;&nbsp;&nbsp;&quot;Return&nbsp;a&nbsp;world&nbsp;like&nbsp;this&nbsp;`world`,&nbsp;in&nbsp;which&nbsp;this&nbsp;`merchant`&nbsp;has&nbsp;planned
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
019&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;new&nbsp;trade,&nbsp;and&nbsp;bought&nbsp;appropriate&nbsp;stock&nbsp;for&nbsp;it.&nbsp;If&nbsp;no&nbsp;profitable&nbsp;trade
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
020&nbsp;&nbsp;&nbsp;&nbsp;can&nbsp;be&nbsp;planned,&nbsp;the&nbsp;merchant&nbsp;is&nbsp;simply&nbsp;moved&nbsp;towards&nbsp;their&nbsp;home.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
021&nbsp;&nbsp;&nbsp;&nbsp;[merchant&nbsp;world]
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
022&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[m&nbsp;(cond
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
023&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(keyword?&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
024&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(-&gt;&nbsp;world&nbsp;:merchants&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
025&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map?&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
026&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
027&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id&nbsp;(:id&nbsp;m)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
028&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;(:location&nbsp;m)
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
029&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;market&nbsp;(-&gt;&nbsp;world&nbsp;:cities&nbsp;location)
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
030&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;plan&nbsp;(select-cargo&nbsp;merchant&nbsp;world)]
</span><br/>
<span class="not-covered" title="0 out of 16 forms covered">
031&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(l&#x2F;debug&nbsp;&quot;plan-and-buy:&nbsp;merchant&quot;&nbsp;id)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
032&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(cond
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
033&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(not&nbsp;(empty?&nbsp;plan))
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
034&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(let
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
035&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[c&nbsp;(:commodity&nbsp;plan)
</span><br/>
<span class="not-covered" title="0 out of 8 forms covered">
036&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;(*&nbsp;(:quantity&nbsp;plan)&nbsp;(:buy-price&nbsp;plan))
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
037&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;q&nbsp;(:quantity&nbsp;plan)]
</span><br/>
<span class="not-covered" title="0 out of 25 forms covered">
038&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(l&#x2F;info&nbsp;&quot;Merchant&quot;&nbsp;id&nbsp;&quot;bought&quot;&nbsp;q&nbsp;&quot;units&nbsp;of&quot;&nbsp;c&nbsp;&quot;at&quot;&nbsp;location&nbsp;&quot;for&quot;&nbsp;p&nbsp;plan)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
039&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:merchants
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
040&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{id
</span><br/>
<span class="not-covered" title="0 out of 13 forms covered">
041&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:stock&nbsp;(add-stock&nbsp;(:stock&nbsp;m)&nbsp;{c&nbsp;q})
</span><br/>
<span class="not-covered" title="0 out of 6 forms covered">
042&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:cash&nbsp;(-&nbsp;(:cash&nbsp;m)&nbsp;p)
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
043&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:known-prices&nbsp;(add-known-prices&nbsp;m&nbsp;world)
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
044&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:plan&nbsp;plan}}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
045&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:cities
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
046&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{location
</span><br/>
<span class="not-covered" title="0 out of 17 forms covered">
047&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:stock&nbsp;(assoc&nbsp;(:stock&nbsp;market)&nbsp;c&nbsp;(-&nbsp;(-&gt;&nbsp;market&nbsp;:stock&nbsp;c)&nbsp;q))
</span><br/>
<span class="not-covered" title="0 out of 6 forms covered">
048&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:cash&nbsp;(+&nbsp;(:cash&nbsp;market)&nbsp;p)}}})
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
049&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;if&nbsp;no&nbsp;plan,&nbsp;then&nbsp;if&nbsp;at&nbsp;home&nbsp;stay&nbsp;put
</span><br/>
<span class="not-covered" title="0 out of 8 forms covered">
050&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(=&nbsp;(:location&nbsp;m)&nbsp;(:home&nbsp;m))
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
051&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(do
</span><br/>
<span class="not-covered" title="0 out of 18 forms covered">
052&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(l&#x2F;info&nbsp;&quot;Merchant&quot;&nbsp;id&nbsp;&quot;remains&nbsp;at&nbsp;home&nbsp;in&quot;&nbsp;location)
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
053&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{})
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
054&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;else&nbsp;move&nbsp;towards&nbsp;home
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
055&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:else
</span><br/>
<span class="not-covered" title="0 out of 8 forms covered">
056&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[route&nbsp;(find-route&nbsp;world&nbsp;location&nbsp;(:home&nbsp;m))
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
057&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next-location&nbsp;(nth&nbsp;route&nbsp;1)]
</span><br/>
<span class="not-covered" title="0 out of 20 forms covered">
058&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(l&#x2F;info&nbsp;&quot;No&nbsp;trade&nbsp;possible&nbsp;at&quot;&nbsp;location&nbsp;&quot;;&nbsp;merchant&quot;&nbsp;id&nbsp;&quot;moves&nbsp;to&quot;&nbsp;next-location)
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
059&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(merge
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
060&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:merchants
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
061&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{id
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
062&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:location&nbsp;next-location}}}
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
063&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(move-gossip&nbsp;id&nbsp;world&nbsp;next-location))))))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
064&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
065&nbsp;&nbsp;(defn&nbsp;re-plan
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
066&nbsp;&nbsp;&nbsp;&nbsp;&quot;Having&nbsp;failed&nbsp;to&nbsp;sell&nbsp;a&nbsp;cargo&nbsp;at&nbsp;current&nbsp;location,&nbsp;re-plan&nbsp;a&nbsp;route&nbsp;to
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
067&nbsp;&nbsp;&nbsp;&nbsp;sell&nbsp;the&nbsp;current&nbsp;cargo.&nbsp;Returns&nbsp;a&nbsp;revised&nbsp;world.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
068&nbsp;&nbsp;&nbsp;&nbsp;[merchant&nbsp;world]
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
069&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[m&nbsp;(cond
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
070&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(keyword?&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
071&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(-&gt;&nbsp;world&nbsp;:merchants&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
072&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map?&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
073&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
074&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id&nbsp;(:id&nbsp;m)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
075&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;(:location&nbsp;m)
</span><br/>
<span class="not-covered" title="0 out of 13 forms covered">
076&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;plan&nbsp;(augment-plan&nbsp;m&nbsp;world&nbsp;(plan-trade&nbsp;m&nbsp;world&nbsp;(-&gt;&nbsp;m&nbsp;:plan&nbsp;:commodity)))]
</span><br/>
<span class="not-covered" title="0 out of 16 forms covered">
077&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(l&#x2F;debug&nbsp;&quot;re-plan:&nbsp;merchant&quot;&nbsp;id)
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
078&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(deep-merge
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
079&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;world
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
080&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:merchants
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
081&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{id
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
082&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:plan&nbsp;plan}}})))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
083&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
084&nbsp;&nbsp;(defn&nbsp;sell-and-buy
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
085&nbsp;&nbsp;&nbsp;&nbsp;&quot;Return&nbsp;a&nbsp;new&nbsp;world&nbsp;like&nbsp;this&nbsp;`world`,&nbsp;in&nbsp;which&nbsp;this&nbsp;`merchant`&nbsp;has&nbsp;sold
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
086&nbsp;&nbsp;&nbsp;&nbsp;their&nbsp;current&nbsp;stock&nbsp;in&nbsp;their&nbsp;current&nbsp;location,&nbsp;and&nbsp;planned&nbsp;a&nbsp;new&nbsp;trade,&nbsp;and
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
087&nbsp;&nbsp;&nbsp;&nbsp;bought&nbsp;appropriate&nbsp;stock&nbsp;for&nbsp;it.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
088&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;TODO:&nbsp;this&nbsp;either&nbsp;sells&nbsp;the&nbsp;entire&nbsp;cargo,&nbsp;or,&nbsp;if&nbsp;the&nbsp;market&nbsp;can&#x27;t&nbsp;afford
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
089&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;it,&nbsp;none&nbsp;of&nbsp;it.&nbsp;And&nbsp;it&nbsp;does&nbsp;not&nbsp;cope&nbsp;with&nbsp;selling&nbsp;different&nbsp;commodities
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
090&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;in&nbsp;different&nbsp;markets.
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
091&nbsp;&nbsp;&nbsp;&nbsp;[merchant&nbsp;world]
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
092&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[m&nbsp;(cond
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
093&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(keyword?&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
094&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(-&gt;&nbsp;world&nbsp;:merchants&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
095&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map?&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
096&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
097&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id&nbsp;(:id&nbsp;m)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
098&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location&nbsp;(:location&nbsp;m)
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
099&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;market&nbsp;(-&gt;&nbsp;world&nbsp;:cities&nbsp;location)
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
100&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stock-value&nbsp;(reduce
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
101&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
102&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map
</span><br/>
<span class="not-covered" title="0 out of 12 forms covered">
103&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#(*&nbsp;(-&gt;&nbsp;m&nbsp;:stock&nbsp;%)&nbsp;(-&gt;&nbsp;market&nbsp;:prices&nbsp;m))
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
104&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(keys&nbsp;(:stock&nbsp;m))))]
</span><br/>
<span class="not-covered" title="0 out of 16 forms covered">
105&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(l&#x2F;debug&nbsp;&quot;sell-and-buy:&nbsp;merchant&quot;&nbsp;id)
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
106&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(if
</span><br/>
<span class="not-covered" title="0 out of 6 forms covered">
107&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&gt;=&nbsp;(:cash&nbsp;market)&nbsp;stock-value)
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
108&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(do
</span><br/>
<span class="not-covered" title="0 out of 24 forms covered">
109&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(l&#x2F;info&nbsp;&quot;Merchant&quot;&nbsp;id&nbsp;&quot;sells&quot;&nbsp;(:stock&nbsp;m)&nbsp;&quot;at&quot;&nbsp;location&nbsp;&quot;for&quot;&nbsp;stock-value)
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
110&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(plan-and-buy
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
111&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;merchant
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
112&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(deep-merge
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
113&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;world
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
114&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:merchants
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
115&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{id
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
116&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:stock&nbsp;{}
</span><br/>
<span class="not-covered" title="0 out of 6 forms covered">
117&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:cash&nbsp;(+&nbsp;(:cash&nbsp;m)&nbsp;stock-value)
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
118&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:known-prices&nbsp;(add-known-prices&nbsp;m&nbsp;world)}}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
119&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:cities
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
120&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{location
</span><br/>
<span class="not-covered" title="0 out of 11 forms covered">
121&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:stock&nbsp;(add-stock&nbsp;(:stock&nbsp;m)&nbsp;(:stock&nbsp;market))
</span><br/>
<span class="not-covered" title="0 out of 6 forms covered">
122&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:cash&nbsp;(-&nbsp;(:cash&nbsp;market)&nbsp;stock-value)}}})))
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
123&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;else
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
124&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(re-plan&nbsp;merchant&nbsp;world))))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
125&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
126&nbsp;&nbsp;(defn&nbsp;move-merchant
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
127&nbsp;&nbsp;&nbsp;&nbsp;&quot;Handle&nbsp;general&nbsp;en&nbsp;route&nbsp;movement&nbsp;of&nbsp;this&nbsp;`merchant`&nbsp;in&nbsp;this&nbsp;`world`;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
128&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;a&nbsp;(partial&nbsp;or&nbsp;full)&nbsp;world&nbsp;like&nbsp;this&nbsp;`world`&nbsp;but&nbsp;in&nbsp;which&nbsp;the
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
129&nbsp;&nbsp;&nbsp;&nbsp;merchant&nbsp;may&nbsp;have&nbsp;been&nbsp;moved&nbsp;ot&nbsp;updated.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
130&nbsp;&nbsp;&nbsp;&nbsp;[merchant&nbsp;world]
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
131&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[m&nbsp;(cond
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
132&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(keyword?&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
133&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(-&gt;&nbsp;world&nbsp;:merchants&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
134&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map?&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
135&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;merchant)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
136&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id&nbsp;(:id&nbsp;m)
</span><br/>
<span class="not-covered" title="0 out of 17 forms covered">
137&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at-destination?&nbsp;(and&nbsp;(:plan&nbsp;m)&nbsp;(=&nbsp;(:location&nbsp;m)&nbsp;(-&gt;&nbsp;m&nbsp;:plan&nbsp;:destination)))
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
138&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;plan&nbsp;(:plan&nbsp;m)
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
139&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next-location&nbsp;(if&nbsp;plan
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
140&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(nth
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
141&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(find-route
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
142&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;world
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
143&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(:location&nbsp;m)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
144&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(:destination&nbsp;plan))
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
145&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1)
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
146&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(:location&nbsp;m))]
</span><br/>
<span class="not-covered" title="0 out of 23 forms covered">
147&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(l&#x2F;debug&nbsp;&quot;move-merchant:&nbsp;merchant&quot;&nbsp;id&nbsp;&quot;at&quot;&nbsp;(:location&nbsp;m)
</span><br/>
<span class="not-covered" title="0 out of 6 forms covered">
148&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;destination&quot;&nbsp;(-&gt;&nbsp;m&nbsp;:plan&nbsp;:destination)&nbsp;&quot;next&quot;&nbsp;next-location
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
149&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;at&nbsp;destination&quot;&nbsp;at-destination?)
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
150&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(cond
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
151&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;if&nbsp;the&nbsp;merchant&nbsp;is&nbsp;at&nbsp;the&nbsp;destination&nbsp;of&nbsp;their&nbsp;current&nbsp;plan
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
152&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;sell&nbsp;all&nbsp;cargo&nbsp;and&nbsp;repurchase.
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
153&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at-destination?
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
154&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(sell-and-buy&nbsp;merchant&nbsp;world)
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
155&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;if&nbsp;they&nbsp;don&#x27;t&nbsp;have&nbsp;a&nbsp;plan,&nbsp;seek&nbsp;to&nbsp;create&nbsp;one
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
156&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(nil?&nbsp;plan)
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
157&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(plan-and-buy&nbsp;merchant&nbsp;world)
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
158&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;otherwise,&nbsp;move&nbsp;one&nbsp;step&nbsp;towards&nbsp;their&nbsp;destination
</span><br/>
<span class="not-covered" title="0 out of 11 forms covered">
159&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(and&nbsp;next-location&nbsp;(not=&nbsp;next-location&nbsp;(:location&nbsp;m)))
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
160&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(do
</span><br/>
<span class="not-covered" title="0 out of 22 forms covered">
161&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(l&#x2F;info&nbsp;&quot;Merchant&nbsp;&quot;&nbsp;id&nbsp;&quot;&nbsp;moving&nbsp;from&nbsp;&quot;&nbsp;(:location&nbsp;m)&nbsp;&quot;&nbsp;to&nbsp;&quot;&nbsp;next-location)
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
162&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(deep-merge
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
163&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:merchants
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
164&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{id
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
165&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:location&nbsp;next-location
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
166&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:known-prices&nbsp;(add-known-prices&nbsp;m&nbsp;world)}}}
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
167&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(move-gossip&nbsp;id&nbsp;world&nbsp;next-location)))
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
168&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:else
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
169&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(do
</span><br/>
<span class="not-covered" title="0 out of 18 forms covered">
170&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(l&#x2F;info&nbsp;&quot;Merchant&quot;&nbsp;id&nbsp;&quot;has&nbsp;plan&nbsp;but&nbsp;no&nbsp;next-location;&nbsp;currently&nbsp;at&quot;
</span><br/>
<span class="not-covered" title="0 out of 6 forms covered">
171&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(:location&nbsp;m)&nbsp;&quot;,&nbsp;destination&nbsp;is&quot;&nbsp;(:destination&nbsp;plan))
</span><br/>
<span class="not-covered" title="0 out of 1 forms covered">
172&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;world))))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
173&nbsp;&nbsp;
</span><br/>
</body>
</html>

View file

@ -0,0 +1,113 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../coverage.css"/> <title> the_great_game/utils.clj </title>
</head>
<body>
<span class="covered" title="1 out of 1 forms covered">
001&nbsp;&nbsp;(ns&nbsp;the-great-game.utils)
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
002&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
003&nbsp;&nbsp;(defn&nbsp;cyclic?
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
004&nbsp;&nbsp;&nbsp;&nbsp;&quot;True&nbsp;if&nbsp;two&nbsp;or&nbsp;more&nbsp;elements&nbsp;of&nbsp;`route`&nbsp;are&nbsp;identical&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
005&nbsp;&nbsp;&nbsp;&nbsp;[route]
</span><br/>
<span class="covered" title="10 out of 10 forms covered">
006&nbsp;&nbsp;&nbsp;&nbsp;(not=&nbsp;(count&nbsp;route)(count&nbsp;(set&nbsp;route))))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
007&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
008&nbsp;&nbsp;(defn&nbsp;deep-merge
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
009&nbsp;&nbsp;&nbsp;&nbsp;&quot;Recursively&nbsp;merges&nbsp;maps.&nbsp;Stolen&nbsp;from
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
010&nbsp;&nbsp;&nbsp;&nbsp;https:&#x2F;&#x2F;dnaeon.github.io&#x2F;recursively-merging-maps-in-clojure&#x2F;&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
011&nbsp;&nbsp;&nbsp;&nbsp;[&amp;&nbsp;maps]
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
012&nbsp;&nbsp;&nbsp;&nbsp;(letfn&nbsp;[(m&nbsp;[&amp;&nbsp;xs]
</span><br/>
<span class="covered" title="17 out of 17 forms covered">
013&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(if&nbsp;(some&nbsp;#(and&nbsp;(map?&nbsp;%)&nbsp;(not&nbsp;(record?&nbsp;%)))&nbsp;xs)
</span><br/>
<span class="covered" title="5 out of 5 forms covered">
014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(apply&nbsp;merge-with&nbsp;m&nbsp;xs)
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
015&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(last&nbsp;xs)))]
</span><br/>
<span class="covered" title="4 out of 4 forms covered">
016&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(reduce&nbsp;m&nbsp;maps)))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
017&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
018&nbsp;&nbsp;(defn&nbsp;make-target-filter
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
019&nbsp;&nbsp;&nbsp;&nbsp;&quot;Construct&nbsp;a&nbsp;filter&nbsp;which,&nbsp;when&nbsp;applied&nbsp;to&nbsp;a&nbsp;list&nbsp;of&nbsp;maps,
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
020&nbsp;&nbsp;&nbsp;&nbsp;will&nbsp;pass&nbsp;those&nbsp;which&nbsp;match&nbsp;these&nbsp;`targets`,&nbsp;where&nbsp;each&nbsp;target
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
021&nbsp;&nbsp;&nbsp;&nbsp;is&nbsp;a&nbsp;tuple&nbsp;[key&nbsp;value].&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
022&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;TODO:&nbsp;this&nbsp;would&nbsp;probably&nbsp;be&nbsp;more&nbsp;elegant&nbsp;as&nbsp;a&nbsp;macro
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
023&nbsp;&nbsp;&nbsp;&nbsp;[targets]
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
024&nbsp;&nbsp;&nbsp;&nbsp;(eval
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
025&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(list
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
026&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#x27;fn
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
027&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(vector&nbsp;&#x27;m)
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
028&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(cons
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
029&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#x27;and
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
030&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
031&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#(list
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
032&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#x27;=
</span><br/>
<span class="covered" title="6 out of 6 forms covered">
033&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(list&nbsp;(first&nbsp;%)&nbsp;&#x27;m)
</span><br/>
<span class="covered" title="4 out of 4 forms covered">
034&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(nth&nbsp;%&nbsp;1))
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
035&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;targets)))))
</span><br/>
</body>
</html>

View file

@ -0,0 +1,173 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../../coverage.css"/> <title> the_great_game/world/routes.clj </title>
</head>
<body>
<span class="covered" title="1 out of 1 forms covered">
001&nbsp;&nbsp;(ns&nbsp;the-great-game.world.routes
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
002&nbsp;&nbsp;&nbsp;&nbsp;&quot;Conceptual&nbsp;(plan&nbsp;level)&nbsp;routes,&nbsp;represented&nbsp;as&nbsp;tuples&nbsp;of&nbsp;location&nbsp;ids.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
003&nbsp;&nbsp;&nbsp;&nbsp;(:require&nbsp;[the-great-game.utils&nbsp;:refer&nbsp;[cyclic?]]))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
004&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
005&nbsp;&nbsp;(defn&nbsp;find-routes
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
006&nbsp;&nbsp;&nbsp;&nbsp;&quot;Find&nbsp;routes&nbsp;from&nbsp;among&nbsp;these&nbsp;`routes`&nbsp;from&nbsp;`from`;&nbsp;if&nbsp;`to`&nbsp;is&nbsp;supplied,
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
007&nbsp;&nbsp;&nbsp;&nbsp;to&nbsp;`to`,&nbsp;by&nbsp;breadth-first&nbsp;search.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
008&nbsp;&nbsp;&nbsp;&nbsp;([routes&nbsp;from]
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
009&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map
</span><br/>
<span class="covered" title="5 out of 5 forms covered">
010&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(fn&nbsp;[to]&nbsp;(cons&nbsp;from&nbsp;to))
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
011&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(remove
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
012&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;empty?
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
013&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(fn&nbsp;[route]
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
015&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(remove
</span><br/>
<span class="covered" title="4 out of 4 forms covered">
016&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#(=&nbsp;from&nbsp;%)
</span><br/>
<span class="covered" title="10 out of 10 forms covered">
017&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(if&nbsp;(some&nbsp;#(=&nbsp;%&nbsp;from)&nbsp;route)&nbsp;route)))
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
018&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;routes))))
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
019&nbsp;&nbsp;&nbsp;&nbsp;([routes&nbsp;from&nbsp;to]
</span><br/>
<span class="covered" title="5 out of 5 forms covered">
020&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[steps&nbsp;(find-routes&nbsp;routes&nbsp;from)
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
021&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;found&nbsp;(filter
</span><br/>
<span class="covered" title="11 out of 11 forms covered">
022&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(fn&nbsp;[step]&nbsp;(if&nbsp;(some&nbsp;#(=&nbsp;to&nbsp;%)&nbsp;step)&nbsp;step))
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
023&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;steps)]
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
024&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(if
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
025&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(empty?&nbsp;found)
</span><br/>
<span class="covered" title="6 out of 6 forms covered">
026&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(find-routes&nbsp;routes&nbsp;from&nbsp;to&nbsp;steps)
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
027&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;found)))
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
028&nbsp;&nbsp;&nbsp;&nbsp;([routes&nbsp;from&nbsp;to&nbsp;steps]
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
029&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(if
</span><br/>
<span class="covered" title="5 out of 5 forms covered">
030&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(not&nbsp;(empty?&nbsp;steps))
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
031&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[paths&nbsp;(remove
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
032&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cyclic?
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
033&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(mapcat
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
034&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(fn&nbsp;[path]
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
035&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(map
</span><br/>
<span class="covered" title="7 out of 7 forms covered">
036&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(fn&nbsp;[x]&nbsp;(concat&nbsp;path&nbsp;(rest&nbsp;x)))
</span><br/>
<span class="covered" title="6 out of 6 forms covered">
037&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(find-routes&nbsp;routes&nbsp;(last&nbsp;path))))
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
038&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;steps))
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
039&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;found&nbsp;(filter
</span><br/>
<span class="covered" title="7 out of 7 forms covered">
040&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#(=&nbsp;(last&nbsp;%)&nbsp;to)&nbsp;paths)]
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
041&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(if
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
042&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(empty?&nbsp;found)
</span><br/>
<span class="covered" title="6 out of 6 forms covered">
043&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(find-routes&nbsp;routes&nbsp;from&nbsp;to&nbsp;paths)
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
044&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;found)))))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
045&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
046&nbsp;&nbsp;(defn&nbsp;find-route
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
047&nbsp;&nbsp;&nbsp;&nbsp;&quot;Find&nbsp;a&nbsp;single&nbsp;route&nbsp;from&nbsp;`from`&nbsp;to&nbsp;`to`&nbsp;in&nbsp;this&nbsp;`world-or-routes`,&nbsp;which
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
048&nbsp;&nbsp;&nbsp;&nbsp;may&nbsp;be&nbsp;either&nbsp;a&nbsp;world&nbsp;as&nbsp;defined&nbsp;in&nbsp;[[the-great-game.world.world]]&nbsp;or&nbsp;else
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
049&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;sequence&nbsp;of&nbsp;tuples&nbsp;of&nbsp;keywords.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
050&nbsp;&nbsp;&nbsp;&nbsp;[world-or-routes&nbsp;from&nbsp;to]
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
051&nbsp;&nbsp;&nbsp;&nbsp;(first
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
052&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(find-routes
</span><br/>
<span class="partial" title="7 out of 8 forms covered">
053&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(or&nbsp;(:routes&nbsp;world-or-routes)&nbsp;world-or-routes)
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
054&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
055&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to)))
</span><br/>
</body>
</html>

View file

@ -0,0 +1,125 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../../coverage.css"/> <title> the_great_game/world/run.clj </title>
</head>
<body>
<span class="covered" title="1 out of 1 forms covered">
001&nbsp;&nbsp;(ns&nbsp;the-great-game.world.run
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
002&nbsp;&nbsp;&nbsp;&nbsp;&quot;Run&nbsp;the&nbsp;whole&nbsp;simulation&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
003&nbsp;&nbsp;&nbsp;&nbsp;(:require&nbsp;[environ.core&nbsp;:refer&nbsp;[env]]
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
004&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[taoensso.timbre&nbsp;:as&nbsp;timbre]
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
005&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[taoensso.timbre.appenders.3rd-party.rotor&nbsp;:as&nbsp;rotor]
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
006&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[the-great-game.gossip.gossip&nbsp;:as&nbsp;g]
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
007&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[the-great-game.merchants.merchants&nbsp;:as&nbsp;m]
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
008&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[the-great-game.merchants.markets&nbsp;:as&nbsp;k]
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
009&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[the-great-game.world.world&nbsp;:as&nbsp;w]))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
010&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
011&nbsp;&nbsp;(defn&nbsp;init
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
012&nbsp;&nbsp;&nbsp;&nbsp;([]
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
013&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(init&nbsp;{}))
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
014&nbsp;&nbsp;&nbsp;&nbsp;([config]
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
015&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(timbre&#x2F;merge-config!
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
016&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:appenders
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
017&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:rotor&nbsp;(rotor&#x2F;rotor-appender
</span><br/>
<span class="not-covered" title="0 out of 6 forms covered">
018&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:path&nbsp;&quot;the-great-game.log&quot;
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
019&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:max-size&nbsp;(*&nbsp;512&nbsp;1024)
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
020&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:backlog&nbsp;10})}
</span><br/>
<span class="not-covered" title="0 out of 9 forms covered">
021&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:level&nbsp;(or
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
022&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(:log-level&nbsp;config)
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
023&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(if&nbsp;(env&nbsp;:dev)&nbsp;:debug)
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
024&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:info)})))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
025&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
026&nbsp;&nbsp;(defn&nbsp;run
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
027&nbsp;&nbsp;&nbsp;&nbsp;&quot;The&nbsp;pipeline&nbsp;to&nbsp;run&nbsp;the&nbsp;simulation&nbsp;each&nbsp;game&nbsp;day.&nbsp;Returns&nbsp;a&nbsp;world&nbsp;like
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
028&nbsp;&nbsp;&nbsp;&nbsp;this&nbsp;world,&nbsp;with&nbsp;all&nbsp;the&nbsp;various&nbsp;active&nbsp;elements&nbsp;updated.&nbsp;The&nbsp;optional
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
029&nbsp;&nbsp;&nbsp;&nbsp;`date`&nbsp;argument,&nbsp;if&nbsp;supplied,&nbsp;is&nbsp;set&nbsp;as&nbsp;the&nbsp;`:date`&nbsp;of&nbsp;the&nbsp;returned&nbsp;world.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
030&nbsp;&nbsp;&nbsp;&nbsp;([world]
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
031&nbsp;&nbsp;&nbsp;&nbsp;(g&#x2F;run
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
032&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(m&#x2F;run
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
033&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(k&#x2F;run
</span><br/>
<span class="not-covered" title="0 out of 3 forms covered">
034&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(w&#x2F;run&nbsp;world)))))
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
035&nbsp;&nbsp;&nbsp;&nbsp;([world&nbsp;date]
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
036&nbsp;&nbsp;&nbsp;&nbsp;(g&#x2F;run
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
037&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(m&#x2F;run
</span><br/>
<span class="not-covered" title="0 out of 2 forms covered">
038&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(k&#x2F;run
</span><br/>
<span class="not-covered" title="0 out of 4 forms covered">
039&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(w&#x2F;run&nbsp;world&nbsp;date))))))
</span><br/>
</body>
</html>

View file

@ -0,0 +1,584 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../../coverage.css"/> <title> the_great_game/world/world.clj </title>
</head>
<body>
<span class="covered" title="1 out of 1 forms covered">
001&nbsp;&nbsp;(ns&nbsp;the-great-game.world.world
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
002&nbsp;&nbsp;&nbsp;&nbsp;&quot;Access&nbsp;to&nbsp;data&nbsp;about&nbsp;the&nbsp;world&quot;)
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
003&nbsp;&nbsp;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
004&nbsp;&nbsp;;;;&nbsp;The&nbsp;world&nbsp;has&nbsp;to&nbsp;work&nbsp;either&nbsp;as&nbsp;map&nbsp;or&nbsp;a&nbsp;database.&nbsp;Initially,&nbsp;and&nbsp;for
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
005&nbsp;&nbsp;;;;&nbsp;unit&nbsp;tests,&nbsp;I&#x27;ll&nbsp;use&nbsp;a&nbsp;map;&nbsp;later,&nbsp;there&nbsp;will&nbsp;be&nbsp;a&nbsp;database.&nbsp;But&nbsp;the
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
006&nbsp;&nbsp;;;;&nbsp;API&nbsp;needs&nbsp;to&nbsp;be&nbsp;agnostic,&nbsp;so&nbsp;that&nbsp;heirarchies&nbsp;which&nbsp;interact&nbsp;with
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
007&nbsp;&nbsp;;;;&nbsp;`world`&nbsp;don&#x27;t&nbsp;have&nbsp;to&nbsp;know&nbsp;which&nbsp;they&#x27;ve&nbsp;got&nbsp;-&nbsp;as&nbsp;far&nbsp;as&nbsp;they&#x27;re&nbsp;concerned
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
008&nbsp;&nbsp;;;;&nbsp;it&#x27;s&nbsp;just&nbsp;a&nbsp;handle.
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
009&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
010&nbsp;&nbsp;(def&nbsp;default-world
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
011&nbsp;&nbsp;&nbsp;&nbsp;&quot;A&nbsp;basic&nbsp;world&nbsp;for&nbsp;testing&nbsp;concepts&quot;
</span><br/>
<span class="covered" title="7 out of 7 forms covered">
012&nbsp;&nbsp;&nbsp;&nbsp;{:date&nbsp;0&nbsp;;;&nbsp;the&nbsp;age&nbsp;of&nbsp;this&nbsp;world&nbsp;in&nbsp;game&nbsp;days
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
013&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:cities
</span><br/>
<span class="covered" title="8 out of 8 forms covered">
014&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:aberdeen
</span><br/>
<span class="covered" title="11 out of 11 forms covered">
015&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:id&nbsp;:aberdeen
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
016&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:supplies
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
017&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;`supplies`&nbsp;is&nbsp;the&nbsp;quantity&nbsp;of&nbsp;each&nbsp;commodity&nbsp;added&nbsp;to&nbsp;the&nbsp;stock
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
018&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;each&nbsp;game&nbsp;day.&nbsp;If&nbsp;the&nbsp;price&nbsp;in&nbsp;the&nbsp;market&nbsp;is&nbsp;lower&nbsp;than&nbsp;1&nbsp;(the
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
019&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;cost&nbsp;of&nbsp;production&nbsp;of&nbsp;a&nbsp;unit)&nbsp;no&nbsp;goods&nbsp;will&nbsp;be&nbsp;added.
</span><br/>
<span class="covered" title="5 out of 5 forms covered">
020&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:fish&nbsp;10
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
021&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:leather&nbsp;5}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
022&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:demands
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
023&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;`stock`&nbsp;is&nbsp;the&nbsp;quantity&nbsp;of&nbsp;each&nbsp;commodity&nbsp;in&nbsp;the&nbsp;market&nbsp;at&nbsp;any
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
024&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;given&nbsp;time.&nbsp;It&nbsp;is&nbsp;adjusted&nbsp;for&nbsp;production&nbsp;and&nbsp;consumption&nbsp;at
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
025&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;the&nbsp;end&nbsp;of&nbsp;each&nbsp;game&nbsp;day.
</span><br/>
<span class="covered" title="7 out of 7 forms covered">
026&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:iron&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
027&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:cloth&nbsp;10
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
028&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:whisky&nbsp;10}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
029&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:port&nbsp;true
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
030&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:prices
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
031&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;`prices`:&nbsp;the&nbsp;current&nbsp;price&nbsp;(both&nbsp;buying&nbsp;and&nbsp;selling,&nbsp;for&nbsp;simplicity)
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
032&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;of&nbsp;each&nbsp;commodity&nbsp;in&nbsp;the&nbsp;market.&nbsp;Updated&nbsp;each&nbsp;game&nbsp;day&nbsp;based&nbsp;on&nbsp;current
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
033&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;stock.
</span><br/>
<span class="covered" title="11 out of 11 forms covered">
034&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:cloth&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
035&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:fish&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
036&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:leather&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
037&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:iron&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
038&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:whisky&nbsp;1}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
039&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:stock
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
040&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;`stock`&nbsp;is&nbsp;the&nbsp;quantity&nbsp;of&nbsp;each&nbsp;commodity&nbsp;in&nbsp;the&nbsp;market&nbsp;at&nbsp;any
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
041&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;given&nbsp;time.&nbsp;It&nbsp;is&nbsp;adjusted&nbsp;for&nbsp;production&nbsp;and&nbsp;consumption&nbsp;at
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
042&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;the&nbsp;end&nbsp;of&nbsp;each&nbsp;game&nbsp;day.
</span><br/>
<span class="covered" title="11 out of 11 forms covered">
043&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:cloth&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
044&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:fish&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
045&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:leather&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
046&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:iron&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
047&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:whisky&nbsp;0}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
048&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:cash&nbsp;100}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
049&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:buckie
</span><br/>
<span class="covered" title="11 out of 11 forms covered">
050&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:id&nbsp;:buckie
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
051&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:supplies
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
052&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:fish&nbsp;20}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
053&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:demands
</span><br/>
<span class="covered" title="9 out of 9 forms covered">
054&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:cloth&nbsp;5
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
055&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:leather&nbsp;3
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
056&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:whisky&nbsp;5
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
057&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:iron&nbsp;1}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
058&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:port&nbsp;true
</span><br/>
<span class="covered" title="11 out of 11 forms covered">
059&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:prices&nbsp;{:cloth&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
060&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:fish&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
061&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:leather&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
062&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:iron&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
063&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:whisky&nbsp;1}
</span><br/>
<span class="covered" title="11 out of 11 forms covered">
064&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:stock&nbsp;{:cloth&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
065&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:fish&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
066&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:leather&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
067&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:iron&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
068&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:whisky&nbsp;0}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
069&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:cash&nbsp;100}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
070&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:callander
</span><br/>
<span class="covered" title="9 out of 9 forms covered">
071&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:id&nbsp;:callander
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
072&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:supplies&nbsp;{:leather&nbsp;20}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
073&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:demands
</span><br/>
<span class="covered" title="9 out of 9 forms covered">
074&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:cloth&nbsp;5
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
075&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:fish&nbsp;3
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
076&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:whisky&nbsp;5
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
077&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:iron&nbsp;1}
</span><br/>
<span class="covered" title="11 out of 11 forms covered">
078&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:prices&nbsp;{:cloth&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
079&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:fish&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
080&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:leather&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
081&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:iron&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
082&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:whisky&nbsp;1}
</span><br/>
<span class="covered" title="11 out of 11 forms covered">
083&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:stock&nbsp;{:cloth&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
084&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:fish&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
085&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:leather&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
086&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:iron&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
087&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:whisky&nbsp;0}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
088&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:cash&nbsp;100}
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
089&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:dundee&nbsp;{:id&nbsp;:dundee}
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
090&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:edinburgh&nbsp;{:id&nbsp;:dundee}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
091&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:falkirk
</span><br/>
<span class="covered" title="11 out of 11 forms covered">
092&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:id&nbsp;:falkirk
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
093&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:supplies&nbsp;{:iron&nbsp;10}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
094&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:demands
</span><br/>
<span class="covered" title="9 out of 9 forms covered">
095&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:cloth&nbsp;5
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
096&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:leather&nbsp;3
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
097&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:whisky&nbsp;5
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
098&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:fish&nbsp;10}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
099&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:port&nbsp;true
</span><br/>
<span class="covered" title="11 out of 11 forms covered">
100&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:prices&nbsp;{:cloth&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
101&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:fish&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
102&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:leather&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
103&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:iron&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
104&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:whisky&nbsp;1}
</span><br/>
<span class="covered" title="11 out of 11 forms covered">
105&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:stock&nbsp;{:cloth&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
106&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:fish&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
107&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:leather&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
108&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:iron&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
109&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:whisky&nbsp;0}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
110&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:cash&nbsp;100}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
111&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:glasgow
</span><br/>
<span class="covered" title="11 out of 11 forms covered">
112&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:id&nbsp;:glasgow
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
113&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:supplies&nbsp;{:whisky&nbsp;10}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
114&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:demands
</span><br/>
<span class="covered" title="9 out of 9 forms covered">
115&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:cloth&nbsp;5
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
116&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:leather&nbsp;3
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
117&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:iron&nbsp;5
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
118&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:fish&nbsp;10}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
119&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:port&nbsp;true
</span><br/>
<span class="covered" title="11 out of 11 forms covered">
120&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:prices&nbsp;{:cloth&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
121&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:fish&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
122&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:leather&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
123&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:iron&nbsp;1
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
124&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:whisky&nbsp;1}
</span><br/>
<span class="covered" title="11 out of 11 forms covered">
125&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:stock&nbsp;{:cloth&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
126&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:fish&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
127&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:leather&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
128&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:iron&nbsp;0
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
129&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:whisky&nbsp;0}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
130&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:cash&nbsp;100}}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
131&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:merchants
</span><br/>
<span class="covered" title="20 out of 20 forms covered">
132&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:archie&nbsp;{:id&nbsp;:archie
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
133&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:home&nbsp;:aberdeen&nbsp;:location&nbsp;:aberdeen&nbsp;:cash&nbsp;100&nbsp;:capacity&nbsp;10
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
134&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:known-prices&nbsp;{}
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
135&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:stock&nbsp;{}}
</span><br/>
<span class="covered" title="13 out of 13 forms covered">
136&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:belinda&nbsp;{:id&nbsp;:belinda
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
137&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:home&nbsp;:buckie&nbsp;:location&nbsp;:buckie&nbsp;:cash&nbsp;100&nbsp;:capacity&nbsp;10
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
138&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:known-prices&nbsp;{}
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
139&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:stock&nbsp;{}}
</span><br/>
<span class="covered" title="13 out of 13 forms covered">
140&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:callum&nbsp;{:id&nbsp;:callum
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
141&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:home&nbsp;:callander&nbsp;:location&nbsp;:calander&nbsp;:cash&nbsp;100&nbsp;:capacity&nbsp;10
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
142&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:known-prices&nbsp;{}
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
143&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:stock&nbsp;{}}
</span><br/>
<span class="covered" title="13 out of 13 forms covered">
144&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:deirdre&nbsp;{:id&nbsp;:deidre
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
145&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:home&nbsp;:dundee&nbsp;:location&nbsp;:dundee&nbsp;:cash&nbsp;100&nbsp;:capacity&nbsp;10
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
146&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:known-prices&nbsp;{}
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
147&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:stock&nbsp;{}}
</span><br/>
<span class="covered" title="13 out of 13 forms covered">
148&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:euan&nbsp;{:id&nbsp;:euan
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
149&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:home&nbsp;:edinbirgh&nbsp;:location&nbsp;:edinburgh&nbsp;:cash&nbsp;100&nbsp;:capacity&nbsp;10
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
150&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:known-prices&nbsp;{}
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
151&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:stock&nbsp;{}}
</span><br/>
<span class="covered" title="13 out of 13 forms covered">
152&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:fiona&nbsp;{:id&nbsp;:fiona
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
153&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:home&nbsp;:falkirk&nbsp;:location&nbsp;:falkirk&nbsp;:cash&nbsp;100&nbsp;:capacity&nbsp;10
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
154&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:known-prices&nbsp;{}
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
155&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:stock&nbsp;{}}}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
156&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:routes
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
157&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;all&nbsp;routes&nbsp;can&nbsp;be&nbsp;traversed&nbsp;in&nbsp;either&nbsp;direction&nbsp;and&nbsp;are&nbsp;assumed&nbsp;to
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
158&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;take&nbsp;the&nbsp;same&nbsp;amount&nbsp;of&nbsp;time.
</span><br/>
<span class="covered" title="4 out of 4 forms covered">
159&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[[:aberdeen&nbsp;:buckie]
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
160&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[:aberdeen&nbsp;:dundee]
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
161&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[:callander&nbsp;:glasgow]
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
162&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[:dundee&nbsp;:callander]
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
163&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[:dundee&nbsp;:edinburgh]
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
164&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[:dundee&nbsp;:falkirk]
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
165&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[:edinburgh&nbsp;:falkirk]
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
166&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[:falkirk&nbsp;:glasgow]]
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
167&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:commodities
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
168&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;cost&nbsp;of&nbsp;commodities&nbsp;is&nbsp;expressed&nbsp;in&nbsp;person&#x2F;days;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
169&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;weight&nbsp;in&nbsp;packhorse&nbsp;loads.&nbsp;Transport&nbsp;in&nbsp;this&nbsp;model
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
170&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;is&nbsp;all&nbsp;overland;&nbsp;you&nbsp;don&#x27;t&nbsp;take&nbsp;bulk&nbsp;cargoes&nbsp;overland
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
171&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;in&nbsp;this&nbsp;period,&nbsp;it&#x27;s&nbsp;too&nbsp;expensive.
</span><br/>
<span class="covered" title="13 out of 13 forms covered">
172&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{:cloth&nbsp;{:id&nbsp;:cloth&nbsp;:cost&nbsp;1&nbsp;:weight&nbsp;0.25}
</span><br/>
<span class="covered" title="7 out of 7 forms covered">
173&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:fish&nbsp;{:id&nbsp;:fish&nbsp;:cost&nbsp;1&nbsp;:weight&nbsp;1}
</span><br/>
<span class="covered" title="7 out of 7 forms covered">
174&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:leather&nbsp;{:id&nbsp;:leather&nbsp;:cost&nbsp;1&nbsp;:weight&nbsp;0.5}
</span><br/>
<span class="covered" title="7 out of 7 forms covered">
175&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:whisky&nbsp;{:id&nbsp;:whisky&nbsp;:cost&nbsp;1&nbsp;:weight&nbsp;0.1}
</span><br/>
<span class="covered" title="7 out of 7 forms covered">
176&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:iron&nbsp;{:id&nbsp;:iron&nbsp;:cost&nbsp;1&nbsp;:weight&nbsp;10}}})
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
177&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
178&nbsp;&nbsp;(defn&nbsp;actual-price
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
179&nbsp;&nbsp;&nbsp;&nbsp;&quot;Find&nbsp;the&nbsp;actual&nbsp;current&nbsp;price&nbsp;of&nbsp;this&nbsp;`commodity`&nbsp;in&nbsp;this&nbsp;`city`&nbsp;given
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
180&nbsp;&nbsp;&nbsp;&nbsp;this&nbsp;`world`.&nbsp;**NOTE**&nbsp;that&nbsp;merchants&nbsp;can&nbsp;only&nbsp;know&nbsp;the&nbsp;actual&nbsp;prices&nbsp;in
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
181&nbsp;&nbsp;&nbsp;&nbsp;the&nbsp;city&nbsp;in&nbsp;which&nbsp;they&nbsp;are&nbsp;currently&nbsp;located.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
182&nbsp;&nbsp;&nbsp;&nbsp;[world&nbsp;commodity&nbsp;city]
</span><br/>
<span class="covered" title="9 out of 9 forms covered">
183&nbsp;&nbsp;&nbsp;&nbsp;(-&gt;&nbsp;world&nbsp;:cities&nbsp;city&nbsp;:prices&nbsp;commodity))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
184&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
185&nbsp;&nbsp;(defn&nbsp;run
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
186&nbsp;&nbsp;&nbsp;&nbsp;&quot;Return&nbsp;a&nbsp;world&nbsp;like&nbsp;this&nbsp;`world`&nbsp;with&nbsp;only&nbsp;the&nbsp;`:date`&nbsp;to&nbsp;this&nbsp;`date`
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
187&nbsp;&nbsp;&nbsp;&nbsp;(or&nbsp;id&nbsp;`date`&nbsp;not&nbsp;supplied,&nbsp;the&nbsp;current&nbsp;value&nbsp;incremented&nbsp;by&nbsp;one).&nbsp;For
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
188&nbsp;&nbsp;&nbsp;&nbsp;running&nbsp;other&nbsp;aspects&nbsp;of&nbsp;the&nbsp;simulation,&nbsp;see&nbsp;[[the-great-game.world.run]].&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
189&nbsp;&nbsp;&nbsp;&nbsp;([world]
</span><br/>
<span class="not-covered" title="0 out of 13 forms covered">
190&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(run&nbsp;world&nbsp;(inc&nbsp;(or&nbsp;(:date&nbsp;world)&nbsp;0))))
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
191&nbsp;&nbsp;&nbsp;&nbsp;([world&nbsp;date]
</span><br/>
<span class="not-covered" title="0 out of 5 forms covered">
192&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(assoc&nbsp;world&nbsp;:date&nbsp;date)))
</span><br/>
</body>
</html>

33
docs/codox/economy.html Normal file
View file

@ -0,0 +1,33 @@
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>Game world economy</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">The-great-game</span> <span class="project-version">0.1.0</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 current"><a href="economy.html"><div class="inner"><span>Game world economy</span></div></a></li><li class="depth-1 "><a href="intro.html"><div class="inner"><span>Introduction to the-great-game</span></div></a></li><li class="depth-1 "><a href="modelling_trading_cost_and_risk.html"><div class="inner"><span>Modelling trading cost and risk</span></div></a></li><li class="depth-1 "><a href="sexual-dimorphism.html"><div class="inner"><span>Sexual dimorphism</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>the-great-game</span></div></div></li><li class="depth-2 branch"><a href="the-great-game.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gossip</span></div></div></li><li class="depth-3"><a href="the-great-game.gossip.gossip.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gossip</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree" style="top: -52px;"><span class="top" style="height: 61px;"></span><span class="bottom"></span></span><span>merchants</span></div></div></li><li class="depth-3 branch"><a href="the-great-game.merchants.markets.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>markets</span></div></a></li><li class="depth-3 branch"><a href="the-great-game.merchants.merchant-utils.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>merchant-utils</span></div></a></li><li class="depth-3 branch"><a href="the-great-game.merchants.merchants.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>merchants</span></div></a></li><li class="depth-3 branch"><a href="the-great-game.merchants.planning.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>planning</span></div></a></li><li class="depth-3"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>strategies</span></div></div></li><li class="depth-4"><a href="the-great-game.merchants.strategies.simple.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>simple</span></div></a></li><li class="depth-2 branch"><a href="the-great-game.utils.html"><div class="inner"><span class="tree" style="top: -207px;"><span class="top" style="height: 216px;"></span><span class="bottom"></span></span><span>utils</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>world</span></div></div></li><li class="depth-3 branch"><a href="the-great-game.world.routes.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>routes</span></div></a></li><li class="depth-3 branch"><a href="the-great-game.world.run.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>run</span></div></a></li><li class="depth-3"><a href="the-great-game.world.world.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>world</span></div></a></li></ul></div><div class="document" id="content"><div class="doc"><div class="markdown"><h1><a href="#game-world-economy" name="game-world-economy"></a>Game world economy</h1>
<p>Broadly this essay extends ideas presented in <a href="https://blog.journeyman.cc/2013/07/populating-game-world.html">Populating a game world</a>, q.v.</p>
<h2><a href="#primary-producers" name="primary-producers"></a>Primary producers</h2>
<h3><a href="#herdsfolk" name="herdsfolk"></a>Herdsfolk</h3>
<p>Herdsfolk are nomadic; its reasonable to think theyll bring their herds to market, rather than selling it lots of tiny markets. So in the spring, shepherds will visit specific towns at the edge of open land, to hold a shearing festival/carnevale; and that both shepherds and cattle herders will visit towns on the edge of open land to sell fatstock in the autumn.</p>
<h3><a href="#miners" name="miners"></a>Miners</h3>
<p>Miners mine. Theyre settled, but theyre settled usually in specialist settlements at the location where the ore body is accessible, usually in mountenous territory. Theyll consume a lot of food, so there will be a local market for foodstuffs encouraging local farming. Different mines obviously mine different ores, but, for example, lead and silver are frequently found together.</p>
<h3><a href="#foresters" name="foresters"></a>Foresters</h3>
<p>Foresters are more or less settled at the edge of forests, at locations from which timber can be moved by navigable water; again in specialist settlements. In addition to timber, foresters hunt and produce both meat and furs, so have less need for other food producers locally.</p>
<h3><a href="#farmers" name="farmers"></a>Farmers</h3>
<p>Farmers are settled. Farmers occupy standard runrig plots, but because they dont employ journeymen or apprentices, and dont have workshops, the plots are mostly open with little building. Most farmers are mixed farmers, producing cereals, meat, eggs and milk. Some will be more specialist. Farm produce, taken broadly to include orchardsfolk, include:</p>
<ul>
<li>meat</li>
<li>milk and milk products</li>
<li>hides</li>
<li>eggs</li>
<li>cereals</li>
<li>root vegetables, onions, etc</li>
<li>peas and beans</li>
<li>leaf vegetables</li>
<li>fruits</li>
<li>fibres: linen, hemp and silk (from silk-moths in mulberry orchards)</li>
<li>possibly other stuff Ive forgotten.</li>
</ul>
<p>Farmers are all basically subsistence farmers, farming first to feed their own household and selling only surplus in the market.</p>
<h2><a href="#crafts" name="crafts"></a>Crafts</h2>
<p>Crafts generally process primary goods into secondary goods - whether intermediate stages or final consumer items. Some elite crafts deal with abstract primary goods like law and knowledge, and they may be seen as somewhat separate.</p>
<p>A master craftsperson occupies a standard runrig plot, much like a farmers plot. Like a farmer, a poor master crafter household will cultivate part of the plot to produce food for the house - at least grow vegetables and keep hens. However, as the crafter takes on apprentices and journeymen - and gets richer - more buildings will be required as accommodation, workshop space and materials stores.</p>
<p>Generally, primary goods arent transported over land - because overland transport is expensive, by the time theyve been transported theyre no longer low cost goods. So often the craftspeople who process primary produce into at least commodity intermediate forms will live close to the source of the primary goods.</p>
<p>So, for example, the town(s) where the shepherds hold their shearing fairs will tend to have a lot of weavers. While around mines there will be smelters producing ingots and bar stock to be marketed to smiths all over the place, there will also be smiths close to the mines producing commodity tools and weapons.</p>
<p>See the table in Populating a game world.</p></div></div></div></body></html>

3
docs/codox/index.html Normal file

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>Introduction to the-great-game</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">The-great-game</span> <span class="project-version">0.1.0-SNAPSHOT</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 current"><a href="intro.html"><div class="inner"><span>Introduction to the-great-game</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>the-great-game</span></div></div></li><li class="depth-2 branch"><a href="the-great-game.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gossip</span></div></div></li><li class="depth-3"><a href="the-great-game.gossip.gossip.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gossip</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree" style="top: -52px;"><span class="top" style="height: 61px;"></span><span class="bottom"></span></span><span>merchants</span></div></div></li><li class="depth-3 branch"><a href="the-great-game.merchants.markets.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>markets</span></div></a></li><li class="depth-3"><a href="the-great-game.merchants.merchants.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>merchants</span></div></a></li><li class="depth-2 branch"><a href="the-great-game.utils.html"><div class="inner"><span class="tree" style="top: -83px;"><span class="top" style="height: 92px;"></span><span class="bottom"></span></span><span>utils</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>world</span></div></div></li><li class="depth-3 branch"><a href="the-great-game.world.routes.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>routes</span></div></a></li><li class="depth-3 branch"><a href="the-great-game.world.run.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>run</span></div></a></li><li class="depth-3"><a href="the-great-game.world.world.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>world</span></div></a></li></ul></div><div class="document" id="content"><div class="doc"><div class="markdown"><h1><a href="#introduction-to-the-great-game" name="introduction-to-the-great-game"></a>Introduction to the-great-game</h1>
<html><head><meta charset="UTF-8" /><title>Introduction to the-great-game</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">The-great-game</span> <span class="project-version">0.1.0</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="economy.html"><div class="inner"><span>Game world economy</span></div></a></li><li class="depth-1 current"><a href="intro.html"><div class="inner"><span>Introduction to the-great-game</span></div></a></li><li class="depth-1 "><a href="modelling_trading_cost_and_risk.html"><div class="inner"><span>Modelling trading cost and risk</span></div></a></li><li class="depth-1 "><a href="sexual-dimorphism.html"><div class="inner"><span>Sexual dimorphism</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>the-great-game</span></div></div></li><li class="depth-2 branch"><a href="the-great-game.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gossip</span></div></div></li><li class="depth-3"><a href="the-great-game.gossip.gossip.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gossip</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree" style="top: -52px;"><span class="top" style="height: 61px;"></span><span class="bottom"></span></span><span>merchants</span></div></div></li><li class="depth-3 branch"><a href="the-great-game.merchants.markets.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>markets</span></div></a></li><li class="depth-3 branch"><a href="the-great-game.merchants.merchant-utils.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>merchant-utils</span></div></a></li><li class="depth-3 branch"><a href="the-great-game.merchants.merchants.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>merchants</span></div></a></li><li class="depth-3 branch"><a href="the-great-game.merchants.planning.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>planning</span></div></a></li><li class="depth-3"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>strategies</span></div></div></li><li class="depth-4"><a href="the-great-game.merchants.strategies.simple.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>simple</span></div></a></li><li class="depth-2 branch"><a href="the-great-game.utils.html"><div class="inner"><span class="tree" style="top: -207px;"><span class="top" style="height: 216px;"></span><span class="bottom"></span></span><span>utils</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>world</span></div></div></li><li class="depth-3 branch"><a href="the-great-game.world.routes.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>routes</span></div></a></li><li class="depth-3 branch"><a href="the-great-game.world.run.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>run</span></div></a></li><li class="depth-3"><a href="the-great-game.world.world.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>world</span></div></a></li></ul></div><div class="document" id="content"><div class="doc"><div class="markdown"><h1><a href="#introduction-to-the-great-game" name="introduction-to-the-great-game"></a>Introduction to the-great-game</h1>
<h1><a href="#the-great-game" name="the-great-game"></a>The Great Game</h1>
<p>In this essay Im going to try to pull together a number of my architectural ideas about the Great Game which I know Im never actually going to build - because its vastly too big for any one person to build - into one overall vision.</p>
<p>So, firstly, how does one characterise this game?</p>

View file

@ -0,0 +1,7 @@
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>Modelling trading cost and risk</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">The-great-game</span> <span class="project-version">0.1.0</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="economy.html"><div class="inner"><span>Game world economy</span></div></a></li><li class="depth-1 "><a href="intro.html"><div class="inner"><span>Introduction to the-great-game</span></div></a></li><li class="depth-1 current"><a href="modelling_trading_cost_and_risk.html"><div class="inner"><span>Modelling trading cost and risk</span></div></a></li><li class="depth-1 "><a href="sexual-dimorphism.html"><div class="inner"><span>Sexual dimorphism</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>the-great-game</span></div></div></li><li class="depth-2 branch"><a href="the-great-game.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gossip</span></div></div></li><li class="depth-3"><a href="the-great-game.gossip.gossip.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gossip</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree" style="top: -52px;"><span class="top" style="height: 61px;"></span><span class="bottom"></span></span><span>merchants</span></div></div></li><li class="depth-3 branch"><a href="the-great-game.merchants.markets.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>markets</span></div></a></li><li class="depth-3 branch"><a href="the-great-game.merchants.merchant-utils.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>merchant-utils</span></div></a></li><li class="depth-3 branch"><a href="the-great-game.merchants.merchants.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>merchants</span></div></a></li><li class="depth-3 branch"><a href="the-great-game.merchants.planning.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>planning</span></div></a></li><li class="depth-3"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>strategies</span></div></div></li><li class="depth-4"><a href="the-great-game.merchants.strategies.simple.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>simple</span></div></a></li><li class="depth-2 branch"><a href="the-great-game.utils.html"><div class="inner"><span class="tree" style="top: -207px;"><span class="top" style="height: 216px;"></span><span class="bottom"></span></span><span>utils</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>world</span></div></div></li><li class="depth-3 branch"><a href="the-great-game.world.routes.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>routes</span></div></a></li><li class="depth-3 branch"><a href="the-great-game.world.run.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>run</span></div></a></li><li class="depth-3"><a href="the-great-game.world.world.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>world</span></div></a></li></ul></div><div class="document" id="content"><div class="doc"><div class="markdown"><h1><a href="#modelling-trading-cost-and-risk" name="modelling-trading-cost-and-risk"></a>Modelling trading cost and risk</h1>
<p>In a dynamic pre-firearms world with many small states and contested regions, trade is not going to be straightforward. Not only will different routes have different physical characteristics - more or less mountainous, more or fewer unbridged river crossings - they will also have different political characteristics: more of less taxed, more or less effectively policed.</p>
<p>Raids by outlaws are expected to be part of the game economy. News of raids are the sort of things which may propagate through the <a href="null">gossip</a> system. So are changes in taxation regime. Obviously, knowledge items can affect merchants trading strategy; in existing prototype code, individual merchants already each keep their own cache of known historical prices, and exchange historical price data with one another; and use this price data to select trades to make.</p>
<p>So: to what extent is it worth modelling the spread of knowledge of trade cost and risk?</p>
<p>Obviously the more we model, the more compute power modelling consumes. If the core objective is a Role Playing Games as currently understood, then there is no need to model very complex trade risk assessment behaviour.</p></div></div></div></body></html>

View file

@ -0,0 +1,28 @@
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>Sexual dimorphism</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">The-great-game</span> <span class="project-version">0.1.0</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="economy.html"><div class="inner"><span>Game world economy</span></div></a></li><li class="depth-1 "><a href="intro.html"><div class="inner"><span>Introduction to the-great-game</span></div></a></li><li class="depth-1 "><a href="modelling_trading_cost_and_risk.html"><div class="inner"><span>Modelling trading cost and risk</span></div></a></li><li class="depth-1 current"><a href="sexual-dimorphism.html"><div class="inner"><span>Sexual dimorphism</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>the-great-game</span></div></div></li><li class="depth-2 branch"><a href="the-great-game.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gossip</span></div></div></li><li class="depth-3"><a href="the-great-game.gossip.gossip.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gossip</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree" style="top: -52px;"><span class="top" style="height: 61px;"></span><span class="bottom"></span></span><span>merchants</span></div></div></li><li class="depth-3 branch"><a href="the-great-game.merchants.markets.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>markets</span></div></a></li><li class="depth-3 branch"><a href="the-great-game.merchants.merchant-utils.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>merchant-utils</span></div></a></li><li class="depth-3 branch"><a href="the-great-game.merchants.merchants.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>merchants</span></div></a></li><li class="depth-3 branch"><a href="the-great-game.merchants.planning.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>planning</span></div></a></li><li class="depth-3"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>strategies</span></div></div></li><li class="depth-4"><a href="the-great-game.merchants.strategies.simple.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>simple</span></div></a></li><li class="depth-2 branch"><a href="the-great-game.utils.html"><div class="inner"><span class="tree" style="top: -207px;"><span class="top" style="height: 216px;"></span><span class="bottom"></span></span><span>utils</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>world</span></div></div></li><li class="depth-3 branch"><a href="the-great-game.world.routes.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>routes</span></div></a></li><li class="depth-3 branch"><a href="the-great-game.world.run.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>run</span></div></a></li><li class="depth-3"><a href="the-great-game.world.world.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>world</span></div></a></li></ul></div><div class="document" id="content"><div class="doc"><div class="markdown"><h1><a href="#sexual-dimorphism" name="sexual-dimorphism"></a>Sexual dimorphism</h1>
<p>This essay is going to upset a lot of people, so lets start with a statement of what it is about: it is an attempt to describe the systematically different behaviours of men and women, in sufficient detail that this can be represented by agents in a game world. Its trying to allow as broad as possible a range of cultures to be represented, so when Im talking about what I consider to be behaviours of particular cultures, Ill say that.</p>
<p>Of course, Im writing this from the view point of an old white male. Its not possible to write about these things from a totally neutral viewpoint, and every one of us will have prejudices.</p>
<p>OK? Lets start.</p>
<p>When a man and a woman have sex, theres a non-zero chance that the woman will get pregnant. Theres a zero chance that the male will get pregnant.</p>
<p>A woman can typically give birth to of the order of twelve children in the course of her life, and each childbirth involves a non-zero risk of death. If modelling the sort of bronze-age-to-late-medieval cultures Im generally considering, there are no available reliable methods of contraception, although their may be, for example, known spermicidal or abortifacient spells or potions. If its abortifacient, thats pretty unpleasant for the woman, too.</p>
<p>Children, especially when young, are very vulnerable and need protection. Children with good protection are much more likely to survive to adulthood. Raising children involves a fair amount of work.</p>
<p>For all sorts of reasons, some of which are clearly cultural but others of which are fundamental, its much easier for men to walk away from responsibility for their children than it is for women. For example, considering a pre-modern world, women would always know for certain which children were theirs, and men would not.</p>
<p>For a woman, consequently, the best breeding strategy is to have sex only with men who will be good fathers, where there are three essential parameters to “good fathers”:</p>
<ol>
<li>Desirable genetic traits;</li>
<li>Preparedness to stick around and share the work;</li>
<li>Ability to provide and protect.</li>
</ol>
<p>The essential trade-off in the traditional western marriage is that the man gets to have sex, and the woman gets to have protection for her progeny.</p>
<p>Another significant point is that womens ability to bear children ceases at a much younger age than mens ability to father them.</p>
<h2><a href="#why-have-sex-at-all-" name="why-have-sex-at-all-"></a>Why have sex at all?</h2>
<p>If a character has having children - the <strong>Ancestor</strong> aspiration, in my typology - as their key aim, then they will want to have sex. But to have children in this sense is to have acknowledged children, so while a male character may be motivated to have multiple female partners, he will never the less have some degree of long term committment to them, and will want both to feel confident that the children are his and to be recognised by their father.</p>
<p>From the point of view of seeking to become an Ancestor, there is little benefit to the woman in having multiple partners, except in very harsh environments. It will be easier to give one partner confidence that all your children are his, and while a man can increase his number of potential progeny by having multiple wives, mistresses or other classes of long-term female sexual partners, a woman cannot.</p>
<h2><a href="#why-have-children-" name="why-have-children-"></a>Why have children?</h2>
<p>In modern Scotland, I have met a lot of women with a strong drive to have children for the sake of having children, where the best explanation they could give is that its instinctual; it may be so. But beyond that, in many cultures children provide their (acknowledged) parents with care and security in their old age, may tend their graves and perform belief-related services after they die, and carry on their name and their stories into the future.</p>
<p>Not everyone wants to have children; in thinking about the driving aspirations of game characters, I view having children one of six potential key aspirations.</p>
<h2><a href="#why-else-have-sex-" name="why-else-have-sex-"></a>Why else have sex?</h2>
<p>Sex, done right, is an extremely pleasant pastime. Sex can also be used to create and maintain bonds of committment, to demonstrate social status, to defuse tense situations, and transactionally in many ways, both formal and informal.</p>
<p>For women, sex with other women carries with it no risk of pregnancy, so can be enjoyed or used for any of these purposes in very much the same way as it can by men; in other words, particularly for women, homosexual sex can be more lighthearted and carefree than heterosexual sex. To what extend our notions of homosexuality and heterosexuality are cultural I simply dont know. But because no children will result, a woman can afford to be more promiscuous with other women than she can with men.</p>
<h2><a href="#how-does-this-impact-on" name="how-does-this-impact-on"></a>How does this impact on</h2></div></div></div></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

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,3 +0,0 @@
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>the-great-game.core documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">The-great-game</span> <span class="project-version">0.1.0-SNAPSHOT</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="intro.html"><div class="inner"><span>Introduction to the-great-game</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>the-great-game</span></div></div></li><li class="depth-2 branch current"><a href="the-great-game.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gossip</span></div></div></li><li class="depth-3"><a href="the-great-game.gossip.gossip.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gossip</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree" style="top: -52px;"><span class="top" style="height: 61px;"></span><span class="bottom"></span></span><span>merchants</span></div></div></li><li class="depth-3 branch"><a href="the-great-game.merchants.markets.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>markets</span></div></a></li><li class="depth-3"><a href="the-great-game.merchants.merchants.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>merchants</span></div></a></li><li class="depth-2 branch"><a href="the-great-game.utils.html"><div class="inner"><span class="tree" style="top: -83px;"><span class="top" style="height: 92px;"></span><span class="bottom"></span></span><span>utils</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>world</span></div></div></li><li class="depth-3 branch"><a href="the-great-game.world.routes.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>routes</span></div></a></li><li class="depth-3 branch"><a href="the-great-game.world.run.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>run</span></div></a></li><li class="depth-3"><a href="the-great-game.world.world.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>world</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="the-great-game.core.html#var-foo"><div class="inner"><span>foo</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">the-great-game.core</h1><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="public anchor" id="var-foo"><h3>foo</h3><div class="usage"><code>(foo x)</code></div><div class="doc"><div class="markdown"><p>I dont do a whole lot.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/core.clj#L3">view source</a></div></div></div></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

File diff suppressed because one or more lines are too long

View file

@ -1,3 +0,0 @@
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>the-great-game.world.run documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">The-great-game</span> <span class="project-version">0.1.0-SNAPSHOT</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="intro.html"><div class="inner"><span>Introduction to the-great-game</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>the-great-game</span></div></div></li><li class="depth-2 branch"><a href="the-great-game.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gossip</span></div></div></li><li class="depth-3"><a href="the-great-game.gossip.gossip.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>gossip</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree" style="top: -52px;"><span class="top" style="height: 61px;"></span><span class="bottom"></span></span><span>merchants</span></div></div></li><li class="depth-3 branch"><a href="the-great-game.merchants.markets.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>markets</span></div></a></li><li class="depth-3"><a href="the-great-game.merchants.merchants.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>merchants</span></div></a></li><li class="depth-2 branch"><a href="the-great-game.utils.html"><div class="inner"><span class="tree" style="top: -83px;"><span class="top" style="height: 92px;"></span><span class="bottom"></span></span><span>utils</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>world</span></div></div></li><li class="depth-3 branch"><a href="the-great-game.world.routes.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>routes</span></div></a></li><li class="depth-3 branch current"><a href="the-great-game.world.run.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>run</span></div></a></li><li class="depth-3"><a href="the-great-game.world.world.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>world</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="the-great-game.world.run.html#var-run"><div class="inner"><span>run</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">the-great-game.world.run</h1><div class="doc"><div class="markdown"><p>Run the whole simulation</p></div></div><div class="public anchor" id="var-run"><h3>run</h3><div class="usage"><code>(run world)</code></div><div class="doc"><div class="markdown"><p>The pipeline to run the simulation each game day. Returns a world like this world, with all the various active elements updated.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/world/run.clj#L10">view source</a></div></div></div></body></html>

File diff suppressed because one or more lines are too long

View file

@ -1,13 +1,28 @@
(defproject the-great-game "0.1.0-SNAPSHOT"
(defproject the-great-game "0.1.1-SNAPSHOT"
:cloverage {:output "docs/cloverage"}
:codox {:metadata {:doc "**TODO**: write docs"
:doc/format :markdown}
:output-path "docs"
:output-path "docs/codox"
:source-uri "https://github.com/simon-brooke/the-great-game/blob/master/{filepath}#L{line}"}
:dependencies [[org.clojure/clojure "1.8.0"]
[environ "1.1.0"]
[com.taoensso/timbre "4.10.0"]]
:description "Prototype code towards the great game I've been writing about for ten years, and know I will never finish."
:license {:name "GNU General Public License,version 2.0 or (at your option) any later version"
:url "https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html"}
:plugins [[lein-codox "0.10.3"]]
:plugins [[lein-cloverage "1.1.1"]
[lein-codox "0.10.7"]]
:release-tasks [["vcs" "assert-committed"]
["change" "version" "leiningen.release/bump-version" "release"]
["vcs" "commit"]
["vcs" "tag" "v." "--no-sign"]
["clean"]
["codox"]
["cloverage"]
["uberjar"]
["change" "version" "leiningen.release/bump-version"]
["vcs" "commit"]]
:url "https://github.com/simon-brooke/the-great-game"
)

View file

@ -49,9 +49,9 @@
[gossip world new-location]
(let [id (cond
(map? gossip)
(:id (-> world :gossipe gossip)
(-> world :gossips gossip :id)
(keyword? gossip)
gossip))]
gossip)]
(deep-merge
world
{:gossips

View file

@ -1,8 +1,7 @@
(ns the-great-game.merchants.markets
"Adjusting quantities and prices in markets."
(:require [taoensso.timbre :as l :refer [info error]]
[the-great-game.utils :refer [deep-merge]]
[the-great-game.world.world :refer [actual-price default-world]]))
[the-great-game.utils :refer [deep-merge]]))
(defn new-price
"If `stock` is greater than the maximum of `supply` and `demand`, then
@ -30,18 +29,23 @@
su (or (-> c :supplies commodity) 0)
decrement (min st d)
increment (cond
;; if its profitable to produce this commodity, the craftspeople
;; of the city will do so.
;; if we've two turns' production of this commodity in
;; stock, halt production
(> st (* su 2))
0
;; if it is profitable to produce this commodity, the
;; craftspeople of the city will do so.
(> p 1) su
;; otherwise, if there isn't a turn's production in stock, top up
;; the stock, so that there's something for incoming merchants to
;; buy
;; otherwise, if there isn't a turn's production in
;; stock, top up the stock, so that there's something for
;; incoming merchants to buy
(> su st)
(- su st)
true 0)
:else
0)
n (new-price p st su d)]
(if
(not (= p n))
(not= p n)
(l/info "Price of" commodity "at" id "has changed from" (float p) "to" (float n)))
{:cities {id
{:stock

View file

@ -0,0 +1,92 @@
(ns the-great-game.merchants.merchant-utils
"Useful functions for doing low-level things with merchants.")
(defn expected-price
"Find the price anticipated, given this `world`, by this `merchant` for
this `commodity` in this `city`. If no information, assume 1.
`merchant` should be passed as a map, `commodity` and `city` should be passed as keywords."
[merchant commodity city]
(or
(:price
(last
(sort-by
:date
(-> merchant :known-prices city commodity))))
1))
(defn burden
"The total weight of the current cargo carried by this `merchant` in this
`world`."
[merchant world]
(let [m (cond
(keyword? merchant)
(-> world :merchants merchant)
(map? merchant)
merchant)
cargo (:stock m)]
(reduce
+
0
(map
#(* (cargo %) (-> world :commodities % :weight))
(keys cargo)))))
(defn can-carry
"Return the number of units of this `commodity` which this `merchant`
can carry in this `world`, given their current burden."
[merchant world commodity]
(let [m (cond
(keyword? merchant)
(-> world :merchants merchant)
(map? merchant)
merchant)]
(quot
(- (:capacity m) (burden m world))
(-> world :commodities commodity :weight))))
(defn can-afford
"Return the number of units of this `commodity` which this `merchant`
can afford to buy in this `world`."
[merchant world commodity]
(let [m (cond
(keyword? merchant)
(-> world :merchants merchant)
(map? merchant)
merchant)
l (:location m)]
(quot
(:cash m)
(-> world :cities l :prices commodity))))
(defn add-stock
"Where `a` and `b` are both maps all of whose values are numbers, return
a map whose keys are a union of the keys of `a` and `b` and whose values
are the sums of their respective values."
[a b]
(reduce
merge
a
(map
#(hash-map % (+ (or (a %) 0) (or (b %) 0)))
(keys b))))
(defn add-known-prices
"Add the current prices at this `merchant`'s location in the `world`
to a new cacke of known prices, and return it."
[merchant world]
(let [m (cond
(keyword? merchant)
(-> world :merchants merchant)
(map? merchant)
merchant)
k (:known-prices m)
l (:location m)
d (:date world)
p (-> world :cities l :prices)]
(reduce
merge
k
(map
#(hash-map % (apply vector cons {:price (p %) :date d} (k %)))
(-> world :commodities keys)))))

View file

@ -1,423 +1,12 @@
(ns the-great-game.merchants.merchants
"Trade planning for merchants, primarily."
(:require [taoensso.timbre :as l :refer [info error]]
(:require [taoensso.timbre :as l :refer [info error spy]]
[the-great-game.utils :refer [deep-merge]]
[the-great-game.gossip.gossip :refer [move-gossip]]
[the-great-game.world.routes :refer [find-route]]
[the-great-game.world.world :refer [actual-price default-world]]))
[the-great-game.merchants.strategies.simple :refer [move-merchant]]))
(defn expected-price
"Find the price anticipated, given this `world`, by this `merchant` for
this `commodity` in this `city`. If no information, assume 1.
`merchant` should be passed as a map, `commodity` and `city` should be passed as keywords."
[merchant commodity city]
(or
(:price
(last
(sort-by
:date
(-> merchant :known-prices city commodity))))
1))
(defn burden
"The total weight of the current cargo carried by this `merchant` in this
`world`."
[merchant world]
(let [m (cond
(keyword? merchant)
(-> world :merchants merchant)
(map? merchant)
merchant)
cargo (-> m :stock)]
(reduce
+
0
(map
#(* (cargo %) (-> world :commodities % :weight))
(keys cargo)))))
(defn make-target-filter
"Construct a filter which, when applied to a list of maps,
will pass those which match these `targets`, where each target
is a tuple [key value]."
;; TODO: this would probably be more elegant as a macro
[targets]
(eval
(list
'fn
(vector 'plan)
(cons
'and
(map
#(list
'=
(list (first %) 'plan)
(nth % 1))
targets)))))
(defn generate-trade-plans
"Generate all possible trade plans for this `merchant` and this `commodity`
in this `world`.
Returned plans are maps with keys:
* :merchant - the id of the `merchant` for whom the plan was created;
* :origin - the city from which the trade starts;
* :destination - the city to which the trade is planned;
* :commodity - the `commodity` to be carried;
* :buy-price - the price at which that `commodity` can be bought;
* :expected-price - the price at which the `merchant` anticipates
that `commodity` can be sold;
* :distance - the number of stages in the planned journey
* :dist-to-home - the distance from `destination` to the `merchant`'s
home city."
[merchant world commodity]
(let [m (cond
(keyword? merchant)
(-> world :merchants merchant)
(map? merchant)
merchant)
origin (-> m :location)]
(map
#(hash-map
:merchant (-> m :id)
:origin origin
:destination %
:commodity commodity
:buy-price (actual-price world commodity origin)
:expected-price (expected-price
m
commodity
%)
:distance (count
(find-route world origin %))
:dist-to-home (count
(find-route
world
(:home m)
%)))
(remove #(= % origin) (keys (-> world :cities))))))
(defn nearest-with-targets
"Return the distance to the nearest destination among those of these
`plans` which match these `targets`. Plans are expected to be plans
as returned by `generate-trade-plans`, q.v.; `targets` are expected to be
as accepted by `make-target-filter`, q.v."
[plans targets]
(apply
min
(map
:distance
(filter
(make-target-filter targets)
plans))))
(defn plan-trade
"Find the best destination in this `world` for this `commodity` given this
`merchant` and this `origin`. If two cities are anticipated to offer the
same price, the nearer should be preferred; if two are equally distant, the
ones nearer to the merchant's home should be preferred.
`merchant` may be passed as a map or a keyword; `commodity` should be
passed as a keyword.
The returned plan is a map with keys:
* :merchant - the id of the `merchant` for whom the plan was created;
* :origin - the city from which the trade starts;
* :destination - the city to which the trade is planned;
* :commodity - the `commodity` to be carried;
* :buy-price - the price at which that `commodity` can be bought;
* :expected-price - the price at which the `merchant` anticipates
that `commodity` can be sold;
* :distance - the number of stages in the planned journey
* :dist-to-home - the distance from `destination` to the `merchant`'s
home city."
[merchant world commodity]
(let [plans (generate-trade-plans merchant world commodity)
best-prices (filter
(make-target-filter
[[:expected-price
(apply
max
(filter number? (map :expected-price plans)))]])
plans)]
(first
(sort-by
;; all other things being equal, a merchant would prefer to end closer
;; to home.
#(- 0 (:dist-to-home %))
;; a merchant will seek the best price, but won't go further than
;; needed to get it.
(filter
(make-target-filter
[[:distance
(apply min (filter number? (map :distance best-prices)))]])
best-prices)))))
(defn can-carry
"Return the number of units of this `commodity` which this `merchant`
can carry in this `world`, given their current burden."
[merchant world commodity]
(let [m (cond
(keyword? merchant)
(-> world :merchants merchant)
(map? merchant)
merchant)]
(quot
(- (:capacity m) (burden m world))
(-> world :commodities commodity :weight))))
(defn can-afford
"Return the number of units of this `commodity` which this `merchant`
can afford to buy in this `world`."
[merchant world commodity]
(let [m (cond
(keyword? merchant)
(-> world :merchants merchant)
(map? merchant)
merchant)
l (:location m)]
(quot
(-> m :cash)
(-> world :cities l :prices commodity))))
(defn augment-plan
"Augment this `plan` constructed in this `world` for this `merchant` with
the `:quantity` of goods which should be bought and the `:expected-profit`
of the trade.
Returns the augmented plan."
[merchant world plan]
(let [c (:commodity plan)
o (:origin plan)
q (min
(or
(-> world :cities o :stock c)
0)
(can-carry merchant world c)
(can-afford merchant world c))
p (* q (- (:expected-price plan) (:buy-price plan)))]
(assoc plan :quantity q :expected-profit p)))
;; (-> default-world :cities :buckie :stock :iron)
;; (burden :fiona default-world)
;; (-> default-world :commodities :iron :weight)
;; (quot 0 10)
(defn select-cargo
"A `merchant`, in a given location in a `world`, will choose to buy a cargo
within the limit they are capable of carrying, which they can anticipate
selling for a profit at a destination."
[merchant world]
(let [m (cond
(keyword? merchant)
(-> world :merchants merchant)
(map? merchant)
merchant)
origin (-> m :location)
available (-> world :cities origin :stock)
plans (map
#(augment-plan
m
world
(plan-trade m world %))
(filter
#(let [q (-> world :cities origin :stock %)]
(and (number? q) (> q 0)))
(keys available)))]
(if
(not (empty? plans))
(first
(sort-by
#(- 0 (:dist-to-home %))
(filter
(make-target-filter
[[:expected-profit
(apply max (filter number? (map :expected-profit plans)))]])
plans))))))
(defn add-stock
"Where `a` and `b` are both maps all of whose values are numbers, return
a map whose keys are a union of the keys of `a` and `b` and whose values
are the sums of their respective values."
[a b]
(reduce
merge
a
(map
#(hash-map % (+ (or (a %) 0) (or (b %) 0)))
(keys b))))
(defn add-known-prices
"Add the current prices at this `merchant`'s location in the `world`
to a new cacke of known prices, and return it."
[merchant world]
(let [m (cond
(keyword? merchant)
(-> world :merchants merchant)
(map? merchant)
merchant)
k (:known-prices m)
l (:location m)
d (:date world)
p (-> world :cities l :prices)]
(reduce
merge
k
(map
#(hash-map % (apply vector cons {:price (p %) :date d} (k %)))
(-> world :commodities keys)))))
;;; Right, from here on in we're actually moving things in the world, so
;;; functions generally return modified partial worlds.
(defn plan-and-buy
"Return a world like this `world`, in which this `merchant` has planned
a new trade, and bought appropriate stock for it. If no profitable trade
can be planned, the merchant is simply moved towards their home."
[merchant world]
(deep-merge
world
(let [m (cond
(keyword? merchant)
(-> world :merchants merchant)
(map? merchant)
merchant)
id (:id m)
location (:location m)
market (-> world :cities location)
plan (select-cargo merchant world)]
(cond
(not (empty? plan))
(let
[c (:commodity plan)
p (* (:quantity plan) (:buy-price plan))
q (:quantity plan)]
(l/info "Merchant " id " bought " q " units of " c " at " location " for " p)
{:merchants
{id
{:stock (add-stock (:stock m) {c q})
:cash (- (:cash m) p)
:known-prices (add-known-prices m world)}}
:cities
{location
{:stock (assoc (:stock market) c (- (-> market :stock c) q))
:cash (+ (:cash market) p)}}})
;; if no plan, then if at home stay put
(= (:location m) (:home m))
(do
(l/info "Merchant " id " remains at home in " location)
{})
;; else move towards home
true
(let [route (find-route world location (:home m))
next-location (nth route 1)]
(l/info "No trade possible at " location "; merchant " id " moves to " next-location)
(merge
{:merchants
{id
{:location next-location}}}
(move-gossip id world next-location)))))))
(defn re-plan
"Having failed to sell a cargo at current location, re-plan a route to
sell the current cargo. Returns a revised world."
[merchant world]
(let [m (cond
(keyword? merchant)
(-> world :merchants merchant)
(map? merchant)
merchant)
id (:id m)
location (:location m)
plan (augment-plan m world (plan-trade m world (-> m :plan :commodity)))]
(deep-merge
world
{:merchants
{id
{:plan plan}}})))
(defn sell-and-buy
"Return a new world like this `world`, in which this `merchant` has sold
their current stock in their current location, and planned a new trade, and
bought appropriate stock for it."
;; TODO: this either sells the entire cargo, or, if the market can't afford
;; it, none of it. And it does not cope with selling different commodities
;; in different markets.
[merchant world]
(let [m (cond
(keyword? merchant)
(-> world :merchants merchant)
(map? merchant)
merchant)
id (:id m)
location (:location m)
market (-> world :cities location)
stock-value (reduce
+
(map
#(* (-> m :stock %) (-> market :prices m))
(keys (:stock m))))]
(if
(>= (:cash market) stock-value)
(do
(l/info
(apply str (flatten (list "Merchant " id " sells " (:stock m) " at " location " for " stock-value))))
(plan-and-buy
merchant
(deep-merge
world
{:merchants
{id
{:stock {}
:cash (+ (:cash m) stock-value)
:known-prices (add-known-prices m world)}}
:cities
{location
{:stock (add-stock (:stock m) (:stock market))
:cash (- (:cash market) stock-value)}}})))
;; else
(re-plan merchant world))))
(defn move-merchant
"Handle general en route movement of this `merchant` in this `world`."
[merchant world]
(let [m (cond
(keyword? merchant)
(-> world :merchants merchant)
(map? merchant)
merchant)
id (:id m)
at-destination? (and (:plan m) (= (:location m) (-> m :plan :destination)))
plan (:plan m)
next-location (if plan
(nth 1 (find-route world (:location m) (:destination plan)))
(:location m))]
(l/info "Merchant " id " has moved from " (:location m) " to " next-location)
(cond
;; if the merchant is at the destination of their current plan
;; sell all cargo and repurchase.
at-destination?
(sell-and-buy merchant world plan)
;; if they don't have a plan, seek to create one
(nil? (:plan m))
(plan-and-buy merchant world)
;; otherwise, move one step towards their destination
true
(deep-merge
{:merchants
{id
{:location next-location
:known-prices (add-known-prices m world)}}}
(move-gossip id world next-location)))))
(defn run
"Return a world like this `world`, but with each merchant moved."
"Return a partial world based on this `world`, but with each merchant moved."
[world]
(try
(reduce
@ -425,7 +14,10 @@
world
(map
#(try
(move-merchant % world)
(let [move-fn (or
(-> world :merchants % :move-fn)
move-merchant)]
(apply move-fn (list % world)))
(catch Exception any
(l/error any "Failure while moving merchant " %)
{}))

View file

@ -0,0 +1,159 @@
(ns the-great-game.merchants.planning
"Trade planning for merchants, primarily. This follows a simple-minded
generate-and-test strategy and currently generates plans for all possible
routes from the current location. This may not scale. Also, routes do not
currently have cost or risk associated with them."
(:require [the-great-game.utils :refer [deep-merge make-target-filter]]
[the-great-game.merchants.merchant-utils :refer :all]
[the-great-game.world.routes :refer [find-route]]
[the-great-game.world.world :refer [actual-price default-world]]))
(defn generate-trade-plans
"Generate all possible trade plans for this `merchant` and this `commodity`
in this `world`.
Returned plans are maps with keys:
* :merchant - the id of the `merchant` for whom the plan was created;
* :origin - the city from which the trade starts;
* :destination - the city to which the trade is planned;
* :commodity - the `commodity` to be carried;
* :buy-price - the price at which that `commodity` can be bought;
* :expected-price - the price at which the `merchant` anticipates
that `commodity` can be sold;
* :distance - the number of stages in the planned journey
* :dist-to-home - the distance from `destination` to the `merchant`'s
home city."
[merchant world commodity]
(let [m (cond
(keyword? merchant)
(-> world :merchants merchant)
(map? merchant)
merchant)
origin (:location m)]
(map
#(hash-map
:merchant (:id m)
:origin origin
:destination %
:commodity commodity
:buy-price (actual-price world commodity origin)
:expected-price (expected-price
m
commodity
%)
:distance (count
(find-route world origin %))
:dist-to-home (count
(find-route
world
(:home m)
%)))
(remove #(= % origin) (-> world :cities keys)))))
(defn nearest-with-targets
"Return the distance to the nearest destination among those of these
`plans` which match these `targets`. Plans are expected to be plans
as returned by `generate-trade-plans`, q.v.; `targets` are expected to be
as accepted by `make-target-filter`, q.v."
[plans targets]
(apply
min
(map
:distance
(filter
(make-target-filter targets)
plans))))
(defn plan-trade
"Find the best destination in this `world` for this `commodity` given this
`merchant` and this `origin`. If two cities are anticipated to offer the
same price, the nearer should be preferred; if two are equally distant, the
ones nearer to the merchant's home should be preferred.
`merchant` may be passed as a map or a keyword; `commodity` should be
passed as a keyword.
The returned plan is a map with keys:
* :merchant - the id of the `merchant` for whom the plan was created;
* :origin - the city from which the trade starts;
* :destination - the city to which the trade is planned;
* :commodity - the `commodity` to be carried;
* :buy-price - the price at which that `commodity` can be bought;
* :expected-price - the price at which the `merchant` anticipates
that `commodity` can be sold;
* :distance - the number of stages in the planned journey
* :dist-to-home - the distance from `destination` to the `merchant`'s
home city."
[merchant world commodity]
(let [plans (generate-trade-plans merchant world commodity)
best-prices (filter
(make-target-filter
[[:expected-price
(apply
max
(filter number? (map :expected-price plans)))]])
plans)]
(first
(sort-by
;; all other things being equal, a merchant would prefer to end closer
;; to home.
#(- 0 (:dist-to-home %))
;; a merchant will seek the best price, but won't go further than
;; needed to get it.
(filter
(make-target-filter
[[:distance
(apply min (filter number? (map :distance best-prices)))]])
best-prices)))))
(defn augment-plan
"Augment this `plan` constructed in this `world` for this `merchant` with
the `:quantity` of goods which should be bought and the `:expected-profit`
of the trade.
Returns the augmented plan."
[merchant world plan]
(let [c (:commodity plan)
o (:origin plan)
q (min
(or
(-> world :cities o :stock c)
0)
(can-carry merchant world c)
(can-afford merchant world c))
p (* q (- (:expected-price plan) (:buy-price plan)))]
(assoc plan :quantity q :expected-profit p)))
(defn select-cargo
"A `merchant`, in a given location in a `world`, will choose to buy a cargo
within the limit they are capable of carrying, which they can anticipate
selling for a profit at a destination."
[merchant world]
(let [m (cond
(keyword? merchant)
(-> world :merchants merchant)
(map? merchant)
merchant)
origin (:location m)
available (-> world :cities origin :stock)
plans (map
#(augment-plan
m
world
(plan-trade m world %))
(filter
#(let [q (-> world :cities origin :stock %)]
(and (number? q) (pos? q)))
(keys available)))]
(if
(not (empty? plans))
(first
(sort-by
#(- 0 (:dist-to-home %))
(filter
(make-target-filter
[[:expected-profit
(apply max (filter number? (map :expected-profit plans)))]])
plans))))))

View file

@ -0,0 +1,173 @@
(ns the-great-game.merchants.strategies.simple
"Default trading strategy for merchants.
The simple strategy buys a single product in the local market if there is
one which can be traded profitably, trades it to the chosen target market,
and sells it there. If there is no commodity locally which can be traded
profitably, moves towards home with no cargo. If at home and no commodity
can be traded profitably, does not move."
(:require [taoensso.timbre :as l :refer [info error spy]]
[the-great-game.utils :refer [deep-merge]]
[the-great-game.gossip.gossip :refer [move-gossip]]
[the-great-game.merchants.planning :refer :all]
[the-great-game.merchants.merchant-utils :refer
[add-stock add-known-prices]]
[the-great-game.world.routes :refer [find-route]]))
(defn plan-and-buy
"Return a world like this `world`, in which this `merchant` has planned
a new trade, and bought appropriate stock for it. If no profitable trade
can be planned, the merchant is simply moved towards their home."
[merchant world]
(let [m (cond
(keyword? merchant)
(-> world :merchants merchant)
(map? merchant)
merchant)
id (:id m)
location (:location m)
market (-> world :cities location)
plan (select-cargo merchant world)]
(l/debug "plan-and-buy: merchant" id)
(cond
(not (empty? plan))
(let
[c (:commodity plan)
p (* (:quantity plan) (:buy-price plan))
q (:quantity plan)]
(l/info "Merchant" id "bought" q "units of" c "at" location "for" p plan)
{:merchants
{id
{:stock (add-stock (:stock m) {c q})
:cash (- (:cash m) p)
:known-prices (add-known-prices m world)
:plan plan}}
:cities
{location
{:stock (assoc (:stock market) c (- (-> market :stock c) q))
:cash (+ (:cash market) p)}}})
;; if no plan, then if at home stay put
(= (:location m) (:home m))
(do
(l/info "Merchant" id "remains at home in" location)
{})
;; else move towards home
:else
(let [route (find-route world location (:home m))
next-location (nth route 1)]
(l/info "No trade possible at" location "; merchant" id "moves to" next-location)
(merge
{:merchants
{id
{:location next-location}}}
(move-gossip id world next-location))))))
(defn re-plan
"Having failed to sell a cargo at current location, re-plan a route to
sell the current cargo. Returns a revised world."
[merchant world]
(let [m (cond
(keyword? merchant)
(-> world :merchants merchant)
(map? merchant)
merchant)
id (:id m)
location (:location m)
plan (augment-plan m world (plan-trade m world (-> m :plan :commodity)))]
(l/debug "re-plan: merchant" id)
(deep-merge
world
{:merchants
{id
{:plan plan}}})))
(defn sell-and-buy
"Return a new world like this `world`, in which this `merchant` has sold
their current stock in their current location, and planned a new trade, and
bought appropriate stock for it."
;; TODO: this either sells the entire cargo, or, if the market can't afford
;; it, none of it. And it does not cope with selling different commodities
;; in different markets.
[merchant world]
(let [m (cond
(keyword? merchant)
(-> world :merchants merchant)
(map? merchant)
merchant)
id (:id m)
location (:location m)
market (-> world :cities location)
stock-value (reduce
+
(map
#(* (-> m :stock %) (-> market :prices m))
(keys (:stock m))))]
(l/debug "sell-and-buy: merchant" id)
(if
(>= (:cash market) stock-value)
(do
(l/info "Merchant" id "sells" (:stock m) "at" location "for" stock-value)
(plan-and-buy
merchant
(deep-merge
world
{:merchants
{id
{:stock {}
:cash (+ (:cash m) stock-value)
:known-prices (add-known-prices m world)}}
:cities
{location
{:stock (add-stock (:stock m) (:stock market))
:cash (- (:cash market) stock-value)}}})))
;; else
(re-plan merchant world))))
(defn move-merchant
"Handle general en route movement of this `merchant` in this `world`;
return a (partial or full) world like this `world` but in which the
merchant may have been moved ot updated."
[merchant world]
(let [m (cond
(keyword? merchant)
(-> world :merchants merchant)
(map? merchant)
merchant)
id (:id m)
at-destination? (and (:plan m) (= (:location m) (-> m :plan :destination)))
plan (:plan m)
next-location (if plan
(nth
(find-route
world
(:location m)
(:destination plan))
1)
(:location m))]
(l/debug "move-merchant: merchant" id "at" (:location m)
"destination" (-> m :plan :destination) "next" next-location
"at destination" at-destination?)
(cond
;; if the merchant is at the destination of their current plan
;; sell all cargo and repurchase.
at-destination?
(sell-and-buy merchant world)
;; if they don't have a plan, seek to create one
(nil? plan)
(plan-and-buy merchant world)
;; otherwise, move one step towards their destination
(and next-location (not= next-location (:location m)))
(do
(l/info "Merchant " id " moving from " (:location m) " to " next-location)
(deep-merge
{:merchants
{id
{:location next-location
:known-prices (add-known-prices m world)}}}
(move-gossip id world next-location)))
:else
(do
(l/info "Merchant" id "has plan but no next-location; currently at"
(:location m) ", destination is" (:destination plan))
world))))

View file

@ -3,7 +3,7 @@
(defn cyclic?
"True if two or more elements of `route` are identical"
[route]
(not (= (count route)(count (set route)))))
(not= (count route)(count (set route))))
(defn deep-merge
"Recursively merges maps. Stolen from
@ -15,3 +15,21 @@
(last xs)))]
(reduce m maps)))
(defn make-target-filter
"Construct a filter which, when applied to a list of maps,
will pass those which match these `targets`, where each target
is a tuple [key value]."
;; TODO: this would probably be more elegant as a macro
[targets]
(eval
(list
'fn
(vector 'm)
(cons
'and
(map
#(list
'=
(list (first %) 'm)
(nth % 1))
targets)))))

View file

@ -9,11 +9,11 @@
(map
(fn [to] (cons from to))
(remove
#(empty? %)
empty?
(map
(fn [route]
(filter
#(not (= from %))
(remove
#(= from %)
(if (some #(= % from) route) route)))
routes))))
([routes from to]
@ -30,14 +30,12 @@
(not (empty? steps))
(let [paths (remove
cyclic?
(apply
concat
(map
(mapcat
(fn [path]
(map
(fn [x] (concat path (rest x)))
(find-routes routes (last path))))
steps)))
steps))
found (filter
#(= (last %) to) paths)]
(if

View file

@ -1,17 +1,39 @@
(ns the-great-game.world.run
"Run the whole simulation"
(:require [taoensso.timbre :as log]
(:require [environ.core :refer [env]]
[taoensso.timbre :as timbre]
[taoensso.timbre.appenders.3rd-party.rotor :as rotor]
[the-great-game.gossip.gossip :as g]
[the-great-game.merchants.merchants :as m]
[the-great-game.merchants.markets :as k]
[the-great-game.world.world :as w]))
(defn init
([]
(init {}))
([config]
(timbre/merge-config!
{:appenders
{:rotor (rotor/rotor-appender
{:path "the-great-game.log"
:max-size (* 512 1024)
:backlog 10})}
:level (or
(:log-level config)
(if (env :dev) :debug)
:info)})))
(defn run
"The pipeline to run the simulation each game day. Returns a world like
this world, with all the various active elements updated."
[world]
this world, with all the various active elements updated. The optional
`date` argument, if supplied, is set as the `:date` of the returned world."
([world]
(g/run
(m/run
(k/run
(w/run world)))))
([world date]
(g/run
(m/run
(k/run
(w/run world date))))))

View file

@ -183,8 +183,10 @@
(-> world :cities city :prices commodity))
(defn run
"Return a world like this `world` with only the `:date` value updated
(incremented by one). For running other aspects of the simulation, see
[[the-great-game.world.run]]."
[world]
(assoc world :date (inc (or (:date world) 0))))
"Return a world like this `world` with only the `:date` to this `date`
(or id `date` not supplied, the current value incremented by one). For
running other aspects of the simulation, see [[the-great-game.world.run]]."
([world]
(run world (inc (or (:date world) 0))))
([world date]
(assoc world :date date)))

View file

@ -0,0 +1,24 @@
(ns the-great-game.merchants.merchant-utils-test
(:require [clojure.test :refer :all]
[the-great-game.utils :refer [deep-merge]]
[the-great-game.world.world :refer [default-world]]
[the-great-game.merchants.merchant-utils :refer :all]))
(deftest expected-price-test
(testing "Anticipated prices in markets"
(let [world (deep-merge
default-world
{:merchants
{:archie
{:known-prices
{:buckie
{:iron
[{:price 1.7 :date 1}
{:price 2 :date 0}]}}}}})]
(let [actual (expected-price (-> world :merchants :archie) :fish :edinburgh)
expected 1] ;;
(is (= actual expected) "if no information assume 1"))
(let [actual (expected-price (-> world :merchants :archie) :iron :buckie)
expected 1.7] ;;
(is (= actual expected) "if information select the most recent")))))

View file

@ -1,26 +1,9 @@
(ns the-great-game.merchants.merchants-test
(ns the-great-game.merchants.planning-test
(:require [clojure.test :refer :all]
[the-great-game.utils :refer [deep-merge]]
[the-great-game.world.world :refer [default-world]]
[the-great-game.merchants.merchants :refer :all]))
[the-great-game.merchants.planning :refer :all]))
(deftest expected-price-test
(testing "Anticipated prices in markets"
(let [world (deep-merge
default-world
{:merchants
{:archie
{:known-prices
{:buckie
{:iron
[{:price 1.7 :date 1}
{:price 2 :date 0}]}}}}})]
(let [actual (expected-price (-> world :merchants :archie) :fish :edinburgh)
expected 1] ;;
(is (= actual expected) "if no information assume 1"))
(let [actual (expected-price (-> world :merchants :archie) :iron :buckie)
expected 1.7] ;;
(is (= actual expected) "if information select the most recent")))))
(deftest plan-trade-test
(testing "Lower level trade planning"