Routines

A repeated action in Turberfield is called a routine. There is one for each of the rectangular boxes in the table above. You can also write your own. For now, well explain the ones which appear in the story of Eargain.

Exchange

Here’s how you would create regular goods-on-credit exchange between characters in a simulation.

loop = asyncio.get_event_loop()

# Bits and pieces from turberfield.common
dramatics = Dramatics()
jq = JobQueue(loop=loop)

# The characters have to meet in the same place
tavern = Location("quarry", "furlong", "tavern", None)

# The characters' need to buy or sell is stored as a Drama
dramatics.relations[merchant, Commodity.STON].add(TradePosition.buying)
dramatics.relations[miner, Commodity.FOOD].add(TradePosition.buying)
dramatics.relations[merchant, Commodity.FOOD].add(TradePosition.selling)
dramatics.relations[miner, Commodity.STON].add(TradePosition.selling)

routine = Exchange(merchant, miner, meet=tavern)

tasks = [Simulation.task(loop, routine, jq)]
sim = Simulation(tasks, jq, buf)
class turberfield.eargain.exchange.Exchange(*args, start: int=None, end: int=None, period: int=None, meet: turberfield.common.inventory.Location=None)[source]

Trade

class turberfield.eargain.trade.Trade(*args, start: int=None, end: int=None, period: int=None, meet: turberfield.common.inventory.Location=None)[source]