diff --git a/README.md b/README.md index 00f1284c22e5ef2db9680effdc17d66aae8c3bef..d8e0921aa813e7e3133e92ecd9ba39e6b5e6f378 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,48 @@ # Dec-MCTS Python implementation of Dec-MCTS + +### Installation +```bash +pip install git+https://code.research.uts.edu.au/bigprint/pydecmcts.git +``` + +### Usage + +```python +from DecMCTS import Tree + +# data can be anything required to calculate your +# global reward and available actions +data = {} + +# Create an available actions function +# This returns a list of possible actions to take from a given state +# state input explained next +def avail_actions(data, state): + + # This example is simply getting max sum, + # options are same regardless of state + return [1,2,3,4,5] + +# Create a reward function. This is the global reward given a list of +# actions taken by the current robot, and every other robot +# State is a dictionary with keys being robot IDs, and values +# are a list of actions taken from the starting position +def reward(dat, state): + each_robot_sum = [sum(state[1][a]) for a in state[1]] + return sum(each_robot_sum) + +# Number of Action Sequences to communicate +comm_n = 5 + +# Create instances for each robot +tree1 = Tree(data, reward, avail_actions, comm_n, 1) # Robot ID is 1 +tree2 = Tree(data, reward, avail_actions, comm_n, 2) # Robot ID is 2 + +for i in range(350): + tree1.grow() + tree2.grow() + tree1.receive_comms(tree2.send_comms(), 2) #send comms message doesn't have ID in it + tree2.receive_comms(tree2.send_comms(), 1) +```