An open API service indexing awesome lists of open source software.

https://github.com/treeplate/computer_factory


https://github.com/treeplate/computer_factory

Last synced: about 2 months ago
JSON representation

Awesome Lists containing this project

README

          

# Box Factory
## Principle
There are several bots with inventories who trade, craft, etc.
They can:
- trade with eachother
- farm cows or sheep (adds one cow/sheep to inv)
- chop wood (add one log to inv)
- mine gold (add one gold ore to inv)
- craft 1 box for 12 planks
- craft 4 planks from 1 log
- craft 1 coin from 1 gold ore

There is also you, a user, who can do all the same things except trading.

"farmer" farms cows and sheep and gives them to "boxmaker".
"boxmaker" trades 3 cows 1 sheep to #2 for 1 plank, makes boxes from 12 planks, and sells to #3 for 3 coins.
"woodcutter" chops wood, turns logs into 4 planks, trades 1 plank to #1 for 3 cows 1 sheep.
"miner" mines gold, crafts coins from gold, and buys boxes from #1 for 3 coins.
"user" is you.

Some of these give multiple sets of resources before the first response set is received, e.g. the miner gives a lot of coins before getting any boxes.
## Protocol
Tuples, starting with a string, are sent from client to server to request a trade/farm/craft/etc.
Server sends back a tuple starting with a string.
### Client To Server
- ("index")

Server sends index of player (used for trading)
- ("farm", "cow"/"sheep")
- ("chop")
- ("mine")
- ("craft", "coin"/"planks"/"box")
- ("trade", index, "cow"/"sheep"/"coin"/"planks"/"log"/"goldOre"/"box", amount)

send \x\<$3> to \ isolate.
- ("getInv", "cow"/"sheep"/"coin"/"planks"/"log"/"goldOre"/"box")
### Server To Client
- ("invalid", "type", "must be record or string")

Client did not send a record or a string (one-argument records are actually strings).
- ("invalid", "action")

Starting string was not valid action, or record had wrong shape for that action.
- ("invalid", "index")

`trade` did not send a valid person index
- ("invalid", "item")

Invalid item / cannot farm/craft this item
- ("invalid", "amount")

Traded more of an item then the client has, or a negative amount.
- ("invalid", "craft-attempt")

Client does not have the resources to craft what they attempted to.
- ("success")

Did what the client asked.
- (index)

In response to client's "index"
- (amount)

In response to client's "getInv"