Adjustment of prices and quantities in markets

This commit is contained in:
Simon Brooke 2019-05-14 14:09:45 +01:00
parent fcf8a8fa0d
commit 530760ee02
10 changed files with 186 additions and 10 deletions

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
<!DOCTYPE html PUBLIC "" <!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>merchants</span></div></div></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: -52px;"><span class="top" style="height: 61px;"></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"><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-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>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"><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> <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>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> <p>So, firstly, how does one characterise this game?</p>

View file

@ -1,3 +1,3 @@
<!DOCTYPE html PUBLIC "" <!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>merchants</span></div></div></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: -52px;"><span class="top" style="height: 61px;"></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"><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> <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>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"><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

View file

@ -1,3 +1,3 @@
<!DOCTYPE html PUBLIC "" <!DOCTYPE html PUBLIC ""
""> "">
<html><head><meta charset="UTF-8" /><title>the-great-game.utils 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>merchants</span></div></div></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 current"><a href="the-great-game.utils.html"><div class="inner"><span class="tree" style="top: -52px;"><span class="top" style="height: 61px;"></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"><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.utils.html#var-cyclic.3F"><div class="inner"><span>cyclic?</span></div></a></li><li class="depth-1"><a href="the-great-game.utils.html#var-deep-merge"><div class="inner"><span>deep-merge</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">the-great-game.utils</h1><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="public anchor" id="var-cyclic.3F"><h3>cyclic?</h3><div class="usage"><code>(cyclic? route)</code></div><div class="doc"><div class="markdown"><p>True if two or more elements of <code>route</code> are identical</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/utils.clj#L4">view source</a></div></div><div class="public anchor" id="var-deep-merge"><h3>deep-merge</h3><div class="usage"><code>(deep-merge &amp; maps)</code></div><div class="doc"><div class="markdown"><p>Recursively merges maps. Stolen from <a href="https://dnaeon.github.io/recursively-merging-maps-in-clojure/">https://dnaeon.github.io/recursively-merging-maps-in-clojure/</a></p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/utils.clj#L9">view source</a></div></div></div></body></html> <html><head><meta charset="UTF-8" /><title>the-great-game.utils 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>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 current"><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"><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.utils.html#var-cyclic.3F"><div class="inner"><span>cyclic?</span></div></a></li><li class="depth-1"><a href="the-great-game.utils.html#var-deep-merge"><div class="inner"><span>deep-merge</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">the-great-game.utils</h1><div class="doc"><div class="markdown"><p><strong>TODO</strong>: write docs</p></div></div><div class="public anchor" id="var-cyclic.3F"><h3>cyclic?</h3><div class="usage"><code>(cyclic? route)</code></div><div class="doc"><div class="markdown"><p>True if two or more elements of <code>route</code> are identical</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/utils.clj#L4">view source</a></div></div><div class="public anchor" id="var-deep-merge"><h3>deep-merge</h3><div class="usage"><code>(deep-merge &amp; maps)</code></div><div class="doc"><div class="markdown"><p>Recursively merges maps. Stolen from <a href="https://dnaeon.github.io/recursively-merging-maps-in-clojure/">https://dnaeon.github.io/recursively-merging-maps-in-clojure/</a></p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/utils.clj#L9">view source</a></div></div></div></body></html>

View file

@ -1,3 +1,3 @@
<!DOCTYPE html PUBLIC "" <!DOCTYPE html PUBLIC ""
""> "">
<html><head><meta charset="UTF-8" /><title>the-great-game.world.routes 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>merchants</span></div></div></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: -52px;"><span class="top" style="height: 61px;"></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 current"><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"><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.routes.html#var-find-routes"><div class="inner"><span>find-routes</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">the-great-game.world.routes</h1><div class="doc"><div class="markdown"><p>Conceptual (plan level) routes, represented as tuples of location ids.</p></div></div><div class="public anchor" id="var-find-routes"><h3>find-routes</h3><div class="usage"><code>(find-routes routes from)</code><code>(find-routes routes from to)</code><code>(find-routes routes from to steps)</code></div><div class="doc"><div class="markdown"><p>Find routes from among these <code>routes</code> from <code>from</code>; if <code>to</code> is supplied, to <code>to</code>, by breadth-first search.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/world/routes.clj#L5">view source</a></div></div></div></body></html> <html><head><meta charset="UTF-8" /><title>the-great-game.world.routes 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>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 current"><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"><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.routes.html#var-find-routes"><div class="inner"><span>find-routes</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">the-great-game.world.routes</h1><div class="doc"><div class="markdown"><p>Conceptual (plan level) routes, represented as tuples of location ids.</p></div></div><div class="public anchor" id="var-find-routes"><h3>find-routes</h3><div class="usage"><code>(find-routes routes from)</code><code>(find-routes routes from to)</code><code>(find-routes routes from to steps)</code></div><div class="doc"><div class="markdown"><p>Find routes from among these <code>routes</code> from <code>from</code>; if <code>to</code> is supplied, to <code>to</code>, by breadth-first search.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/world/routes.clj#L5">view source</a></div></div></div></body></html>

View file

@ -1,3 +1,3 @@
<!DOCTYPE html PUBLIC "" <!DOCTYPE html PUBLIC ""
""> "">
<html><head><meta charset="UTF-8" /><title>the-great-game.world.world 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>merchants</span></div></div></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: -52px;"><span class="top" style="height: 61px;"></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 current"><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.world.html#var-actual-price"><div class="inner"><span>actual-price</span></div></a></li><li class="depth-1"><a href="the-great-game.world.world.html#var-default-world"><div class="inner"><span>default-world</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">the-great-game.world.world</h1><div class="doc"><div class="markdown"><p>Access to data about the world</p></div></div><div class="public anchor" id="var-actual-price"><h3>actual-price</h3><div class="usage"><code>(actual-price world commodity city)</code></div><div class="doc"><div class="markdown"><p>Find the actual current price of this <code>commodity</code> in this <code>city</code> given this <code>world</code>. <strong>NOTE</strong> that merchants can only know the actual prices in the city in which they are currently located.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/world/world.clj#L177">view source</a></div></div><div class="public anchor" id="var-default-world"><h3>default-world</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>A basic world for testing concepts</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/world/world.clj#L10">view source</a></div></div></div></body></html> <html><head><meta charset="UTF-8" /><title>the-great-game.world.world 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>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 current"><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.world.html#var-actual-price"><div class="inner"><span>actual-price</span></div></a></li><li class="depth-1"><a href="the-great-game.world.world.html#var-default-world"><div class="inner"><span>default-world</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">the-great-game.world.world</h1><div class="doc"><div class="markdown"><p>Access to data about the world</p></div></div><div class="public anchor" id="var-actual-price"><h3>actual-price</h3><div class="usage"><code>(actual-price world commodity city)</code></div><div class="doc"><div class="markdown"><p>Find the actual current price of this <code>commodity</code> in this <code>city</code> given this <code>world</code>. <strong>NOTE</strong> that merchants can only know the actual prices in the city in which they are currently located.</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/world/world.clj#L177">view source</a></div></div><div class="public anchor" id="var-default-world"><h3>default-world</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>A basic world for testing concepts</p></div></div><div class="src-link"><a href="https://github.com/simon-brooke/the-great-game/blob/master/src/the_great_game/world/world.clj#L10">view source</a></div></div></div></body></html>

View file

@ -0,0 +1,76 @@
(ns the-great-game.merchants.markets
"Adjusting quantities and prices in markets."
(:require [the-great-game.utils :refer [deep-merge]]
[the-great-game.world.world :refer [actual-price default-world]]))
(defn new-price
"If `stock` is greater than the maximum of `supply` and `demand`, then
there is surplus and `old` price is too high, so shold be reduced. If
lower, then it is too low and should be increased."
[old stock supply demand]
(let
[delta (dec' (/ (max supply demand 1) (max stock 1)))
scaled (/ delta 100)]
(+ old scaled)))
(defn adjust-quantity-and-price
"Adjust the quantity of this `commodity` currently in stock in this `city`
of this `world`. Return a fragmentary world which can be deep-merged into
this world."
[world city commodity]
(let [c (cond
(keyword? city) (-> world :cities city)
(map? city) city)
id (:id c)
p (or (-> c :prices commodity) 0)
d (or (-> c :demands commodity) 0)
st (or (-> c :stock commodity) 0)
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.
(> 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
(> su st)
(- su st)
true 0)
price (new-price p st su d)]
{:cities {id
{:stock
{commodity (+ (- st decrement) increment)}
:prices
{commodity price}}}}))
(defn update-markets
"Return a world like this `world`, with quantities and prices in markets
updated to reflect supply and demand. If `city` or `city` and `commodity`
are specified, return a fragmentary world with only the changes for that
`city` (and `commodity` if specified) populated."
([world]
(reduce
deep-merge
world
(map
#(update-markets world %)
(keys (:cities world)))))
([world city]
(reduce
deep-merge
{}
(map #(update-markets world city %)
(keys (:commodities world)))))
([world city commodity]
(adjust-quantity-and-price world city commodity)))
(defn run
"Return a world like this `world`, with quantities and prices in markets
updated to reflect supply and demand."
[world]
(update-markets world))

View file

@ -0,0 +1,86 @@
(ns the-great-game.merchants.markets-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.markets :refer :all]))
(deftest new-price-test
(testing "Adjustment of prices based on supply and demand"
(is (> (new-price 1 0 10 10) 1)
"If no stock but there is supply and demand, price should rise")
(is (> (new-price 1 0 0 10) 1)
"If no stock but there is demand, price should rise")
(is (> (new-price 1 5 0 10) 1)
"If there is insufficient stock to meet demand, price should rise")
(is (= (new-price 1 10 0 10) 1)
"If there is exactly sufficient stock to meet demand, price should not change")
(is (< (new-price 1 10 0 5) 1)
"If there is surplus stock beyond demand, price should fall")
(is (> (new-price 1 0 0 10) (new-price 1 5 0 10))
"The greater the relative undersupply, the more prices should rise")
(is (< (new-price 1 10 0 0)(new-price 1 10 0 5) 1)
"The greater the relative oversupply, the more prices should fall")
))
(deftest adjust-qunatity-and-price-test
(testing "Adjustment in quantity and price: supply only."
(let [world (deep-merge
default-world
{:cities
{:falkirk
{:stock {:iron 0}
:supplies {:iron 12}}}})
actual (adjust-quantity-and-price world :falkirk :iron)]
(is
(=
(-> actual :cities :falkirk :stock :iron)
(-> world :cities :falkirk :supplies :iron))
"If stock is empty it should be topped up by supply amount."))
(let [world (deep-merge
default-world
{:cities
{:falkirk
{:stock {:iron 5}
:supplies {:iron 12}
:prices {:iron 0.9}}}})
actual (adjust-quantity-and-price world :falkirk :iron)]
(is
(=
(-> actual :cities :falkirk :stock :iron)
(-> world :cities :falkirk :supplies :iron))
"If stock is not empty and price is below cost, stock should be topped up only to supply amount."))
(let [world (deep-merge
default-world
{:cities
{:falkirk
{:stock {:iron 5}
:supplies {:iron 12}
:prices {:iron 1.1}}}})
actual (adjust-quantity-and-price world :falkirk :iron)]
(is
(=
(-> actual :cities :falkirk :stock :iron)
(+ (-> world :cities :falkirk :supplies :iron)
(-> world :cities :falkirk :stock :iron)))
"If stock is not empty and price is above cost, stock should be topped up by supply amount.")))
(testing "Adjustment in quantity and price: supply and demand."
(let [world (deep-merge
default-world
{:cities
{:falkirk
{:stock {:iron 10}
:demands {:iron 5}
:supplies {:iron 12}
:prices {:iron 1.1}}}})
actual (adjust-quantity-and-price world :falkirk :iron)]
(is
(=
(-> actual :cities :falkirk :stock :iron)
17)
"Stock should be topped up by the difference between the supply and
the demand amount."))
)
)