RootKit ai Lib (RL - Qlearning)
Project description
rkt_ai_lib - Python library
This Python library is based only on built-in Python libraries and one (1) non-build-in library : PyYaml
Python Version 3.7.2
PyYaml Version 5.4.1 (Released Jan 20, 2021)
What is Python?
Python is an interpreted high-level general-purpose programming language. Python's design philosophy emphasizes code readability with its notable use of significant indentation. Its language constructs as well as its object-oriented approach aim to help programmers write clear, logical code for small and large-scale projects.
Libraries
- AI: overlay of pandas library (Renforcement Learning - Qlearning)
Use it
Install
(venv) my_project> pip install rkt_ai_lib [--index-url https://gitlab.tprc.ovh/api/v4/groups/python/-/packages/pypi]
from os.path import exists
from rkt_ai_lib import QLearning
from your_local_lib import MyGameObject
my_action_list = ['up', 'down', 'left', 'right']
# can override alpha (0.1), gamma (0.5)
if exists("my_mind.pkl"):
mind = QLearning(actions=my_action_list, should_load=True, qtable_file_to_load="my_mind.pkl")
else:
mind = QLearning(actions=my_action_list)
# You can use the Qlearning for another thing then game
my_game = MyGameObject()
while True:
# get the current state
state = my_game.get_state()
# get the action
action = mind.choose_action(state)
# do the action your logic is here (move, attack, ... for game, send, buy, ... for trading, ...)
my_game.do_action(action)
# get the reward this is here reward logic
reward = my_game.get_reward(action, state)
# update the Q-table
mind.learn(state, action, reward)
# check if you "win"
if my_game.is_win():
break
mind.save("my_mind.pkl")
Output (as file or sdtout ot both)
Your "game" log
Contributing
If you find this library useful here's how you can help:
- Send a merge request with your kickass new features and bug fixes
- Help new users with issues they may encounter
- Support the development of this library and star this repo!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rkt_ai_lib-1.0.0.tar.gz
(5.1 kB
view hashes)
Built Distribution
Close
Hashes for rkt_ai_lib-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c75e66a7b567ad272fa44d2b45fd78701b22d9af1d64625a26de57519404f0b |
|
MD5 | d976c906e40acaceeaa7de1b7ded5ec6 |
|
BLAKE2b-256 | 925926906abd9c6ac134bded57578279af75520089c129a00f5c1c1855492a77 |