Initial commit. A start has been made, but nothing works yet.

This commit is contained in:
Simon Brooke 2023-07-18 22:31:57 +01:00
commit 72d9326216
65 changed files with 3179 additions and 0 deletions

View file

@ -0,0 +1,59 @@
## Basic ruleset which just grows trees
;; This ruleset is not very interesting in itself, but is useful as a starting
;; point from which to build more interesting rulesets.
## Vegetation rules
;; rules which populate the world with plants
;; Occasionally, passing birds plant tree seeds into grassland
if state is grassland then 1 chance in 10 state should be heath
;; heath below the treeline grows gradually into forest
if state is heath and altitude is less than 120 then state should be scrub
if state is scrub then 1 chance in 5 state should be forest
;; Forest on fertile land grows to climax
if state is forest and fertility is more than 5 and altitude is less than 70 then state should be climax
;; Climax forest occasionally catches fire (e.g. lightning strikes)
if state is climax then 1 chance in 500 state should be fire
;; Climax forest neighbouring fires is likely to catch fire
if state is climax and some neighbours are fire then 1 chance in 3 state should be fire
;; After fire we get waste
if state is fire then state should be waste
;; And after waste we get pioneer species; if there's a woodland seed
;; source, it's going to be heath, otherwise grassland.
if state is waste and some neighbours are scrub then state should be heath
if state is waste and some neighbours are forest then state should be heath
if state is waste and some neighbours are climax then state should be heath
if state is waste then state should be grassland
## Potential blockers
;; Forest increases soil fertility.
if state is in forest or climax then fertility should be fertility + 1
## Initialisation rules
;; Rules which deal with state 'new' will waste less time if they're near the
;; end of the file
;; below the waterline we have water.
if state is new and altitude is less than 10 then state should be water
;; above the snowline we have snow.
if state is new and altitude is more than 200 then state should be snow
;; otherwise, we have grassland.
if state is new then state should be grassland

View file

@ -0,0 +1,39 @@
# Conway's Game of Life is the classic cellular automaton.
;; see http://en.wikipedia.org/wiki/Conway's_Game_of_Life
;; This ruleset works with any strictly black and white map, but the maps which
;; are designed to work with it have names starting 'life'.
;; The universe of the Game of Life is an infinite two-dimensional orthogonal
;; grid of square cells, each of which is in one of two possible states, alive
;; or dead, represented in this ruleset by 'black' and 'white' respectively.
;; Every cell interacts with its eight neighbours, which are the
;; cells that are horizontally, vertically, or diagonally adjacent.
;; Although this ruleset is superficially simple, it runs very slowly, because
;; all the rules depend on neighbours, which makes them more expensive to
;; compute.
;; At each step in time, the following transitions occur:
;; Any live cell with fewer than two live neighbours dies, as if caused by
;; under-population.
if state is black and fewer than 2 neighbours are black then state should be white
;; Any live cell with two or three live neighbours lives on to the next generation.
;; Any live cell with more than three live neighbours dies, as if by overcrowding.
if state is black and more than 3 neighbours are black then state should be white
;; Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
if state is not black and 3 neighbours are black then state should be black
# Initialisation rules
if state is new and altitude is more than 127 then state should be black
if state is new then state should be white

View file

@ -0,0 +1,99 @@
## Ruleset which attempts to model predator/prey ecology (not very well yet)
## Vegetation rules
;; rules which populate the world with plants
;; Occasionally, passing birds plant tree seeds into grassland
if state is grassland then 1 chance in 10 state should be heath
;; heath below the treeline grows gradually into forest, providing browsing pressure is not to high
if state is heath and deer are fewer than 6 and altitude is less than 120 then state should be scrub
if state is scrub then 1 chance in 5 state should be forest
;; Forest on fertile land at low altitude grows to climax
if state is forest and fertility is more than 5 and altitude is less than 70 then state should be climax
;; Climax forest occasionally catches fire (e.g. lightning strikes)
if state is climax then 1 chance in 500 state should be fire
;; Climax forest neighbouring fires is likely to catch fire
if state is climax and some neighbours are fire then 1 chance in 3 state should be fire
;; After fire we get waste
if state is fire then state should be waste
;; And after waste we get pioneer species; if there's a woodland seed
;; source, it's going to be heath, otherwise grassland.
if state is waste and some neighbours are scrub then state should be heath
if state is waste and some neighbours are forest then state should be heath
if state is waste and some neighbours are climax then state should be heath
if state is waste then state should be grassland
## Herbivore rules
;; rules describing the impact of herbivores on the environment
;; if there are too many deer for the fertility of the area to sustain,
;; some die or move on.
;; if deer are more than fertility then deer should be fertility / 2
;; deer arrive occasionally at the edge of the map.
if x is 0 or y is 0 and deer are 0 then 1 chance in 50 deer should be 2
;; deer gradually spread through the world by breeding or migrating.
if fertility is more than 10 and deer is 0 and some neighbours have deer more than 2 then deer should be 2
;; deer breed.
if deer are more than 1 then deer should be deer * 2
## Predator rules
;; rules describing the impact of predator behaviour on the environment
if deer are more than wolves then deer should be deer - wolves
;; if there are not enough deer to sustain the population of wolves,
;; some wolves die or move on.
if wolves are more than deer then deer should be 0 and wolves should be deer + 0
;; wolves arrive occasionally at the edge of the map.
if x is 0 or y is 0 and wolves are 0 then 1 chance in 50 wolves should be 2
;; wolves gradually spread through the world by breeding or migrating.
if state is not water and wolves is 0 and some neighbours have wolves more than 2 then 1 chance in 5 wolves should be 2
;; wolves breed.
if wolves are more than 1 then wolves should be wolves * 2
## Potential blockers
;; Forest increases soil fertility.
if state is in forest or climax then fertility should be fertility + 1
## Initialisation rules
;; Rules which deal with state 'new' will waste less time if they're near the
;; end of the file
;; below the waterline we have water.
if state is new and altitude is less than 10 then state should be water
;; above the snowline we have snow.
if state is new and altitude is more than 200 then state should be snow
;; otherwise, we have grassland.
if state is new then state should be grassland

View file

@ -0,0 +1,4 @@
;; 'run once' ruleset to be run after (e.g.) settlement to establish harbours
;; Doesn't work yet, need to find out why and fix it!
if state is water and more than four neighbours are not water and some neighbours are house then state should be harbour

View file

@ -0,0 +1,65 @@
## Ruleset which attempts to model retreat of ice after an iceage
;; Limitations: because the rule language doesn't (yet) allow sophisticated
;; arithmetic, the ice retreats north to south (southern hemisphere). Otherwise,
;; it's pretty realistic; ice moves progressively up hillsides, and vegetation
;; gradually re-establishes.
## Vegetation rules
;; rules which populate the world with plants
;; Occasionally, passing birds plant tree seeds into grassland
if state is grassland then 1 chance in 10 state should be heath
;; heath below the treeline grows gradually into forest, providing browsing pressure is not to high
if state is heath and fertility is more than 10 and altitude is less than 120 then state should be scrub
if state is scrub and fertility is more than 20 then 1 chance in 20 state should be forest
;; Forest on fertile land grows to climax
if state is forest and fertility is more than 30 and altitude is less than 70 then state should be climax
;; Climax forest occasionally catches fire (e.g. lightning strikes)
if state is climax then 1 chance in 500 state should be fire
;; Climax forest neighbouring fires is likely to catch fire
if state is climax and some neighbours are fire then 1 chance in 3 state should be fire
;; After fire we get waste
if state is fire then state should be waste
;; And after waste we get pioneer species; if there's a woodland seed
;; source, it's going to be heath, otherwise grassland.
if state is waste and some neighbours are scrub then state should be heath
if state is waste and some neighbours are forest then state should be heath
if state is waste and some neighbours are climax then state should be heath
if state is waste then state should be grassland
## Potential blockers
;; Woody plants increase soil fertility over time.
if state is in heath or scrub or forest or climax then fertility should be fertility + 1
## Initialisation rules
;; Rules which deal with state 'new' will waste less time if they're near the
;; end of the file
if state is new then state should be ice
;; thaw moves gradually southwards (the distinction between 'ice' and 'snow' is
;; just a hack because I can't do complex arithmetic in rules)
;; below the waterline ice thaws to water.
if state is ice and generation is more than y and altitude is less than 10 then state should be water
;; otherwise it thaws to snow
if state is ice and generation is more than y then state should be snow
;; thaw moves gradually up the hills
if state is snow and generation is more than altitude then state should be waste

View file

@ -0,0 +1,156 @@
# Human settlement
;; This rule set attempts to model human settlement in a landscape. It models
;; western European pre-history moderately well. Settlement first occurs as
;; nomadic camps on coastal promentaries (cells with four or more neighbours
;; that are water). This represents 'kitchen-midden' mesolithic settlement.
;;
;; As grassland becomes available near camps, pastoralists appear, and will
;; follow their herds inland. When pastoralists have available fertile land,
;; they will till the soil and plant crops, and in doing so will establish
;; permanent settlements; this is approximately a neolithic stage.
;;
;; Where soil is fertile, settlements will cluster, and markets will appear.
;; where there is sufficient settlement, the markets become permanent, and you
;; have the appearance of towns. This takes us roughly into the bronze age.
;;
;; This is quite a complex ruleset, and runs quite slowly. However, it does
;; model some significant things. Soil gains in fertility under woodland; deep
;; loams and podzols build up over substantial time. Agriculture depletes
;; fertility. So if forest has become well established before human settlement
;; begins, a higher population (more crops) will eventually be sustainable,
;; whereas if human population starts early the deep fertile soils will not
;; establish and you will have more pastoralism, supporting fewer permanent
;; settlements.
;; hack to speed up processing on the 'great britain and ireland' map
if state is water then state should be water
;; nomads make their first significant camp near water because of fish and
;; shellfish (kitchen-midden people)
if state is in grassland or heath and more than 3 neighbours are water and generation is more than 20 then state should be camp
;; sooner or later nomads learn to keep flocks
if state is in grassland or heath and some neighbours are camp then 1 chance in 2 state should be pasture
;; and more herds support more people
if state is in grassland or heath and more than 2 neighbours are pasture then 1 chance in 3 state should be camp
if state is pasture and more than 3 neighbours are pasture and fewer than 1 neighbours are camp and fewer than 1 neighbours within 2 are house then state should be camp
;; the idea of agriculture spreads
if state is in grassland or heath and some neighbours within 2 are house then state should be pasture
;; nomads don't move on while the have crops growing. That would be silly!
if state is camp and some neighbours are ploughland then state should be camp
;; Impoverished pasture can't be grazed permanently
if state is pasture and fertility is less than 2 then 1 chance in 3 state should be heath
;; nomads move on
if state is camp then 1 chance in 5 state should be waste
;; pasture that's too far from a house or camp will be abandoned
if state is pasture and fewer than 1 neighbours within 3 are house and fewer than 1 neighbours within 2 are camp then state should be heath
;; markets spring up near settlements
if state is in grassland or pasture and more than 1 neighbours are house then 1 chance in 10 state should be market
;; good fertile pasture close to settlement will be ploughed for crops
if state is pasture and fertility is more than 10 and altitude is less than 100 and some neighbours are camp or some neighbours are house then state should be ploughland
if state is ploughland then state should be crop
;; after the crop is harvested, the land is allowed to lie fallow. But cropping
;; depletes fertility.
if state is crop then state should be grassland and fertility should be fertility - 1
;; if there's reliable food available, nomads build permanent settlements
if state is in camp or abandoned and some neighbours are crop then state should be house
if state is abandoned and some neighbours are pasture then state should be house
;; people camp near to markets
if state is in waste or grassland and some neighbours are market then state should be camp
;; a market in a settlement survives
if state is market and some neighbours are inn then state should be market
if state is market then state should be grassland
;; a house near a market in a settlement will become an inn
if state is house and some neighbours are market and more than 1 neighbours are house then 1 chance in 5 state should be inn
;; but it will need some local custom to survive
if state is inn and fewer than 3 neighbours are house then state should be house
;; if there aren't enough resources houses should be abandoned
;; resources from fishing
if state is house and more than 2 neighbours are water then state should be house
;; from farming
if state is house and some neighbours are pasture then state should be house
if state is house and some neighbours are ploughland then state should be house
if state is house and some neighbours are crop then state should be house
;; from the market
if state is house and some neighbours are market then state should be house
if state is house then 1 chance in 2 state should be abandoned
if state is abandoned then 1 chance in 5 state should be waste
## Vegetation rules
;; rules which populate the world with plants
;; Occasionally, passing birds plant tree seeds into grassland
if state is grassland then 1 chance in 10 state should be heath
;; heath below the treeline grows gradually into forest
if state is heath and altitude is less than 120 then state should be scrub
if state is scrub then 1 chance in 5 state should be forest
;; Forest on fertile land grows to climax
if state is forest and fertility is more than 5 and altitude is less than 70 then state should be climax
;; Climax forest occasionally catches fire (e.g. lightning strikes)
if state is climax then 1 chance in 500 state should be fire
;; Forest neighbouring fires is likely to catch fire. So are buildings.
if state is in forest or climax or camp or house or inn and some neighbours are fire then 1 chance in 3 state should be fire
;; Climax forest near to settlement may be cleared for timber
if state is in climax and more than 3 neighbours within 2 are house then state should be scrub
;; After fire we get waste
if state is fire then state should be waste
;; waste near settlement that is fertile becomes ploughland
if state is waste and fertility is more than 10 and some neighbours are house or some neighbours are camp then state should be ploughland
;; And after waste we get pioneer species; if there's a woodland seed
;; source, it's going to be heath, otherwise grassland.
if state is waste and some neighbours are scrub then state should be heath
if state is waste and some neighbours are forest then state should be heath
if state is waste and some neighbours are climax then state should be heath
if state is waste then state should be grassland
## Potential blockers
;; Forest increases soil fertility.
if state is in forest or climax then fertility should be fertility + 1
## Initialisation rules
;; Rules which deal with state 'new' will waste less time if they're near the
;; end of the file
;; below the waterline we have water.
if state is new and altitude is less than 10 then state should be water
;; above the snowline we have snow.
if state is new and altitude is more than 200 then state should be snow
;; otherwise, we have grassland.
if state is new then state should be grassland

View file

@ -0,0 +1,150 @@
# Human settlement
;; This rule set adds ideas aboutv rainfall and river drainage to the human settlement ruleset.
;; This depends on transforming the world with the drainage functions before starting running
;; the rule set, and that isn't done by default because it is computationally expensive.
;; hack to speed up processing on the 'great britain and ireland' map
if state is sea then state should be sea
;; nomads make their first significant camp near sea because of fish and
;; shellfish (kitchen-midden people)
if state is in grassland or heath and more than 3 neighbours are sea and generation is more than 20 then state should be camp
;; sooner or later nomads learn to keep flocks
if state is in grassland or heath and some neighbours are camp then 1 chance in 2 state should be pasture
;; and more herds support more people
if state is in grassland or heath and more than 2 neighbours are pasture then 1 chance in 3 state should be camp
if state is pasture and more than 3 neighbours are pasture and fewer than 1 neighbours are camp and fewer than 1 neighbours within 2 are house then state should be camp
;; the idea of agriculture spreads
if state is in grassland or heath and some neighbours within 2 are house then state should be pasture
;; nomads don't move on while the have crops growing. That would be silly!
if state is camp and some neighbours are ploughland then state should be camp
;; Impoverished pasture can't be grazed permanently
if state is pasture and fertility is less than 2 then 1 chance in 3 state should be heath
;; nomads move on
if state is camp then 1 chance in 5 state should be waste
;; pasture that's too far from a house or camp will be abandoned
if state is pasture and fewer than 1 neighbours within 3 are house and fewer than 1 neighbours within 2 are camp then state should be heath
;; markets spring up near settlements
if state is in grassland or pasture and more than 1 neighbours are house then 1 chance in 10 state should be market
;; good fertile pasture close to settlement will be ploughed for crops
if state is pasture and fertility is more than 10 and altitude is less than 100 and some neighbours are camp or some neighbours are house then state should be ploughland
if state is ploughland then state should be crop
;; after the crop is harvested, the land is allowed to lie fallow. But cropping
;; depletes fertility.
if state is crop then state should be grassland and fertility should be fertility - 1
;; if there's reliable food available, nomads build permanent settlements
if state is in camp or abandoned and some neighbours are crop then state should be house
if state is abandoned and some neighbours are pasture then state should be house
;; people camp near to markets
if state is in waste or grassland and some neighbours are market then state should be camp
;; a market in a settlement survives
if state is market and some neighbours are inn then state should be market
;; a market at a river mouth survives
if state is market and some neighbours are navigable and some neighbours are sea then state should be market
;; otherwise markets are transitory
if state is market then state should be grassland
;; a house near a market in a settlement will become an inn
if state is house and some neighbours are market and more than 1 neighbours are house then 1 chance in 5 state should be inn
;; but it will need some local custom to survive
if state is inn and fewer than 3 neighbours are house then state should be house
;; if there aren't enough resources houses should be abandoned
;; resources from fishing
if state is house and more than 2 neighbours are sea then state should be house
;; from farming
if state is house and some neighbours are pasture then state should be house
if state is house and some neighbours are ploughland then state should be house
if state is house and some neighbours are crop then state should be house
;; from the market
if state is house and some neighbours are market then state should be house
if state is house then 1 chance in 2 state should be abandoned
if state is abandoned then 1 chance in 5 state should be waste
## Vegetation rules
;; rules which populate the world with plants
;; Occasionally, passing birds plant tree seeds into grassland
if state is grassland then 1 chance in 10 state should be heath
;; heath below the treeline grows gradually into forest
if state is heath and altitude is less than 120 then state should be scrub
if state is scrub then 1 chance in 5 state should be forest
;; Forest on fertile land grows to climax
if state is forest and fertility is more than 5 and altitude is less than 70 then state should be climax
;; Climax forest occasionally catches fire (e.g. lightning strikes)
if state is climax then 1 chance in 500 state should be fire
;; Forest neighbouring fires is likely to catch fire. So are buildings.
if state is in forest or climax or camp or house or inn and some neighbours are fire then 1 chance in 3 state should be fire
;; Climax forest near to settlement may be cleared for timber
if state is climax and more than 3 neighbours within 2 are house then state should be scrub
;; After fire we get waste
if state is fire then state should be waste
;; waste near settlement that is fertile becomes ploughland
if state is waste and fertility is more than 10 and some neighbours are house or some neighbours are camp then state should be ploughland
;; And after waste we get pioneer species; if there's a woodland seed
;; source, it's going to be heath, otherwise grassland.
if state is waste and some neighbours are scrub then state should be heath
if state is waste and some neighbours are forest then state should be heath
if state is waste and some neighbours are climax then state should be heath
if state is waste then state should be grassland
## Rivers connected to the sea are navigable
if state is river and some neighbours are sea then state should be navigable
if state is river and some neighbours are navigable then state should be navigable
## Where navigable water meets the sea, ports are probable
if state is in grassland or heath or scrub and some neighbours are sea and some neighbours are navigable and some neighbours are house then state should be market
## Potential blockers
;; Forest increases soil fertility.
if state is in forest or climax then fertility should be fertility + 1
## Initialisation rules
;; Rules which deal with state 'new' will waste less time if they're near the
;; end of the file
;; below the high-tide line we have sea.
if state is new and altitude is less than 10 then state should be sea
;; above the high-tide line, there's a threshold of water pressure above which we have rivers
;; the actual threshold will need tuning, 30 is a guess.
if state is new and flow is more than 30 then state should be river
;; above the snowline we have snow.
if state is new and altitude is more than 200 then state should be snow
;; otherwise, we have grassland.
if state is new then state should be grassland