Skip to content

aphorism44/economyModel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a Maven Spring Boot project, initially created as an Eclipse "Java Project," then converted to an Eclipse "Maven project." The POM file is at root level.

MAIN CLASS: src/main/java/Main.java (you can run this as a Java app in Eclipse)
CONTROLLER CLASS: src/main/java/controllers/MarketController.java
INSTANTIATED BEAN: src/main/java/models/Market.java

This REST API controls a model economy based on this paper:

https://larc.unt.edu/techreports/LARC-2010-03.pdf

A full explanation of this model, and how it was designed, is available in this blog entry:

https://wordpress.com/post/aphorism44.wordpress.com/609


One instance of the "Market" Bean is instantiated within Spring Boot.

There are currently five different agents types defined:

1. "farmer" (produces food)
2. "lumberjack" (produces wood)
3. "miner" (produces ore)
4. "refiner" (changes ore to metal)
5. "blacksmith" (changes metal to tools)

All of the agents consume food on a daily basis (with the exception of the farmer, which consumes wood).

All of the agents must have 1 tool in inventory to produce at top capacity (with the exception of the blacksmith, which produces tools).

The initial setup for the agent Production Rules is configurable with the following file:

/src/main/resources/productionData.csv

The REST API has 4 resources:

1. GET STATUS

"/status"

Outputs the status of the market at this particular iteration/turn. Currently the turn number, number of agents, and breakdown of agents by type.

EXAMPLE OUTPUT:

{ turnNumber: 151,
totalAgents: 4,
farmer: 1,
lumberjack: 1,
miner: 1,
blacksmith: 1 }


2. GET PRICES

"/prices?commodity=string"

Output the names and market value of the parameter commodity; if send without any commodity, it will output for all commodities.

EXAMPLE OUTPUTS:

{ food: 20,
wood: 13,
ore: 13,
metal: 37,
tools: 41 }

{ food: "35" }

3. ADD AGENT TYPES

"/add?agentType=s"

Adds 1 agent of the type specified by the string s (one of the 5 above choices, or it will return an error message).

EXAMPLE OUTPUTS:

{ response: "added 1 agent of type farmer" }

{ response: "there is no agent template for type toymaker" }

4. ITERATE TURNS

"/iterate?turns=n"

Iterates the market by n "turns."

EXAMPLE OUTPUT:

{ response: "iterated 5 turns" }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages