Xodia24


NameXodia24 JSON
Version 0.1.19 PyPI version JSON
download
home_pageNone
SummaryPython package providing a custom environment for simulating tank battles
upload_time2024-04-23 18:54:50
maintainerNone
docs_urlNone
authorPrem Gaikwad
requires_pythonNone
licenseNone
keywords python reinforcement-learning tank-battle
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Xodia24: PocketTank Environment



<p align="center">

  <img src="https://i.ibb.co/P4nyZNv/Xodia-Logo-removebg-preview.png" alt="Xodia-Logo-removebg-preview" border="0" width="400px">

</p>



Xodia24 is a Python package providing a custom environment for simulating a tank battle scenario where two tanks are positioned on a 2D grid. The objective is to train a Reinforcement Learning (RL) agent to effectively control one of the tanks and shoot at the other tank using different actions such as adjusting power, angle, and moving the tank.



## Installation



You can install Xodia24 via pip:

```

pip install Xodia24

```



## Usage



1. **Implementing the Custom Reward Function:**

   Before training the RL model, it's necessary to implement the reward function according to specific problem requirements. This function should take the difference in distance between the bullet and the target tank as input and return the reward. To implement the custom reward function, you need to subclass the `PocketTank` environment and override the `reward` method with your custom implementation.



2. **Training the RL Model:**

   After implementing the custom reward function, you can train your RL model using this environment by interacting with it through the `step()` method. Provide actions to the tank and observe the resulting state, reward, and other information.



Example:

```python

# Import the environment

from Xodia24.env import PocketTank



# Train RL model using the environment

# ...

```



3. **Using the Custom PocketTank Environment:**

   If you want to utilize a custom implementation of the PocketTank environment, you can create your subclass and override the necessary methods. Here's a sample implementation:

   

# Custom PocketTank

```python

from Xodia24.env import PocketTank

from gymnasium import spaces

import numpy as np



class CustomPocketTank(PocketTank):

    def __init__(self):

        super().__init__()

        """

        Define a custom action space but only limit it

        dont change actual crux or step function wont work

         """

        # Example 1

		self.action_space  =  spaces.MultiDiscrete([100,90,1]) # This limit movement only hit from the current position

		# Example 2

		self.action_space  =  spaces.MultiDiscrete([100,45,3]) # Limit the angle

		# Example 3

		self.action_space  =  spaces.MultiDiscrete([60,90,3])# Limit the power of firing

    def reward(self, diff_distance):

        """

        Custom reward function implementation.



        Args:

            diff_distance (float): Difference in distance between the bullet and the target tank.



        Returns:

            float: Custom reward value based on the difference in distance.

        """

        # Implement your custom reward logic here

        custom_reward = 0 # Add your reward Function

        return custom_reward

```



## Dependencies



- `gymnasium`: A toolkit for developing and comparing reinforcement learning algorithms.

- `numpy`: Library for numerical computations and array operations.

- `matplotlib`: Library for creating plots and visualizations.





## Action Space



The action space in the Xodia24 PocketTank environment refers to the set of possible actions that the reinforcement learning (RL) agent can take at each time step. In the tank battle scenario, the agent controls one of the tanks and has several actions available to it, including adjusting the power and angle of the tank's cannon and moving the tank across the 2D grid.



### Available Actions:

- **Adjust Power**: The agent can adjust the power setting of the tank's cannon, determining the force with which the projectile is fired.

Range: 0-100

- **Adjust Angle**: The agent can adjust the angle of the tank's cannon, controlling the direction in which the projectile is launched.

Range: 0 deg - 90 deg

- **Move Tank**: The agent can move the tank across the 2D grid, changing its position on the battlefield.

0 = Dont move only fire

1 = move +25 and then fire

2 = move -25 and then fire





## Observation Space



The observation space refers to the information that the RL agent receives from the environment at each time step. This information helps the agent make decisions about which actions to take in order to achieve its objective. In the Xodia24 PocketTank environment, the observation space includes various features of the battlefield and the tanks' positions.



obs = [x1,x2,b]



x1: Your Tank Location

x2: Enemy Tank Location

b : bullet type ID







## Bullet Types



The tank has seven different types of bullets available, each with unique properties and effects. The tank has access to each bullet type an unlimited number of times.



1. *Standard Shell*:

    - *Description*: A classic projectile bullet that follows projectile motion.

    - *Damage*: Deals 20 damage upon hitting the target.

    - *Trajectory*: Parabolic trajectory determined by initial angle and velocity.

    - *ID*: 0



2. *Triple Threat*:

    - *Description*: A bullet that splits into three smaller bullets upon firing.

    - *Damage*: Each of the three bullets deals 20 damage, similar to the Standard Shell.

    - *Trajectory*: Parabolic trajectory similar to Standard Shell.

     - *ID*: 1



3. *Long Shot*:

    - *Description*: A bullet that deals more damage based on the distance it travels before hitting the ground.

    - *Damage*: Damage increases as the distance traveled increases.

    - *Trajectory*: Parabolic trajectory similar to the Standard Shell.

    - *ID*: 2



4. *Heavy Impact*:

    - *Description*: A high-damage bullet with limited range and velocity.

    - *Damage*: Deals 40 damage upon hitting the target.

    - *Trajectory*: Limited velocity and range compared to other bullets.

    - *ID*: 3



5. *Blast Radius*:

    - *Description*: A bullet that causes area damage within a radius of 100.

    - *Damage*: Deals 10 damage in a radius of 100 around the impact point.

    - *Trajectory*: Parabolic trajectory similar to the Standard Shell.

    - *ID*: 4



6. *Healing Halo*:

    - *Description*: A bullet that heals the tank upon impact.

    - *Healing*: Heals the tank by 10 points upon hitting the ground or a target.

    - *Trajectory*: Parabolic trajectory similar to the Standard Shell.

    - *ID*: 5



7. *Boomerang Blast*:

    - *Description*: A bullet that follows a unique trajectory resembling a boomerang.

    - *Damage*: Deals 20 damage upon hitting the target.

    - *Trajectory*: Follows a curved trajectory that slightly reverses direction, like a boomerang.

    - *ID*: 6




            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "Xodia24",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "python, reinforcement-learning, tank-battle",
    "author": "Prem Gaikwad",
    "author_email": "premgaikwad7a@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/54/a4/fe1a67a77ddc2e0944cae1aef04b904bd6f48552ab052c08d20f2617b397/Xodia24-0.1.19.tar.gz",
    "platform": null,
    "description": "# Xodia24: PocketTank Environment\r\n\r\n\r\n\r\n<p align=\"center\">\r\n\r\n  <img src=\"https://i.ibb.co/P4nyZNv/Xodia-Logo-removebg-preview.png\" alt=\"Xodia-Logo-removebg-preview\" border=\"0\" width=\"400px\">\r\n\r\n</p>\r\n\r\n\r\n\r\nXodia24 is a Python package providing a custom environment for simulating a tank battle scenario where two tanks are positioned on a 2D grid. The objective is to train a Reinforcement Learning (RL) agent to effectively control one of the tanks and shoot at the other tank using different actions such as adjusting power, angle, and moving the tank.\r\n\r\n\r\n\r\n## Installation\r\n\r\n\r\n\r\nYou can install Xodia24 via pip:\r\n\r\n```\r\n\r\npip install Xodia24\r\n\r\n```\r\n\r\n\r\n\r\n## Usage\r\n\r\n\r\n\r\n1. **Implementing the Custom Reward Function:**\r\n\r\n   Before training the RL model, it's necessary to implement the reward function according to specific problem requirements. This function should take the difference in distance between the bullet and the target tank as input and return the reward. To implement the custom reward function, you need to subclass the `PocketTank` environment and override the `reward` method with your custom implementation.\r\n\r\n\r\n\r\n2. **Training the RL Model:**\r\n\r\n   After implementing the custom reward function, you can train your RL model using this environment by interacting with it through the `step()` method. Provide actions to the tank and observe the resulting state, reward, and other information.\r\n\r\n\r\n\r\nExample:\r\n\r\n```python\r\n\r\n# Import the environment\r\n\r\nfrom Xodia24.env import PocketTank\r\n\r\n\r\n\r\n# Train RL model using the environment\r\n\r\n# ...\r\n\r\n```\r\n\r\n\r\n\r\n3. **Using the Custom PocketTank Environment:**\r\n\r\n   If you want to utilize a custom implementation of the PocketTank environment, you can create your subclass and override the necessary methods. Here's a sample implementation:\r\n\r\n   \r\n\r\n# Custom PocketTank\r\n\r\n```python\r\n\r\nfrom Xodia24.env import PocketTank\r\n\r\nfrom gymnasium import spaces\r\n\r\nimport numpy as np\r\n\r\n\r\n\r\nclass CustomPocketTank(PocketTank):\r\n\r\n    def __init__(self):\r\n\r\n        super().__init__()\r\n\r\n        \"\"\"\r\n\r\n        Define a custom action space but only limit it\r\n\r\n        dont change actual crux or step function wont work\r\n\r\n         \"\"\"\r\n\r\n        # Example 1\r\n\r\n\t\tself.action_space  =  spaces.MultiDiscrete([100,90,1]) # This limit movement only hit from the current position\r\n\r\n\t\t# Example 2\r\n\r\n\t\tself.action_space  =  spaces.MultiDiscrete([100,45,3]) # Limit the angle\r\n\r\n\t\t# Example 3\r\n\r\n\t\tself.action_space  =  spaces.MultiDiscrete([60,90,3])# Limit the power of firing\r\n\r\n    def reward(self, diff_distance):\r\n\r\n        \"\"\"\r\n\r\n        Custom reward function implementation.\r\n\r\n\r\n\r\n        Args:\r\n\r\n            diff_distance (float): Difference in distance between the bullet and the target tank.\r\n\r\n\r\n\r\n        Returns:\r\n\r\n            float: Custom reward value based on the difference in distance.\r\n\r\n        \"\"\"\r\n\r\n        # Implement your custom reward logic here\r\n\r\n        custom_reward = 0 # Add your reward Function\r\n\r\n        return custom_reward\r\n\r\n```\r\n\r\n\r\n\r\n## Dependencies\r\n\r\n\r\n\r\n- `gymnasium`: A toolkit for developing and comparing reinforcement learning algorithms.\r\n\r\n- `numpy`: Library for numerical computations and array operations.\r\n\r\n- `matplotlib`: Library for creating plots and visualizations.\r\n\r\n\r\n\r\n\r\n\r\n## Action Space\r\n\r\n\r\n\r\nThe action space in the Xodia24 PocketTank environment refers to the set of possible actions that the reinforcement learning (RL) agent can take at each time step. In the tank battle scenario, the agent controls one of the tanks and has several actions available to it, including adjusting the power and angle of the tank's cannon and moving the tank across the 2D grid.\r\n\r\n\r\n\r\n### Available Actions:\r\n\r\n- **Adjust Power**: The agent can adjust the power setting of the tank's cannon, determining the force with which the projectile is fired.\r\n\r\nRange: 0-100\r\n\r\n- **Adjust Angle**: The agent can adjust the angle of the tank's cannon, controlling the direction in which the projectile is launched.\r\n\r\nRange: 0 deg - 90 deg\r\n\r\n- **Move Tank**: The agent can move the tank across the 2D grid, changing its position on the battlefield.\r\n\r\n0 = Dont move only fire\r\n\r\n1 = move +25 and then fire\r\n\r\n2 = move -25 and then fire\r\n\r\n\r\n\r\n\r\n\r\n## Observation Space\r\n\r\n\r\n\r\nThe observation space refers to the information that the RL agent receives from the environment at each time step. This information helps the agent make decisions about which actions to take in order to achieve its objective. In the Xodia24 PocketTank environment, the observation space includes various features of the battlefield and the tanks' positions.\r\n\r\n\r\n\r\nobs = [x1,x2,b]\r\n\r\n\r\n\r\nx1: Your Tank Location\r\n\r\nx2: Enemy Tank Location\r\n\r\nb : bullet type ID\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n## Bullet Types\r\n\r\n\r\n\r\nThe tank has seven different types of bullets available, each with unique properties and effects. The tank has access to each bullet type an unlimited number of times.\r\n\r\n\r\n\r\n1. *Standard Shell*:\r\n\r\n    - *Description*: A classic projectile bullet that follows projectile motion.\r\n\r\n    - *Damage*: Deals 20 damage upon hitting the target.\r\n\r\n    - *Trajectory*: Parabolic trajectory determined by initial angle and velocity.\r\n\r\n    - *ID*: 0\r\n\r\n\r\n\r\n2. *Triple Threat*:\r\n\r\n    - *Description*: A bullet that splits into three smaller bullets upon firing.\r\n\r\n    - *Damage*: Each of the three bullets deals 20 damage, similar to the Standard Shell.\r\n\r\n    - *Trajectory*: Parabolic trajectory similar to Standard Shell.\r\n\r\n     - *ID*: 1\r\n\r\n\r\n\r\n3. *Long Shot*:\r\n\r\n    - *Description*: A bullet that deals more damage based on the distance it travels before hitting the ground.\r\n\r\n    - *Damage*: Damage increases as the distance traveled increases.\r\n\r\n    - *Trajectory*: Parabolic trajectory similar to the Standard Shell.\r\n\r\n    - *ID*: 2\r\n\r\n\r\n\r\n4. *Heavy Impact*:\r\n\r\n    - *Description*: A high-damage bullet with limited range and velocity.\r\n\r\n    - *Damage*: Deals 40 damage upon hitting the target.\r\n\r\n    - *Trajectory*: Limited velocity and range compared to other bullets.\r\n\r\n    - *ID*: 3\r\n\r\n\r\n\r\n5. *Blast Radius*:\r\n\r\n    - *Description*: A bullet that causes area damage within a radius of 100.\r\n\r\n    - *Damage*: Deals 10 damage in a radius of 100 around the impact point.\r\n\r\n    - *Trajectory*: Parabolic trajectory similar to the Standard Shell.\r\n\r\n    - *ID*: 4\r\n\r\n\r\n\r\n6. *Healing Halo*:\r\n\r\n    - *Description*: A bullet that heals the tank upon impact.\r\n\r\n    - *Healing*: Heals the tank by 10 points upon hitting the ground or a target.\r\n\r\n    - *Trajectory*: Parabolic trajectory similar to the Standard Shell.\r\n\r\n    - *ID*: 5\r\n\r\n\r\n\r\n7. *Boomerang Blast*:\r\n\r\n    - *Description*: A bullet that follows a unique trajectory resembling a boomerang.\r\n\r\n    - *Damage*: Deals 20 damage upon hitting the target.\r\n\r\n    - *Trajectory*: Follows a curved trajectory that slightly reverses direction, like a boomerang.\r\n\r\n    - *ID*: 6\r\n\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python package providing a custom environment for simulating tank battles",
    "version": "0.1.19",
    "project_urls": null,
    "split_keywords": [
        "python",
        " reinforcement-learning",
        " tank-battle"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "823b9ef63ef1b9cbc712b2d41f57d380438cff765445582f7eba5f34f0e825f9",
                "md5": "6cbe1f640c08d234281e72f69d4fcbde",
                "sha256": "1d085e8ce9ddf250a5d858e7916f8279418569a8c5a9d1bf40abb6fb0e80946b"
            },
            "downloads": -1,
            "filename": "Xodia24-0.1.19-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6cbe1f640c08d234281e72f69d4fcbde",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7212,
            "upload_time": "2024-04-23T18:54:47",
            "upload_time_iso_8601": "2024-04-23T18:54:47.756766Z",
            "url": "https://files.pythonhosted.org/packages/82/3b/9ef63ef1b9cbc712b2d41f57d380438cff765445582f7eba5f34f0e825f9/Xodia24-0.1.19-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "54a4fe1a67a77ddc2e0944cae1aef04b904bd6f48552ab052c08d20f2617b397",
                "md5": "ff01ebd59b88378878bac63003b9dde8",
                "sha256": "69e42174df21364b10a3783b6668d4ef6fd3cea5460e25e28295fb3ad94bdc64"
            },
            "downloads": -1,
            "filename": "Xodia24-0.1.19.tar.gz",
            "has_sig": false,
            "md5_digest": "ff01ebd59b88378878bac63003b9dde8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8016,
            "upload_time": "2024-04-23T18:54:50",
            "upload_time_iso_8601": "2024-04-23T18:54:50.123006Z",
            "url": "https://files.pythonhosted.org/packages/54/a4/fe1a67a77ddc2e0944cae1aef04b904bd6f48552ab052c08d20f2617b397/Xodia24-0.1.19.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-23 18:54:50",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "xodia24"
}
        
Elapsed time: 0.53847s