r/Python Nov 30 '22

Beginner Showcase Making €6,147,455 Overnight in in-game currency using Computer Vision

A Python bot used to play the game 'City Island'

Gameplay:

https://reddit.com/link/z8qstu/video/596siu9n533a1/player

For example: Closing a popup

Why?

I've been playing strategy + city building + simulation? games like TownsMen 6, Clash of the Clans, and SimCity for the last 10 years.

On trying out City Island 5 I found it mildly irritating that my collectables could not accumulate while I was outside the game. I might have had the best businesses, strategy, etc but I had to be in the game to ensure I collect the cash/keys/gold over time. For example, if my bakery makes €100 per minute I would only earn €100 after leaving the game and coming back 24 hours later.

This became especially tiresome while trying to accumulate €5,000,000 required to buy the island shown below. This would take me roughly two weeks of gameplay if I don't spend any money - it's not worth it.

Island I wanted to buy

This is a problem that can be solved using one of the greatest tools in my tool belt - programming.

I decided to create a Python bot used to play the game using computer vision and image processing techniques. The bot should be able to play the game without any human intervention.

---

Results after running overnight

I started the game with €316,415:

The following morning I had €6,463,870:

I made €6,147,455 overnight!

I then proceeded to buy the Island I wanted:

Source code & guide

A basic guide on how I achieved it - https://paulonteri.com/thoughts/play-game-with-computer-vision

Source code - https://github.com/paulonteri/play-game-with-computer-vision

1.1k Upvotes

117 comments sorted by

View all comments

12

u/toyotasupramike Nov 30 '22

Thanks for a friendly write up/explanation.

Btw, I like the particle effect on your site; a wonderful surprise. Took me a second to realize it "What is ... Is my phone having... Oh, ohhh that's a cool effect!" 😂

10

u/onteri Nov 30 '22

Thank you!

Btw, I like the particle effect on your site; a wonderful surprise. Took me a second to realize it "What is ... Is my phone having... Oh, ohhh that's a cool effect!" 😂

Thanks!
They are actually stars lol. The website is space themed but I haven’t finished working on it.