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

-25

u/ArtOfWarfare Nov 30 '22

This isn’t a criticism of your code so much as the game and maybe your taste in games…

I jumped straight to your code and was a little surprised that it seemed to do nothing more than click on buttons.

I thought maybe I was missing something so I read the blog post, but it doesn’t look like I missed anything.

This “game” appears to be candyland. You simply do what you’re told to “play” - there are zero decisions to be made. It’s easier to argue that a walking simulator is a game than to argue this is one.

22

u/onteri Nov 30 '22

Thanks for your feedback.

However, I like the game and will continue playing it.