{ "info": { "author": "Chris Bamford", "author_email": "chrisbam4d@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# python-microRTS\n\nA python client library for microRTS.\n\n## Overview\n\nThe python client library makes use of the `SocketAI` interface in the microRTS library.\n\nBy default the socketAI library will connect to localhost:9898. The python client is hard-coded to use these values also.\n\n\n## Running\nFirstly start your AI class in python... you should see some logging that looks like \n```\nDEBUG:RTSServer:Socket created\nDEBUG:RTSServer:Socket bind complete\nDEBUG:RTSServer:Socket now listening\nserver is running\n```\n\nOne you see this logging, you can start a microRTS environment and it should connect to the control server.\n\n## How to create a controller\n\n1. Create a class that inherits the `Server` class in `server.py`\n\n```\nfrom pyrts.server import Server\n\n\nclass AI(server):\n\n....\n\n```\n\n2. Implement the method `get_action`\n\n\n```\n\nclass AI(Server):\n\n def get_action(state):\n # In here implement the algorithm that takes the state and creates the action\n\n return [ .. list of actions]\n\n\n```\n\nThe format of the actions list returned should be like be the following:\n\n```\n\n[\n {\n \"unitID\": 0 - the unit that you wish to control\n \"unitAction\": {\n 'type': 1 - the type of action (this is defined in the unit type table)\n 'parameters': 0 - the parameters for the action (this is defined in the unit type table)\n }\n },\n {\n ... more actions for different unitID s\n }\n]\n\n\n```\n\nfor every game tick, the `get_action` function is called. \n\n##### NOTE\nIf there are no actions to send to the units in the game then the action NONE should be sent.\nNONE should also be sent to any units that are currently performing action that take time. (a list of these units is \nreturned by `get_busy_units`)\n\n## Examples\n\nExamples can be found in the `examples` directory.\n\nCurrently the following algorithms are implemented:\n\n\n....\n##### super simple examples\n - random actions - perform random actions for all units\n - random bot movement - a random walk for the single worker that starts\n\n## Useful functions in the Server class\n\n##### get_busy_units(state)\n\nGet a list of the units that are currently busy performing an action\n\n##### get_available_actions_by_type(unit_type_table, type)\n\nGiven the unit type and the unit type table, return a complete list of the possible actions that unit can perform\n\n##### get_unit_type_table()\n\nThis function returns the unit type table, which describes the environment.\n\nfor example, the environment `basesWorkers16x16.xml` will return:\n\n```\n{\n \"moveConflictResolutionStrategy\": 1,\n \"unitTypes\": [\n {\n \"maxDamage\": 1,\n \"producedBy\": [],\n \"name\": \"Resource\",\n \"produces\": [],\n \"canAttack\": false,\n \"hp\": 1,\n \"moveTime\": 10,\n \"canMove\": false,\n \"isResource\": true,\n \"sightRadius\": 0,\n \"attackRange\": 1,\n \"harvestAmount\": 1,\n \"cost\": 1,\n \"produceTime\": 10,\n \"attackTime\": 10,\n \"minDamage\": 1,\n \"canHarvest\": false,\n \"isStockpile\": false,\n \"harvestTime\": 10,\n \"ID\": 0,\n \"returnTime\": 10\n },\n {\n \"maxDamage\": 1,\n \"producedBy\": [\n \"Worker\"\n ],\n \"name\": \"Base\",\n \"produces\": [\n \"Worker\"\n ],\n \"canAttack\": false,\n \"hp\": 10,\n \"moveTime\": 10,\n \"canMove\": false,\n \"isResource\": false,\n \"sightRadius\": 5,\n \"attackRange\": 1,\n \"harvestAmount\": 1,\n \"cost\": 10,\n \"produceTime\": 250,\n \"attackTime\": 10,\n \"minDamage\": 1,\n \"canHarvest\": false,\n \"isStockpile\": true,\n \"harvestTime\": 10,\n \"ID\": 1,\n \"returnTime\": 10\n },\n {\n \"maxDamage\": 1,\n \"producedBy\": [\n \"Worker\"\n ],\n \"name\": \"Barracks\",\n \"produces\": [\n \"Light\",\n \"Heavy\",\n \"Ranged\"\n ],\n \"canAttack\": false,\n \"hp\": 4,\n \"moveTime\": 10,\n \"canMove\": false,\n \"isResource\": false,\n \"sightRadius\": 3,\n \"attackRange\": 1,\n \"harvestAmount\": 1,\n \"cost\": 5,\n \"produceTime\": 200,\n \"attackTime\": 10,\n \"minDamage\": 1,\n \"canHarvest\": false,\n \"isStockpile\": false,\n \"harvestTime\": 10,\n \"ID\": 2,\n \"returnTime\": 10\n },\n {\n \"maxDamage\": 1,\n \"producedBy\": [\n \"Base\"\n ],\n \"name\": \"Worker\",\n \"produces\": [\n \"Base\",\n \"Barracks\"\n ],\n \"canAttack\": true,\n \"hp\": 1,\n \"moveTime\": 10,\n \"canMove\": true,\n \"isResource\": false,\n \"sightRadius\": 3,\n \"attackRange\": 1,\n \"harvestAmount\": 1,\n \"cost\": 1,\n \"produceTime\": 50,\n \"attackTime\": 5,\n \"minDamage\": 1,\n \"canHarvest\": true,\n \"isStockpile\": false,\n \"harvestTime\": 20,\n \"ID\": 3,\n \"returnTime\": 10\n },\n {\n \"maxDamage\": 2,\n \"producedBy\": [\n \"Barracks\"\n ],\n \"name\": \"Light\",\n \"produces\": [],\n \"canAttack\": true,\n \"hp\": 4,\n \"moveTime\": 8,\n \"canMove\": true,\n \"isResource\": false,\n \"sightRadius\": 2,\n \"attackRange\": 1,\n \"harvestAmount\": 1,\n \"cost\": 2,\n \"produceTime\": 80,\n \"attackTime\": 5,\n \"minDamage\": 2,\n \"canHarvest\": false,\n \"isStockpile\": false,\n \"harvestTime\": 10,\n \"ID\": 4,\n \"returnTime\": 10\n },\n {\n \"maxDamage\": 4,\n \"producedBy\": [\n \"Barracks\"\n ],\n \"name\": \"Heavy\",\n \"produces\": [],\n \"canAttack\": true,\n \"hp\": 4,\n \"moveTime\": 12,\n \"canMove\": true,\n \"isResource\": false,\n \"sightRadius\": 2,\n \"attackRange\": 1,\n \"harvestAmount\": 1,\n \"cost\": 2,\n \"produceTime\": 120,\n \"attackTime\": 5,\n \"minDamage\": 4,\n \"canHarvest\": false,\n \"isStockpile\": false,\n \"harvestTime\": 10,\n \"ID\": 5,\n \"returnTime\": 10\n },\n {\n \"maxDamage\": 1,\n \"producedBy\": [\n \"Barracks\"\n ],\n \"name\": \"Ranged\",\n \"produces\": [],\n \"canAttack\": true,\n \"hp\": 1,\n \"moveTime\": 10,\n \"canMove\": true,\n \"isResource\": false,\n \"sightRadius\": 3,\n \"attackRange\": 3,\n \"harvestAmount\": 1,\n \"cost\": 2,\n \"produceTime\": 100,\n \"attackTime\": 5,\n \"minDamage\": 1,\n \"canHarvest\": false,\n \"isStockpile\": false,\n \"harvestTime\": 10,\n \"ID\": 6,\n \"returnTime\": 10\n }\n ]\n}\n\n```\n\n##### get_valid_action_positions_for_state(state):\n\nReturns a tuple containing the following:\n*invalid_move_positions* - a set of all the positions that cannot be moved into\n*valid_harvest_positions* - a set of all the resource locations\n*valid_base_positions* - a set of the positions of bases on the current players team\n*valid_attack_positions* - a set of the positions that can be attacked\n\nThese positions can be cross-referenced with possible actions that units can perform, to make sure no invalid\nactions are sent to the environment\n\n##### get_valid_actions_for_unit(unit, available_actions, valid_positions)\n\nGet the actions that are valid for a unit to perform.\nAn action is INVALID if the action cannot be performed in the environment.\nFor example, if the action is MOVE(left) but the position to the left of the unit is blocked\n\n##### get_available_actions_by_type_name(unit_type_table, type_name)\n\nGets a list of the available actions that can be performed by a particlar unit\n\n##### get_resources_for_player(state, player)\n\nGet the number of resources the player currently has available\n\n##### get_resource_usage_from_state(state)\n\nHow many resources are currently being used to build units\n\n##### get_resource_usage_from_actions(actions)\n\nFrom a list of actions, sum the cost of the actions\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/bam4d/python-microRTS", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "python-microRTS", "package_url": "https://pypi.org/project/python-microRTS/", "platform": "", "project_url": "https://pypi.org/project/python-microRTS/", "project_urls": { "Homepage": "https://github.com/bam4d/python-microRTS" }, "release_url": "https://pypi.org/project/python-microRTS/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "MicroRTS client for python", "version": "0.0.1" }, "last_serial": 4859047, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "3d7fea3bf91a9349279f7b02918c1fe9", "sha256": "8e649d39f7bb88dc467691211e4e979f104b25e30e6271e01e7e87b46f40ee48" }, "downloads": -1, "filename": "python_microRTS-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "3d7fea3bf91a9349279f7b02918c1fe9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9263, "upload_time": "2019-02-23T19:31:55", "url": "https://files.pythonhosted.org/packages/73/bf/c29e9d2127f4b00f074a0ed9c46317fa8ed37d58373333b1344383c0312f/python_microRTS-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ba63f90e8515f031d37c46fce50bd5e0", "sha256": "d56c3bf84337340ef745ba2befc68246596e44cebb404db49ddf6772d273fc9b" }, "downloads": -1, "filename": "python-microRTS-0.0.1.tar.gz", "has_sig": false, "md5_digest": "ba63f90e8515f031d37c46fce50bd5e0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6215, "upload_time": "2019-02-23T19:31:57", "url": "https://files.pythonhosted.org/packages/9c/64/c48acebf524d246809b1d42bdf376a8603ee16f3211f816195d1452c9535/python-microRTS-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3d7fea3bf91a9349279f7b02918c1fe9", "sha256": "8e649d39f7bb88dc467691211e4e979f104b25e30e6271e01e7e87b46f40ee48" }, "downloads": -1, "filename": "python_microRTS-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "3d7fea3bf91a9349279f7b02918c1fe9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9263, "upload_time": "2019-02-23T19:31:55", "url": "https://files.pythonhosted.org/packages/73/bf/c29e9d2127f4b00f074a0ed9c46317fa8ed37d58373333b1344383c0312f/python_microRTS-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ba63f90e8515f031d37c46fce50bd5e0", "sha256": "d56c3bf84337340ef745ba2befc68246596e44cebb404db49ddf6772d273fc9b" }, "downloads": -1, "filename": "python-microRTS-0.0.1.tar.gz", "has_sig": false, "md5_digest": "ba63f90e8515f031d37c46fce50bd5e0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6215, "upload_time": "2019-02-23T19:31:57", "url": "https://files.pythonhosted.org/packages/9c/64/c48acebf524d246809b1d42bdf376a8603ee16f3211f816195d1452c9535/python-microRTS-0.0.1.tar.gz" } ] }