A repository for managing projects and code related to Vanderbilt's CS-5260 - Artificial Intelligence
The primary project contained in this repository is a world trader simulation used to explore and experiment with AI search strategies.
-
Clone the repo OR download the source code as a zip file and extract it.
-
Navigate to the WorldTraderSim directory
cd CS-5260/WorldTraderSim
- Initialize a virtual environment and install dependencies.
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
- Run
main.py
to generate a schedule (a full arguments list is included below).
python src/WorldTraderSim/main.py
- Graph the best schedule using
graph_schedule.py
.
python src/WorldTraderSim/graph_schedule.py
Both the default parameters AND configuration options have been set to the currently best performing settings.
The following arguments are supported to change simulation behavior:
Name | Flags | Usage | Default |
---|---|---|---|
Country Name | -c, --country-name | Sets the self country the AI agent will use | Atlantis |
State Directory | -s, --state-dir | Sets the directory that contains the state files | SCRIPT_PATH+"/data/states/" |
Resources File | -r, --resources-file | CSV file containing resource definitions | resources.csv |
Initial State File | -i, --initial-state-file | CSV file containing the initial game state | initial.csv |
Output File | -o, --output-file | File to write schedules generated by the AI agent | schedules.txt |
Number of Schedules | -n, --num-schedules | How many schedules to generate | 1 |
Depth Bound | -d, --depth-bound | How deep to search the graph | 100 |
Frontier Size | -f, --frontier-size | Maximum size of the frontier | 20000 |
Config | --config | File to configure global options | SCRIPT_PATH+"/config.ini" |
Log Level | -l, --log-level | How verbose logging output will be | 20 (INFO) |
NOTE: If increasing depth-bound, pay attention to logs to see whether the "Max Frontier Length" is staying under "Max Frontier Size". When the frontier size cannot grow to accomodate newly expanded nodes, the output of search strategies can be impacted. While the performance can be better, the results often aren't. This is particularly true for the default search strategy, HeuristicDepthFirstSearch.
Using a configuratoin file, the following global options can be changed:
Section | Option | Usage | Default |
---|---|---|---|
Actions | Shuffle | Shuffle the list of all actions to avoid deterministic outcomes | True |
Actions | TransferQuantityMax | Creates Transfer Actions for resource quantities of 1 -> MAX | 5 |
Actions | TransformQuantityMax | Creates Transform Actions for resource quantities of 1 -> MAX | 1 |
Search | Strategy | The SearchStrategy class to use | HeuristicDepthFirstSearch |
Search | EnableReached | Whether a search strategy will use a reached structure during search | True |
ScheduleEvaluation | FailedImpact | Penalty multiplied by schedule failure probability (C) | -0.35 |
ScheduleEvaluation | LengthImpact | Exponentially decreases the expected utility of a schedule over time (gamma) | 0.999 |
ScheduleEvaluation | LogisticFunctionMidpoint | Changes the likelihood a schedule will be successful, zero is neutral (x_0) | -1 |
ScheduleEvaluation | LogisticFunctionGrowth | Changes how significantly a delta in discounted reward moves success probability (k) | 1 |
ScheduleEvaluation | ForceSelfAccept | Force the agent country to always accept its own schedule | False |