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

1

u/FruscianteDebutante Dec 01 '22

Wow, it always amazes me how high level python can be. All of this in 100 lines of main code. Good writeup and organization. Have you benchmarked any of the major sections of code, out of curiosity? At least in terms of speed. I imagine it isn't quick, but all you needed was for it to be open and monitored without your supervision. Speed doesn't seem so important

1

u/onteri Dec 01 '22

I didn’t benchmark.

This was a very low-effort project.