{"id":18851903,"url":"https://github.com/kroshechka/footbot","last_synced_at":"2026-05-09T00:03:44.976Z","repository":{"id":158648943,"uuid":"621323783","full_name":"KroSheChKa/FootBot","owner":"KroSheChKa","description":"Automated bot, which performs the role of goalkeeper in mini soccer.","archived":false,"fork":false,"pushed_at":"2023-07-19T20:52:22.000Z","size":36,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-30T16:54:29.953Z","etag":null,"topics":["bot","computer-vision","game","game-automation","gamebot","image-processing","mss","opencv","opencv-python","python","template-matching","vk-bot","vkbot","vkgame","vkgamebot","vkontakte-bot","win32api"],"latest_commit_sha":null,"homepage":"https://vk.com/app8013553","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KroSheChKa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-30T12:41:57.000Z","updated_at":"2023-04-15T11:18:24.000Z","dependencies_parsed_at":"2023-07-26T02:31:39.020Z","dependency_job_id":null,"html_url":"https://github.com/KroSheChKa/FootBot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KroSheChKa%2FFootBot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KroSheChKa%2FFootBot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KroSheChKa%2FFootBot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KroSheChKa%2FFootBot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KroSheChKa","download_url":"https://codeload.github.com/KroSheChKa/FootBot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239789011,"owners_count":19697293,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","computer-vision","game","game-automation","gamebot","image-processing","mss","opencv","opencv-python","python","template-matching","vk-bot","vkbot","vkgame","vkgamebot","vkontakte-bot","win32api"],"created_at":"2024-11-08T03:37:06.049Z","updated_at":"2026-02-04T01:30:16.459Z","avatar_url":"https://github.com/KroSheChKa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FootBot\n## An automated bot that performs the role of a goalkeeper in mini-football\n\n**The bot works in general using computer vision (OpenCV + mss libraries), and mouse movement emulation.**\n\n**[Video](https://www.youtube.com/watch?v=akwmVh6k5aY\u0026ab_channel=KroSheChKa) how `FootBot_fast` works**\n\nhttps://user-images.githubusercontent.com/104899233/232225652-76f9716a-ed4e-47fb-81b8-358fb6ec9a55.mp4\n\n- If you want `maximum performance` of the bot launch `FootBot_fast`, if you want to **observe the process** and **modify the values** for a while launch `FootBot`\n\n### So the idea is\n\nThe [game](https://vk.com/app8013553) is built on the principle of ping-pong, where you have to hit the ball and hit all the bricks from above. Miss - lose.\n\n*The game is constructed in such a way, that from the PC version the control of the brick that kicks the ball is done by just moving the cursor. (The brick follows the cursor)*\n\n**1. Get the most possible coordinates of the ball. And VERY quickly, because with each new level the ball accelerates faster and faster.**\n\n\u003eSo I had to use the `mss library`, because it is faster than the libraries I know, such as PIL, pyautogui.\n\n \u003eMore screenshots per second == more fps == the chance of missing the ball is reducing\n\n**2. Set the cursor on these coordinates, but the y coordinate is `stable`. There is no need to change it.**\n\n\u003eActually, I did a confidence threshold to calm down a cursor a little bit while a ball is away, but it had a bad influence on detecting the ball. Even with a little threshold.\n\nsome features and thats it.\n\n----\n### Total optimization\n\n**I made as much effort to optimize the bot as possible. The next stage of optimization goes beyond Python to `C++`**\n\nI implemented some optimization features:\n- I made a small optimization, by `limiting the cursor area`. Why is this necessary? In a game there can be a case where the ball hits the corner of the soccer field, and the cursor, not keeping up with the ball (about this later), pinches it in the corner. The ball comes out of such a position with the least resistance - **in the goal**. Therefore, the `cursor is limited` so that it does not jam the ball, but also would not let the ball into the goal at any angle.\n\n```python\nwin32api.ClipCursor((width start,height start,width end,height end))\n```\n- A new optimization [feature](https://github.com/KroSheChKa/FootBot/commit/92d9ba6f254b7bf6952f8debc7283942045523f6) has been added. The reason for creating it was the fact that the ball could kind of \"slide\" off the edge of the brick and hit the goal. Since the brick should ideally only travel along the goal to kick the ball (or maybe it's all over the field). I came up with a solution:\n```python\nx = round((x_old - goal_center) * 0.7) + goal_center\n```\n\u003eShrink the entire visible field for the bot to the size of the goal. Multiply the difference between the center of the goal and the X coordinate of the ball by `coefficient` and add to the center of the goal. In my case, the coefficient is 0.7.\n\n    Now the bot hardly ever faces the problem that the ball is ahead of him.\n    \n----\n### A technical problem with the ~~bot~~ game\n\nThere was a whole paragraph here, which dealt with the problem with the bot. But they've already been fixed, and the rest are left in the game itself. The game doesn't have time to `process the inputs`, I think. It turns out that the game counts defeat when I actually kicked the ball. Also there are some in-game cases that highly accelerated ball might just go through the wall and cause a loss :(\n\n----\n\n## How to run\n\nThis bot has an enormous attachment to `certain coordinates` on the screen and to the screen resolution itself. Actually in the new commit on 13.07.2023 I added a solution that should help.\n\nAll you have to to is:\n\n- Install [python](https://www.python.org/downloads/) together with `IDLE` on your computer **(you should run the code via IDLE!)**\n- Clone this project by this command somewhere on your computer:\n\u003e **Make sure you have downloaded [git](https://git-scm.com/downloads)!**\n```\ngit clone https://github.com/KroSheChKa/FootBot.git\n```\n- Open cmd in the created folder or press RButton in the folder and click \"`Git Bash Here`\" and paste that:\n```\npip install -r requirements.txt\n```\n\n**Particular case:** *If you have a monitor 3440x1440, then simply place the window with the game exactly half the screen on the left, set the **window scale 150%** and run it.*\n\nIn other cases to run this code on your computer you will have to `change values` depending on the resolution of your monitor, such as:\n```python \n# Football field (game area)\nfield = {'left': 747,\n         'top': 990,\n         'width': 462,\n         'height': 200}\n```\n![image](https://github.com/KroSheChKa/FootBot/assets/104899233/c6a186a9-f941-494f-a93a-da001182656c)\n\u003e The corners of the rectangle are the `coordinates of your screen` relative to the left edge of the screen and the top edge of the screen\n```python\n# Limiting the cursor movement area btw soccer goalposts\nfrom_left, cursor_area = 870, 214\n...\nfrom_top = 1160\n```\n![image](https://github.com/KroSheChKa/FootBot/assets/104899233/35daa60c-fd5e-4a60-be77-3563bc3d968c)\n\u003e Limit cursor area to make bot more effective\n\nYou can also play with the ball detection threshold to make the detection valid\n```python\nball_threshold = 0.251\n```\n\n- It is necessary to have an account in a popular CIS social network [VK.com](https://vk.com)\n  \n- Then go into the [Game](https://vk.com/app6657931)\n  \n- Make sure the game window is on the top. You will have a moment to remove the `IDLE Shell` from game area.\n\nAnd that's it.\n\u003eI hope my detailed comments in the code will help you\n\n----\n\n\u003eThere are some in-game bugs and the bot may lose due to it\n\n*Any suggestions? You found a bug?*\n\n-\u003e Leave a comment in [Discussions](https://github.com/KroSheChKa/BasketBot/discussions)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkroshechka%2Ffootbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkroshechka%2Ffootbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkroshechka%2Ffootbot/lists"}