Package: civrealm
CivRealm: A Learning and Reasoning Odyssey inCivilizationfor Decision-Making Agents[Arxiv][PDF][Docs][LLM Agents][Tensor Agent]CivRealm is an interactive environment for the open-source strategy gameFreeciv-web, based onFreeciv, a Civilization-like game. Within CivRealm, we provide interfaces for two typical types of agents: tensor-based reinforcement learning agents (seeTensor-agent Repo) based on theGymnasiumAPI, and language-based agents (seeLLM-agent Repo) driven by language models.We also provide a set of tools for training and evaluating agents, as well as a set of baselines for both types of agents. We hope that CivRealm can serve as a testbed for the development and evaluation of agents that can learn and reason in complex environments. Detailed usage of the CivRealm API can be found in theDocumentation.ContentsAboutPrerequisitesInstallationTesting the InstallationSingle player mode (against built-in AIs)Multiplayer modeTrouble ShootingOur PaperAboutCivRealm is developed based onfreeciv-bot, dependent onfreeciv-webandFCIV-NET.
In the future, CivRealm will be maintained byBIGAI.PrerequisitesCivRealm requires Python≥ 3.8and docker. We have tested on Ubuntu 22.04, Mac OS X, and Windows. To test CivRealm onhttp://localhost, please follow the docker installation instructions onhttps://gitlab.mybigai.ac.cn/civilization/freeciv-web.git.InstallationYou can install the CivRealm stable version by:pipinstallcivrealmTo install the latest version from the source code or contribute to the project, please follow the instructions below:gitclonessh://git@gitlab.mybigai.ac.cn:2222/civilization/civrealm.git&&cdcivrealm
pipinstall-e.Testing the InstallationBefore testing the installation, please make sure that the freeciv-web service is running. You can check the status of the freeciv-web service by running:dockerpsYou should see a docker container namedfreeciv-webrunning.Single player mode (against built-in AIs)To test the installation, run the following command after installation. This will start a single player game against the built-in AIs with the default settings.test_civrealm!!! success
If the installation is successful, the output should be similar to the following:```bash
Reset with port: 6300
Step: 0, Turn: 1, Reward: 0, Terminated: False, Truncated: False, action: ('unit', 104, 'move NorthEast')
Step: 1, Turn: 1, Reward: 0, Terminated: False, Truncated: False, action: ('unit', 117, 'move North')
Step: 2, Turn: 1, Reward: 0, Terminated: False, Truncated: False, action: ('unit', 118, 'move North')
Step: 3, Turn: 1, Reward: 0, Terminated: False, Truncated: False, action: ('unit', 119, 'move SouthEast')
Step: 4, Turn: 1, Reward: 0, Terminated: False, Truncated: False, action: ('unit', 120, 'move SouthEast')
```Multiplayer modeTo test with multiple players, run the following command in a terminal to start the game with playermyagent:test_civrealm--minp=2--username=myagent--client_port=6001Then start another terminal and join the game with playermyagent1:test_civrealm--username=myagent1--client_port=6001Trouble ShootingThe following are some common issues that you may encounter when running the code. If you encounter any other issues, please feel free to open an issue.If firefox keeps loading the page, please try to add the following line to/etc/hosts:127.0.0.1maxcdn.bootstrapcdn.com127.0.0.1cdn.webglstats.comIf you encounter the following error when runningsudo civ_prep_selenium.sh, please trythis solution....
Thefollowingpackageshaveunmetdependencies:
containerd.io:Conflicts:containerdConflicts:runc
...If you see the following error when runningtest_civrealm,  please seethis solution. If this does not solve the problem, please checkgeckodriver.logfor more information.selenium.common.exceptions.WebDriverException:Message:Processunexpectedlyclosedwithstatus1One potential solution on Ubuntu 22.04 is:sudoaptinstallfirefox-geckodriver
ln-s/snap/bin/firefox.geckodrivergeckodriverIf you see the following error when settingtake_screenshot: True, it is caused by snap version of Firefox. Please trySystem Firefox installation.YourFirefoxprofilecannotbeloaded.Itmaybemissingorinaccessible.If the screenshot is not centered on the location of your first unit, it is because you are using multiple displays. Please ensure the Firefox browser for screenshot pops up on your primary display.Check out our paperOur paper is available onArxiv. If you find our code or databases useful, please consider citing us:@inproceedings{qi2024civrealm,title={CivRealm: A Learning and Reasoning Odyssey in Civilization for Decision-Making Agents},author={Siyuan Qi and Shuo Chen and Yexin Li and Xiangyu Kong and Junqi Wang and Bangcheng Yang and Pring Wong and Yifan Zhong and Xiaoyuan Zhang and Zhaowei Zhang and Nian Liu and Wei Wang and Yaodong Yang and Song-Chun Zhu},booktitle={International Conference on Learning Representations},year={2024},url={https://openreview.net/forum?id=UBVNwD3hPN}}