Comments (2)
Just a quick note that the double for loop in the Simulation class will have to change. Right now it advances each village through time, independently. ie it runs village A for 10 years, then runs village B for 10 years when it should run village A for 1 year, then run village B for run year, then back to A, etc
from villager.
After discussing it with Marcus, the trade was originally designed to be in a subclassed village. This is no longer the case, and trade is officially not supported at this moment.
We Currently Have
- The ability to connect two villages for trade with add_trade_partner.
- A skeleton method for executing trade algorithms, trade
We Don't Have
- The ability to add custom functions that dictate trade behavior to the village
- The logic that actually executes the trade (the contents of
trade()
)
Adding Custom Functions
I think it makes the most sense to do this with add_trade_partner
. This method becomes
add_trade_partner = function(newTradePartner, trade_model, addBack=TRUE)
. This ties a particular trade model to that village. By pairing the village to the algorithm (village, trade_algo) you can have different dynamics between villages.
The tuple should then be added so some sort of list that belongs in villager
, like models.
Running the Trade Models
Once the models are stored, you'll want to run them at each time step. Note that the logic for whether it's a trading day (ie a festival) is in the trade model code.
I believe the trade()
method in villager is there for historical reasons. This was the method that subclassed villages subclassed with their trade logic.
There are a couple of ways to do this.
Same way as propagate()
Loop over the trade functions and call them in the trade()
method, and call village$trade()
in the simulation class. If you put the call before the call to propagate, then the trade is done at the beginning of time step (day, month, year). If it goes after, then it's at the end of the year, month, day, etc.
Call from propagate
You can also put the logic in propagate()
. You can also call trade()
from propagate and skip the Simulator class
Which One?
There's a nice sense of division of responsibility in the first way. But the second way has a sense of elegance in that just a single call to the village propagates it through time. Your call!
from villager.
Related Issues (20)
- Tidy up the DESCRIPTION File HOT 1
- Increase Test Coverage of village_state and village HOT 1
- Write the code documentation HOT 1
- Look into List Copying
- Help Wanted: Code Review HOT 1
- Add support for variadic parameters in add_resource & add_winik
- Add support for user defined data writing HOT 1
- Add support for retrieving all of the resources in a resource manager HOT 1
- Check minimum dependencies HOT 1
- Add Community Guidelines HOT 1
- Run tests and code coverage with github actions HOT 1
- Replace the gregorian package HOT 2
- Add paper to new branch
- Add new badges HOT 1
- make a logo HOT 3
- Update license for JOSS HOT 3
- Some confusing conventions HOT 2
- Add a new example
- Update Paper HOT 1
- Error in self$initial_condition(self$current_state, self$model_data, self$winik_mgr, : object 'agent' not found HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from villager.