Baking the world
+Generated by Codox
The-great-game 0.1.2-SNAPSHOT
Baking the world
Wednesday, 8 May 2019
-Devorgilla’s Bridge in Dumfries, early foourteenth century. This clearly shows how a genetic buildings approach to bridges can be made to work: a single element is repeated to span the necessary distance. That element can be stretched vertically and laterally to match the location, and can be rendered in different stone finishes to match local geology.
In previous posts, I’ve described algorithms for dynamically populating and dynamically settling a game world. But at kilometre scale (and I think we need a higher resolution than that - something closer to hectare scale), settling the British Isles using my existing algorithms takes about 24 hours of continuous compute on an eight core, 3GHz machine. You cannot do that every time you launch a new game.
So the game development has to run in four phases: the first three phases happen during development, to create a satisfactory, already populated and settled, initial world for the game to start from. This is particularly necessary if hand-crafted buildings and environments are going to be added to the world; the designers of those buildings and environments have to be able to see the context into which their models must fit.
Phase one: proving - the procedural world
diff --git a/docs/codox/Pathmaking.html b/docs/codox/Pathmaking.html index 966e6e7..17d6c51 100644 --- a/docs/codox/Pathmaking.html +++ b/docs/codox/Pathmaking.html @@ -1,15 +1,16 @@ -Generated by Codox
The-great-game 0.1.1-SNAPSHOT
Pathmaking
+Generated by Codox
The-great-game 0.1.2-SNAPSHOT
Pathmaking
NOTE: this file is called ‘pathmaking’, not ‘pathfinding’, because ‘pathfinding’ has a very specific meaning/usage in game design which is only part of what I want to talk about here.
Stages in creating routes between locations
-The ‘procedural’ phase
-see also Baking-the-world
+see also Baking the world
Towards the end of the procedural phase of the build process, every agent within the game world must move through the complete range of their needs-driven repertoire. Merchants must traverse their trading routes; soldiers must patrol routes within their employers domain; primary producers and craftspeople must visit the craftspeople who supply them; every character must visit their local inn, and must move daily between their dwelling and their workplace if different; and so on. They must do this over a considerable period - say 365 simulated days.
At the start of the baking phase, routes - roads, tracks and paths - designed by the game designers already exist.
The algorithmic part of choosing a route is the same during this baking phase as in actual game play except that during the baking phase the routemap is being dynamically updated, creating a new path or augmenting an existing path wherever any agent goes.
Thus the ‘weight’ of any section of route is a function of the total number of times that route segment has been traversed by an agent during this baking phase. At the end of the baking phase, routes travelled more than R
times are rendered as roads, T
times as tracks, and P
times as footpaths, where R
, T
and P
are all chosen by the game designer but generally R > T > P
.
Algorithmic rules
+Routing
+Routing is fundamentally by A*, I think.
+Algorithmic rules
- No route may pass through any part of a reserved holding, except the holding which is its origin, if any, and the holding which is its destination (and in any case we won’t render paths or roads within holdings, although traversal information may be used to determine whether a holding, or part of it, is paved/cobbled;
- No route may pass through any building, with the exception of a city gate; @@ -17,8 +18,30 @@
- Any existing route segment costs only a third as much to traverse as open ground having the same gradient;
- A more used route costs less to traverse than a less used route.
Step costing:
+Step cost is something like:
+(/
+ (-
+ (+ distance
+ (expt height-gained height-gain-exponent)
+ (reduce + (map crossing-penalty watercourses-crossed)))
+ (reduce + (map bridge-bonus bridges-crossed)))
+ (or road-bonus 1))
+
+Where
+-
+
distance
traversed is in metres;
+ height-gained
is in metres;
+ height-gain-exponent
is tunable;
+ - river
crossing-penalty
varies with a (tunable) exponent of the flow;
+ bridge-bonus
works as follows: bridge bonus for a bridge entirely cancels the river crossing penalty for the watercourse the bridge crosses; bridge bonus for a ferry cancels a (tunable) fraction the river crossing penalty.
+ - road-bonus for a road is substantial - probably about 8; for a track is less than road but greater than footpath, say 5; for a footpath has to be at least 3, to provide an incentive to stick to paths. All these values are tunable. Road bonus ought also to increase a small amount with each traversal of the path segment, but that’s still to be worked on. +
A lot of this is subject to tuning once we have prototype code running.
+Somewhere into all this I need to factor tolls charged by local aristons, especially for bridges/ferries, and risk factors of hostile action, whether by outlaws or by hostile factions. But actually, that is at a per actor level, rather than at a pathmaking level: richer actors are less deterred by tolls, better armed actors less deterred by threat of hostile action.
River crossings
-Crossing rivers is expensive - say five times as expensive as level open ground (but this will probably need tuning). Where a river is shallow enough, (i.e. where the amount of water passing is below some threshold) then a path crossing will be rendered as stepping stones and a track crossing as a ford. Where it’s deeper than that, a path crossing either isn’t rendered at all or is rendered as a light footbridge. A track or road crossing is rendered as a bridge. However, the maximum length of a bridge varies with the amount of traffic on the route segment, and if the crossing exceeds that length then a ferry is used. Road bridges will be more substantial than track bridges, for example in a biome with both timber and stone available road bridges might be rendered as stone bridges while track bridges were rendered as timber. If the watercourse is marked as navigable
, the bridge must have a lifting section. It is assumed here that bridges are genetic buildings like most other in-game buildings, and so don’t need to be individually designed.
River crossings appear automatically when the number of traversals of a particular route across a watercourse passes some threshhold. The threshold probably varies with an exponent of the flow; the threshold at which a ferry will appear is lower (by half?) than the threshold for a bridge. Of course river crossings, like roads, can also be pre-designed by game designers.
+Where a river is shallow enough, (i.e. where the flow is below some threshold) then a path crossing will be rendered as stepping stones and a track crossing as a ford. Where it’s deeper than that, a path crossing either isn’t rendered at all or is rendered as a light footbridge. A track or road crossing is rendered as a bridge. However, the maximum length of a bridge varies with the amount of traffic on the route segment, and if the crossing exceeds that length then a ferry is used. Road bridges will be more substantial than track bridges, for example in a biome with both timber and stone available road bridges might be rendered as stone bridges while track bridges were rendered as timber. If the watercourse is marked as navigable
, the bridge must have a lifting section. It is assumed here that bridges are genetic buildings like most other in-game buildings, and so don’t need to be individually designed.
Representation
At some stage in the future I’ll have actual game models to work with and $DEITY knows what the representation of those will be like, but to get this started I need two inputs: a heightmap, from which gradients can be derived, and a route map. The heightmap can conventionally be a monochrome raster image, and that’s easy. The route map needs to be a vector representation, and SVG will be as convenient as any. So from the point of view of routing during the baking phase, a route map shall be an SVG with the following classes:
-
@@ -47,15 +70,7 @@
I shall have to write custom code for 4 and 5 above, and, looking at what’s available, probably 3 as well.
I’m working on a separate library, walkmap, which will attempt to implement this pipeline.
Pathmaking and scale
-Dealing with large heightmaps - doing anything at all with them - is extremely compute intensive. Just converting a 1000x1000 heightmap from STL to SVG is currently taking 8 hours and 15 minutes; and it ends up with a 46 megabyte SVG file! However, most of the time cost is in writing. Reading the STL file takes four and a quarter seconds; converting that STL to SVG in memory takes less than five seconds. So the huge cost is writing the file with Dali.
-walkmap.core=> (time (def stl (decode-binary-stl "../the-great-game/resources/maps/heightmap.stl")))
-"Elapsed time: 4285.231513 msecs"
-#'walkmap.core/stl
-walkmap.core=> (time (def svg (stl-to-svg stl)))
-"Elapsed time: 4865.798059 msecs"
-#'walkmap.core/svg
-
-“Elapsed time: 2.969569560662E7 msecs”
+Dealing with large heightmaps - doing anything at all with them - is extremely compute intensive.
We cannot effectively do routing at metre scale - which is what we ultimately need in settlements - across the entire thousand kilometre square map in one pass. But also we don’t need to because much of the continent is by design relatively unpeopled and relatively untracked. The basic concept of the Steppe is that there are two north/south routes, the one over the Midnight Pass into the Great Place and the one via Hans’hua down to the Cities of the Coast, and those can be part of the ‘designed roads’ map. So we can basically exclude most of the Steppe from routing altogether. We can also - for equally obvious reasons exclude the ocean. The ocean makes up roughly half of the 1000x1000 kilometre map, the steppe and plateau take up half of what’s left, mountain massifs eat into the remainder and my feeling is that much of the eastern part of the continent is probably too arid to be settled. So we probably end up only having to dynamically route about 20% of the entire map.
However, this doesn’t get round the main problem with scale, and pathmaking. If we pathmake at kilometre scale, then curves will be necessarily very long and sweeping - because each path segment will be at least a kilometre long. And, actually, that’s fine for very long distance roads in unpopulated fairly flat territory. It’s not so good for long distance roads in rugged terrain, but…
Phase one: hand-designed routes
@@ -74,6 +89,8 @@ walkmap.core=> (time (def svg (stl-to-svg stl)))we can then collect contiguous groups of zones each having at least one holding, where in phase four each zone is a kilometre square and divided into 100x100 grid so that we route at ten metre scale; in phase five we use ten kilometre by ten kilometre zones and we route at 100 metre scale; in phase six, 100 km by 100 km zones and we route at kilometre scale. This process should automatically link up all settlements on the south and west coasts, all those on the north coast, and all in the Great Place; and seeing that the posited pre-designed caravan roads already join the south coast to the north, the north to the Great Place and the Great Place to the south coast, we’re done.
At least one of phases three, four, five and six is probably redundant; but without trying I’m not sure which.
+Relevant actor classes by phase
+Craftspeople and primary producers do travel between settlements, but only exceptionally. They mainly travel within at most a few kilometres of home; so they are primarily relevant in phases four and five, and need not be activated during phase six. Similarly, merchants primarily travel between settlements, and rarely within settlements; therefore, they need not be activated in phase four, and probably not even in phase five; but they must do a lot of journeys - substantially their full repertoire - in phase six.
Tidying up
After the full set of increasing-scale passes is complete, we should automatically cull any route segments generated in the settlement phase which have never actually been traversed.
Following that, there may be scope for some final manual tweaking, if desired; I think this is most likely to happen where roads routed at kilometre scale cross rugged terrain.
Generated by Codox
The-great-game 0.1.1-SNAPSHOT
Populating a game world
+Generated by Codox
The-great-game 0.1.2-SNAPSHOT
Populating a game world
Saturday, 6 July 2013
(You might want to read this essay in conjunction with my older essay, Settling a game world, which covers similar ground but which this hopefully advances on)
For an economy to work people have to be able to move between occupations to fill economic niches. In steady state, non player character (NPC) males become adult as ‘vagrants’, and then move through the state transitions described in this document. The pattern for females is different.
diff --git a/docs/codox/Settling-a-game-world.html b/docs/codox/Settling-a-game-world.html index 1bdac1f..b46a745 100644 --- a/docs/codox/Settling-a-game-world.html +++ b/docs/codox/Settling-a-game-world.html @@ -1,6 +1,6 @@ -Generated by Codox
The-great-game 0.1.1-SNAPSHOT
Settling a game world
+Generated by Codox
The-great-game 0.1.2-SNAPSHOT
Settling a game world
Wednesday, 30 December 2009
This essay is part of a series with ‘Worlds and Flats’ and ‘The spread of knowledge in a large game world’; if you haven’t read those you may want to read them before reading this. This essay describes how a large world can come into being and can evolve. I’ve written again on this subject since - see ‘Populating a game world’)
Microworld
diff --git a/docs/codox/The-spread-of-knowledge-in-a-large-game-world.html b/docs/codox/The-spread-of-knowledge-in-a-large-game-world.html index 21193ca..4b8dc93 100644 --- a/docs/codox/The-spread-of-knowledge-in-a-large-game-world.html +++ b/docs/codox/The-spread-of-knowledge-in-a-large-game-world.html @@ -1,6 +1,6 @@ -Generated by Codox
The-great-game 0.1.1-SNAPSHOT
The spread of knowledge in a large game world
+Generated by Codox
The-great-game 0.1.2-SNAPSHOT
The spread of knowledge in a large game world
Saturday, 26 April 2008
Note
diff --git a/docs/codox/Voice-acting-considered-harmful.html b/docs/codox/Voice-acting-considered-harmful.html index 44121b1..1b1b3fe 100644 --- a/docs/codox/Voice-acting-considered-harmful.html +++ b/docs/codox/Voice-acting-considered-harmful.html @@ -1,6 +1,6 @@ -Generated by Codox
The-great-game 0.1.1-SNAPSHOT
Voice acting considered harmful
+Generated by Codox
The-great-game 0.1.2-SNAPSHOT
Voice acting considered harmful
Wednesday, 25 February 2015
Long, long, time ago, I can still remember when… we played (and wrote) adventure games where the user typed at a command line, and the system printed back at them. A Read-Eval-Print loop in the classic Lisp sense, and I wrote my adventure games in Lisp. I used the same opportunistic parser whether the developer was building the game Create a new room north of here called dungeon-3 the player was playing the game Pick up the rusty sword and go north or the player was talking to a non-player character Say to the wizard ‘can you tell me the way to the castle’ Of course, the parser didn’t ‘understand’ English. It worked on trees of words, in which terminal nodes were actions and branching nodes were key words, and it had the property that any word it didn’t recognise at that point in sentence was a noise word and could be ignored. A few special hacks (such as ‘the’, ‘a’, or ‘an’ was an indicator that what came next was probably a noun phrase, and thus that if there was more than one sword in the player’s immediate environment the one that was wanted was the one tagged with the adjective ‘rusty’), and you ended up with a parser that most of the time convincingly interpreted most of what the player threw at it.
diff --git a/docs/codox/economy.html b/docs/codox/economy.html index c4dbafb..9bd68f7 100644 --- a/docs/codox/economy.html +++ b/docs/codox/economy.html @@ -1,6 +1,6 @@ -Generated by Codox
The-great-game 0.1.1-SNAPSHOT
Game world economy
+Generated by Codox
The-great-game 0.1.2-SNAPSHOT
Game world economy
Broadly this essay extends ideas presented in Populating a game world, q.v.
Primary producers
Herdsfolk
diff --git a/docs/codox/index.html b/docs/codox/index.html index f7aab85..2d0f0d2 100644 --- a/docs/codox/index.html +++ b/docs/codox/index.html @@ -1,3 +1,3 @@ -Generated by Codox
The-great-game 0.1.1-SNAPSHOT
The-great-game 0.1.1-SNAPSHOT
Released under the GNU General Public License,version 2.0 or (at your option) any later version
Prototype code towards the great game I've been writing about for ten years, and know I will never finish.
Installation
To install, add the following dependency to your project or build file:
[the-great-game "0.1.1-SNAPSHOT"]
Topics
- Baking the world
- Pathmaking
- Populating a game world
- Settling a game world
- The spread of knowledge in a large game world
- Voice acting considered harmful
- Game world economy
- Introduction to the-great-game
- Modelling trading cost and risk
- Naming of Characters
- On Dying
- Organic Quests
- Sandbox
- Sexual dimorphism
Namespaces
the-great-game.gossip.gossip
Interchange of news events between gossip agents
Public variables and functions:
the-great-game.gossip.news-items
Categories of news events interesting to gossip agents
the-great-game.merchants.markets
Adjusting quantities and prices in markets.
Public variables and functions:
the-great-game.merchants.merchant-utils
Useful functions for doing low-level things with merchants.
Public variables and functions:
the-great-game.merchants.merchants
Trade planning for merchants, primarily.
Public variables and functions:
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.
Public variables and functions:
the-great-game.merchants.strategies.simple
Default trading strategy for merchants.
Public variables and functions:
the-great-game.time
TODO: write docs
the-great-game.world.location
Functions dealing with location in the world.
Public variables and functions:
the-great-game.world.routes
Conceptual (plan level) routes, represented as tuples of location ids.
Public variables and functions:
Generated by Codox
The-great-game 0.1.2-SNAPSHOT
The-great-game 0.1.2-SNAPSHOT
Released under the GNU General Public License,version 2.0 or (at your option) any later version
Prototype code towards the great game I've been writing about for ten years, and know I will never finish.
Installation
To install, add the following dependency to your project or build file:
[journeyman-cc/the-great-game "0.1.2-SNAPSHOT"]
Topics
- Baking the world
- Pathmaking
- Populating a game world
- Settling a game world
- The spread of knowledge in a large game world
- Voice acting considered harmful
- Game world economy
- Introduction to the-great-game
- Modelling trading cost and risk
- Naming of Characters
- On Dying
- Organic Quests
- Sandbox
- Sexual dimorphism
Namespaces
the-great-game.gossip.gossip
Interchange of news events between gossip agents
Public variables and functions:
the-great-game.gossip.news-items
Categories of news events interesting to gossip agents
the-great-game.merchants.markets
Adjusting quantities and prices in markets.
Public variables and functions:
the-great-game.merchants.merchant-utils
Useful functions for doing low-level things with merchants.
Public variables and functions:
the-great-game.merchants.merchants
Trade planning for merchants, primarily.
Public variables and functions:
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.
Public variables and functions:
the-great-game.merchants.strategies.simple
Default trading strategy for merchants.
Public variables and functions:
the-great-game.time
TODO: write docs
the-great-game.world.location
Functions dealing with location in the world.
Public variables and functions:
the-great-game.world.routes
Conceptual (plan level) routes, represented as tuples of location ids.
Public variables and functions:
Generated by Codox
The-great-game 0.1.1-SNAPSHOT
Introduction to the-great-game
+Generated by Codox
The-great-game 0.1.2-SNAPSHOT
Introduction to the-great-game
The Great Game
In this essay I’m going to try to pull together a number of my architectural ideas about the Great Game which I know I’m never actually going to build - because it’s vastly too big for any one person to build - into one overall vision.
So, firstly, how does one characterise this game?
diff --git a/docs/codox/modelling_trading_cost_and_risk.html b/docs/codox/modelling_trading_cost_and_risk.html index 93ea97f..0e4b71a 100644 --- a/docs/codox/modelling_trading_cost_and_risk.html +++ b/docs/codox/modelling_trading_cost_and_risk.html @@ -1,6 +1,6 @@ -Generated by Codox
The-great-game 0.1.1-SNAPSHOT
Modelling trading cost and risk
+Generated by Codox
The-great-game 0.1.2-SNAPSHOT
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?
diff --git a/docs/codox/naming-of-characters.html b/docs/codox/naming-of-characters.html index e0f2dea..d36f96d 100644 --- a/docs/codox/naming-of-characters.html +++ b/docs/codox/naming-of-characters.html @@ -1,6 +1,6 @@ -Generated by Codox
The-great-game 0.1.1-SNAPSHOT
Naming of Characters
+Generated by Codox
The-great-game 0.1.2-SNAPSHOT
Naming of Characters
Generally speaking, in modern RPGs, every character with any impact on the plot has a distinct name. But if we are going to give all non-player characters sufficient agency to impact on the plot, then we must have a way of naming tens or hundreds of thousands of characters, and distinct names will become problematic (even if we’re procedurally generating names, which we shall have to do. So this note is about how characters are named.
The full name of each character will be made up as follows:
[epithet] [clan] [personal-name] the [trade-or-rank] of [location], son/daughter of [parent]
diff --git a/docs/codox/on-dying.html b/docs/codox/on-dying.html index a52e81a..8b6ad91 100644 --- a/docs/codox/on-dying.html +++ b/docs/codox/on-dying.html @@ -1,6 +1,6 @@ -Generated by Codox
The-great-game 0.1.1-SNAPSHOT
On Dying
+Generated by Codox
The-great-game 0.1.2-SNAPSHOT
On Dying
Death is the end of your story. One of the tropes in games which, for me, most breaks immersion is when you lose a fight and are presented with a screen that says ‘you are dead. Do you want to reload your last save?’ Life is not like that. We do not have save-states. We die.
So how could this be better handled?
You lose a fight. Switch to cutscene: the battlefield, after the fight, your body is there. Probably no sound. A party of non-enemies crosses the battlefield and finds your body. We see surprise and concern. They gather around you. Cut to interior scene, you are in a bed, unconcious, being tended; cut to similar interior scene, you are in a bed, conscious, being tended; cut to exterior scene, you are sitting with some of your saviours, and the game restarts.
diff --git a/docs/codox/orgnic-quests.html b/docs/codox/orgnic-quests.html index 49b6973..ae56c9c 100644 --- a/docs/codox/orgnic-quests.html +++ b/docs/codox/orgnic-quests.html @@ -1,6 +1,6 @@ -Generated by Codox
The-great-game 0.1.1-SNAPSHOT
Organic Quests
+Generated by Codox
The-great-game 0.1.2-SNAPSHOT
Organic Quests
The structure of a modern Role Playing Came revolves around ‘quests’: tasks that the player character is invited to do, either by the framing narrative of the game or by some non-player character (‘the Quest Giver’). Normally there is one core quest which provides the overarching narrative for the whole game. [Wikipedia](https://en.wikipedia.org/wiki/Quest_(gaming)) offers a typology of quests as follows:
- Kill quests diff --git a/docs/codox/sandbox.html b/docs/codox/sandbox.html index 975e6d8..4ec0232 100644 --- a/docs/codox/sandbox.html +++ b/docs/codox/sandbox.html @@ -1,6 +1,6 @@ -
:active
- actors within visual/audible range of the player character;:pending
- actors not in the active circle, but sufficiently close to it that they may enter the active circle within a short period;
diff --git a/docs/codox/the-great-game.gossip.gossip.html b/docs/codox/the-great-game.gossip.gossip.html
index 3e5f1a4..1779077 100644
--- a/docs/codox/the-great-game.gossip.gossip.html
+++ b/docs/codox/the-great-game.gossip.gossip.html
@@ -1,3 +1,3 @@
-actor
is the id of the character who it is reported performed the action;other
is the id of the character on whom it is reported the action was performed;
diff --git a/docs/codox/the-great-game.merchants.markets.html b/docs/codox/the-great-game.merchants.markets.html
index e85c827..9e41495 100644
--- a/docs/codox/the-great-game.merchants.markets.html
+++ b/docs/codox/the-great-game.merchants.markets.html
@@ -1,3 +1,3 @@
-
Generated by Codox
The-great-game 0.1.1-SNAPSHOT
Sandbox
+Generated by Codox
The-great-game 0.1.2-SNAPSHOT
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
diff --git a/docs/codox/sexual-dimorphism.html b/docs/codox/sexual-dimorphism.html index 90c7153..07f0ce8 100644 --- a/docs/codox/sexual-dimorphism.html +++ b/docs/codox/sexual-dimorphism.html @@ -1,6 +1,6 @@ -Generated by Codox
The-great-game 0.1.1-SNAPSHOT
Sexual dimorphism
+Generated by Codox
The-great-game 0.1.2-SNAPSHOT
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.
diff --git a/docs/codox/the-great-game.agent.agent.html b/docs/codox/the-great-game.agent.agent.html index 7e659af..efd5f84 100644 --- a/docs/codox/the-great-game.agent.agent.html +++ b/docs/codox/the-great-game.agent.agent.html @@ -1,6 +1,6 @@ -Generated by Codox
The-great-game 0.1.1-SNAPSHOT
the-great-game.agent.agent
Anything in the game world with agency
ProtoAgent
protocol
An object which can act in the world
members
act
(act actor world circle)
Allow actor
to do something in this world
, in the context of this circle
; return the new state of the actor if something was done, nil
if nothing was done. Circle is expected to be one of
Generated by Codox
The-great-game 0.1.2-SNAPSHOT
the-great-game.agent.agent
Anything in the game world with agency
ProtoAgent
protocol
An object which can act in the world
members
act
(act actor world circle)
Allow actor
to do something in this world
, in the context of this circle
; return the new state of the actor if something was done, nil
if nothing was done. Circle is expected to be one of
Generated by Codox
The-great-game 0.1.1-SNAPSHOT
the-great-game.gossip.gossip
Interchange of news events between gossip agents
dialogue
(dialogue enquirer respondent world)
Dialogue between an enquirer
and an agent
in this world
; returns a map identical to enquirer
except that its :gossip
collection may have additional entries.
move-gossip
(move-gossip gossip world new-location)
Return a world like this world
but with this gossip
moved to this new-location
. Many gossips are essentially shadow-records of agents of other types, and the movement of the gossip should be controlled by the run function of the type of the record they shadow. The #run function below does NOT call this function.
run
(run world)
Return a world like this world
, with news items exchanged between gossip agents.
Generated by Codox
The-great-game 0.1.2-SNAPSHOT
the-great-game.gossip.gossip
Interchange of news events between gossip agents
dialogue
(dialogue enquirer respondent world)
Dialogue between an enquirer
and an agent
in this world
; returns a map identical to enquirer
except that its :gossip
collection may have additional entries.
move-gossip
(move-gossip gossip world new-location)
Return a world like this world
but with this gossip
moved to this new-location
. Many gossips are essentially shadow-records of agents of other types, and the movement of the gossip should be controlled by the run function of the type of the record they shadow. The #run function below does NOT call this function.
run
(run world)
Return a world like this world
, with news items exchanged between gossip agents.
Generated by Codox
The-great-game 0.1.1-SNAPSHOT
the-great-game.gossip.news-items
Categories of news events interesting to gossip agents
degrade-character
(degrade-character gossip character)
Return a character specification like this character
, but comprising only those properties this gossip
is interested in.
degrade-location
(degrade-location gossip location)
Return a location specification like this location
, but comprising only those elements this gossip
is interested in. If none, return nil
.
interest-in-character
(interest-in-character gossip character)
Integer representation of how interesting this character
is to this gossip
. TODO: this assumes that characters are passed as keywords, but, as documented above, they probably have to be maps, to allow for degradation.
interest-in-location
(interest-in-location gossip location)
Integer representation of how interesting this location
is to this gossip
.
interesting-character?
(interesting-character? gossip character)
Boolean representation of whether this character
is interesting to this gossip
.
interesting-item?
(interesting-item? gossip item)
True if anything about this news item
is interesting to this gossip
.
interesting-location?
(interesting-location? gossip item)
True if the location of this news item
is interesting to this gossip
.
learn-news-item
(learn-news-item gossip item)
(learn-news-item gossip item follow-inferences?)
Return a gossip like this gossip
, which has learned this news item
if it is of interest to them.
make-all-inferences
(make-all-inferences item)
Return a list of knowledge entries that can be inferred from this news item
.
news-topics
Topics of interest to gossip agents. Topics are keyed in this map by their verbs
. The keys
associated with each topic are the extra pieces of information required to give context to a gossip item. Generally:
Generated by Codox
The-great-game 0.1.2-SNAPSHOT
the-great-game.gossip.news-items
Categories of news events interesting to gossip agents
degrade-character
(degrade-character gossip character)
Return a character specification like this character
, but comprising only those properties this gossip
is interested in.
degrade-location
(degrade-location gossip location)
Return a location specification like this location
, but comprising only those elements this gossip
is interested in. If none, return nil
.
interest-in-character
(interest-in-character gossip character)
Integer representation of how interesting this character
is to this gossip
. TODO: this assumes that characters are passed as keywords, but, as documented above, they probably have to be maps, to allow for degradation.
interest-in-location
(interest-in-location gossip location)
Integer representation of how interesting this location
is to this gossip
.
interesting-character?
(interesting-character? gossip character)
Boolean representation of whether this character
is interesting to this gossip
.
interesting-item?
(interesting-item? gossip item)
True if anything about this news item
is interesting to this gossip
.
interesting-location?
(interesting-location? gossip item)
True if the location of this news item
is interesting to this gossip
.
learn-news-item
(learn-news-item gossip item)
(learn-news-item gossip item follow-inferences?)
Return a gossip like this gossip
, which has learned this news item
if it is of interest to them.
make-all-inferences
(make-all-inferences item)
Return a list of knowledge entries that can be inferred from this news item
.
news-topics
Topics of interest to gossip agents. Topics are keyed in this map by their verbs
. The keys
associated with each topic are the extra pieces of information required to give context to a gossip item. Generally:
Generated by Codox
The-great-game 0.1.1-SNAPSHOT
the-great-game.merchants.markets
Adjusting quantities and prices in markets.
adjust-quantity-and-price
(adjust-quantity-and-price world city commodity)
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.
new-price
(new-price old stock supply demand)
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.
run
(run world)
Return a world like this world
, with quantities and prices in markets updated to reflect supply and demand.
update-markets
(update-markets world)
(update-markets world city)
(update-markets world city commodity)
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.
Generated by Codox
The-great-game 0.1.2-SNAPSHOT
the-great-game.merchants.markets
Adjusting quantities and prices in markets.
adjust-quantity-and-price
(adjust-quantity-and-price world city commodity)
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.
new-price
(new-price old stock supply demand)
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.
run
(run world)
Return a world like this world
, with quantities and prices in markets updated to reflect supply and demand.
update-markets
(update-markets world)
(update-markets world city)
(update-markets world city commodity)
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.
Generated by Codox
The-great-game 0.1.1-SNAPSHOT
the-great-game.merchants.merchant-utils
Useful functions for doing low-level things with merchants.
add-known-prices
(add-known-prices merchant world)
Add the current prices at this merchant
’s location in the world
to a new cache of known prices, and return it.
add-stock
(add-stock a b)
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.
burden
(burden merchant world)
The total weight of the current cargo carried by this merchant
in this world
.
can-afford
(can-afford merchant world commodity)
Return the number of units of this commodity
which this merchant
can afford to buy in this world
.
can-carry
(can-carry merchant world commodity)
Return the number of units of this commodity
which this merchant
can carry in this world
, given their current burden.
expected-price
(expected-price merchant commodity city)
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.
Generated by Codox
The-great-game 0.1.2-SNAPSHOT
the-great-game.merchants.merchant-utils
Useful functions for doing low-level things with merchants.
add-known-prices
(add-known-prices merchant world)
Add the current prices at this merchant
’s location in the world
to a new cache of known prices, and return it.
add-stock
(add-stock a b)
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.
burden
(burden merchant world)
The total weight of the current cargo carried by this merchant
in this world
.
can-afford
(can-afford merchant world commodity)
Return the number of units of this commodity
which this merchant
can afford to buy in this world
.
can-carry
(can-carry merchant world commodity)
Return the number of units of this commodity
which this merchant
can carry in this world
, given their current burden.
expected-price
(expected-price merchant commodity city)
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.
Generated by Codox
The-great-game 0.1.1-SNAPSHOT
the-great-game.merchants.merchants
Trade planning for merchants, primarily.
Generated by Codox
The-great-game 0.1.2-SNAPSHOT
the-great-game.merchants.merchants
Trade planning for merchants, primarily.
Generated by Codox
The-great-game 0.1.1-SNAPSHOT
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.
augment-plan
(augment-plan merchant world 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.
Generated by Codox
The-great-game 0.1.2-SNAPSHOT
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.
augment-plan
(augment-plan merchant world 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.
generate-trade-plans
(generate-trade-plans merchant world commodity)
Generate all possible trade plans for this merchant
and this commodity
in this world
.
Returned plans are maps with keys:
-
diff --git a/docs/codox/the-great-game.merchants.strategies.simple.html b/docs/codox/the-great-game.merchants.strategies.simple.html
index e2b151a..9d2e4c7 100644
--- a/docs/codox/the-great-game.merchants.strategies.simple.html
+++ b/docs/codox/the-great-game.merchants.strategies.simple.html
@@ -1,4 +1,4 @@
-
Generated by Codox
The-great-game 0.1.1-SNAPSHOT
the-great-game.merchants.strategies.simple
Default trading strategy for merchants.
+Generated by Codox
The-great-game 0.1.2-SNAPSHOT
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.
move-merchant
(move-merchant merchant world)
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.
plan-and-buy
(plan-and-buy merchant world)
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.
re-plan
(re-plan merchant world)
Having failed to sell a cargo at current location, re-plan a route to sell the current cargo. Returns a revised world.
sell-and-buy
(sell-and-buy merchant world)
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.
Generated by Codox
The-great-game 0.1.1-SNAPSHOT
the-great-game.objects.container
TODO: write docs
ProtoContainer
protocol
members
contents
(contents container)
Return a sequence of the contents of this container
, or nil
if empty.
is-empty?
(is-empty? container)
Return true
if this container
is empty, else false
.
Generated by Codox
The-great-game 0.1.2-SNAPSHOT
the-great-game.objects.container
TODO: write docs
ProtoContainer
protocol
members
contents
(contents container)
Return a sequence of the contents of this container
, or nil
if empty.
is-empty?
(is-empty? container)
Return true
if this container
is empty, else false
.
Generated by Codox
The-great-game 0.1.1-SNAPSHOT
the-great-game.objects.game-object
Anything at all in the game world
ProtoObject
protocol
An object in the world
members
id
(id object)
Returns the unique id of this object.
reify-object
(reify-object object)
Adds this object
to the global object list. If the object
has a non-nil value for its id
method, keys it to that id - but if the id value is already in use, throws a hard exception. Returns the id to which the object is keyed in the global object list.
Generated by Codox
The-great-game 0.1.2-SNAPSHOT
the-great-game.objects.game-object
Anything at all in the game world
ProtoObject
protocol
An object in the world
members
id
(id object)
Returns the unique id of this object.
reify-object
(reify-object object)
Adds this object
to the global object list. If the object
has a non-nil value for its id
method, keys it to that id - but if the id value is already in use, throws a hard exception. Returns the id to which the object is keyed in the global object list.
Generated by Codox
The-great-game 0.1.1-SNAPSHOT
the-great-game.time
TODO: write docs
date-string
(date-string game-time)
Return a correctly formatted date for this game-time
in the calendar of the Great Place.
day-of-year
macro
(day-of-year game-time)
The day of the year represented by this game-time
, ignoring leap years.
days-of-week
The eight-day week of the game world. This differs from the canonical ordering of houses in that it omits the eye.
game-day-length
The Java clock advances in milliseconds, which is fine. But we need game-days to be shorter than real world days. A Witcher 3 game day is 1 hour 36 minutes, or 96 minutes, which is presumably researched. Round it up to 100 minutes for easier calculation.
game-time
(game-time)
(game-time timestamp)
With no arguments, the current game time. If a Java timestamp
value is passed (as a long
), the game time represented by that value.
now
(now)
For now, we’ll use Java timestamp for time; ultimately, we need a concept of game-time which allows us to drive day/night cycle, seasons, et cetera, but what matters about time is that it is a value which increases.
seasons-in-year
Nine seasons in a year, one for each house (although the order is different.
seasons-of-year
The ordering of seasons in the year is different from the canonical ordering of the houses, for reasons of the agricultural cycle.
weeks-in-season
To fit nine seasons of eight day weeks into 365 days, each must be of five weeks.
weeks-of-season
To fit nine seasons of eight day weeks into 365 days, each must be of five weeks.
Generated by Codox
The-great-game 0.1.2-SNAPSHOT
the-great-game.time
TODO: write docs
date-string
(date-string game-time)
Return a correctly formatted date for this game-time
in the calendar of the Great Place.
day-of-year
macro
(day-of-year game-time)
The day of the year represented by this game-time
, ignoring leap years.
days-of-week
The eight-day week of the game world. This differs from the canonical ordering of houses in that it omits the eye.
game-day-length
The Java clock advances in milliseconds, which is fine. But we need game-days to be shorter than real world days. A Witcher 3 game day is 1 hour 36 minutes, or 96 minutes, which is presumably researched. Round it up to 100 minutes for easier calculation.
game-time
(game-time)
(game-time timestamp)
With no arguments, the current game time. If a Java timestamp
value is passed (as a long
), the game time represented by that value.
now
(now)
For now, we’ll use Java timestamp for time; ultimately, we need a concept of game-time which allows us to drive day/night cycle, seasons, et cetera, but what matters about time is that it is a value which increases.
seasons-in-year
Nine seasons in a year, one for each house (although the order is different.
seasons-of-year
The ordering of seasons in the year is different from the canonical ordering of the houses, for reasons of the agricultural cycle.
weeks-in-season
To fit nine seasons of eight day weeks into 365 days, each must be of five weeks.
weeks-of-season
To fit nine seasons of eight day weeks into 365 days, each must be of five weeks.
Generated by Codox
The-great-game 0.1.1-SNAPSHOT
the-great-game.utils
TODO: write docs
deep-merge
(deep-merge & maps)
Recursively merges maps. Stolen from https://dnaeon.github.io/recursively-merging-maps-in-clojure/
make-target-filter
(make-target-filter targets)
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].
Generated by Codox
The-great-game 0.1.2-SNAPSHOT
the-great-game.utils
TODO: write docs
deep-merge
(deep-merge & maps)
Recursively merges maps. Stolen from https://dnaeon.github.io/recursively-merging-maps-in-clojure/
make-target-filter
(make-target-filter targets)
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].
Generated by Codox
The-great-game 0.1.1-SNAPSHOT
the-great-game.world.location
Functions dealing with location in the world.
get-coords
(get-coords location)
Return the coordinates in the game world of location
, which may be 1. A coordinate pair in the format {:x 5 :y 32}; 2. A location, as discussed above; 3. Any other gameworld object, having a :location
property whose value is one of the above.
Generated by Codox
The-great-game 0.1.2-SNAPSHOT
the-great-game.world.location
Functions dealing with location in the world.
get-coords
(get-coords location)
Return the coordinates in the game world of location
, which may be 1. A coordinate pair in the format {:x 5 :y 32}; 2. A location, as discussed above; 3. Any other gameworld object, having a :location
property whose value is one of the above.
Generated by Codox
The-great-game 0.1.1-SNAPSHOT
the-great-game.world.routes
Conceptual (plan level) routes, represented as tuples of location ids.
find-route
(find-route world-or-routes from to)
Find a single route from from
to to
in this world-or-routes
, which may be either a world as defined in the-great-game.world.world or else a sequence of tuples of keywords.
find-routes
(find-routes routes from)
(find-routes routes from to)
(find-routes routes from to steps)
Find routes from among these routes
from from
; if to
is supplied, to to
, by breadth-first search.
Generated by Codox
The-great-game 0.1.2-SNAPSHOT
the-great-game.world.routes
Conceptual (plan level) routes, represented as tuples of location ids.
find-route
(find-route world-or-routes from to)
Find a single route from from
to to
in this world-or-routes
, which may be either a world as defined in the-great-game.world.world or else a sequence of tuples of keywords.
find-routes
(find-routes routes from)
(find-routes routes from to)
(find-routes routes from to steps)
Find routes from among these routes
from from
; if to
is supplied, to to
, by breadth-first search.
Generated by Codox
The-great-game 0.1.1-SNAPSHOT
the-great-game.world.run
Run the whole simulation
run
(run world)
(run world date)
The pipeline to run the simulation each game day. Returns a world like this world, with all the various active elements updated. The optional date
argument, if supplied, is set as the :date
of the returned world.
Generated by Codox
The-great-game 0.1.2-SNAPSHOT
the-great-game.world.run
Run the whole simulation
run
(run world)
(run world date)
The pipeline to run the simulation each game day. Returns a world like this world, with all the various active elements updated. The optional date
argument, if supplied, is set as the :date
of the returned world.
Generated by Codox
The-great-game 0.1.1-SNAPSHOT
the-great-game.world.world
Access to data about the world
actual-price
(actual-price world commodity city)
Find the actual current price of this commodity
in this city
given this world
. NOTE that merchants can only know the actual prices in the city in which they are currently located.
run
(run world)
(run world date)
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.
Generated by Codox
The-great-game 0.1.2-SNAPSHOT
the-great-game.world.world
Access to data about the world
actual-price
(actual-price world commodity city)
Find the actual current price of this commodity
in this city
given this world
. NOTE that merchants can only know the actual prices in the city in which they are currently located.
run
(run world)
(run world date)
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.