Community post
Flood-It with Python
Greetings Steemians! :)
As a project for my very first CS class I made the classic game Flood-It using Python and a Draw module (that uses tkinter and allows for some basic drawings and animation).
The starting board looks like this:

The board is a 15x15 grid and each tile is randomly assigned a color at the start of the game, using the following code:

The color a tile is assigned is saved so that a 15x15 2D-list of every tile’s color can be created. This allows us to easily access and change the color of a tile later on during gameplay.
To allow the player to actually ‘flood-it’, I used the flood-fill algorithm, shown below:

After the player chooses a color from the color palette (the options are to the left of the flood-it board), this function is called like so: colorCheck(0, 0, colors_grid[0][0], color_chosen).
This tells the program to run the function starting with the top-left tile (tile[0][0]) and to check for the color the player chose.
If the tile is currently the ‘oldColor’, then the program will change it to the ‘newColor’ that the player chose and then proceed to check the tiles above, below, to the right, and to the left of that tile (if they exist). So after checking tile[0][0], the program will run the same function on tile[1][0] and tile[0][1]. If those tiles are the old color, they will be changed to the new color and then the function will check all of their surrounding tiles, and so on. The function does not do this if the tile in question is not the old color OR if it is already the new color. In that case, the program exits the function. The tile’s color is not changed and its surrounding tiles are not checked.


The game comes out to only 277 lines of code, most of which was very simple (even for a beginner like me). The recursive algorithm took the most time for me to get working properly by far, and it was incredibly frustrating at times, but that made it all the more worth it. I learned so much during the process and all-in-all it was incredibly rewarding, so thank you for letting me share my very first project with you! :D
Replies (4)
Congratulations @devohier, you have decided to take the next big step with your first post! The Steem Network Team wishes you a great time among this awesome community.
The proven road to boost your personal success in this amazing Steem Network
Do you already know that awesome content will get great profits by following these simple steps, that have been worked out by experts?
Greetings my friend!
I am glad that our community has increased with one more member!
I hope that you will find here a way to realize yourself, and to benefit others
Be yourself, be sincere, be honest and worthy of the place you are in.
I Upvoted your post and Resteem of your greeting in my feed, where you you can search friends and other minnows...
I think you can use this collected information:
First off all! Most answers to your questions you can find here https://www.steemithelp.net/
Blockchain Explorer https://steemd.com/@_Your_Steemit_Nickname
Blockchain Explorer and statistics https://steemdb.com/@Your_Steemit_Nickname
Your account achievements https://steemitboard.com
Navigate the prices and exchanges where you can buy Steem or sell SBD
Steem
SBD
For the your first post use please #introduceyourself tag! Thank you:)
You can become a participant in the competitions, by selecting the desired in the tag #contest or invent and organize your own.
More useful tips and steemit app you can find in #steemit & #steem tag
There is a Steemit chat with various rooms, in which you can ask questions, advice, or place your post to advertise it to the community https://steemit.chat
Upvote chat in the telegram massager:
https://t.me/steem
https://t.me/intercambiosteemit
https://t.me/Steemplus
Similarly, by reading the posts of other Steemians you can find invitations to the Discord channels! They often contain upvote chats, and you can easily find friends of interest in them
Here are some of them:
_World Of Photography https://discord.gg/4Ezx2eM_
_MinnowBOOSTER https://discord.gg/k7fWQD7_
_SteemSports https://discord.gg/ApvKKUF_
_WhaleShares https://discord.gg/DX7zErC_
_Steem Gigs https://discord.gg/NuFVxKA_
_SteemTrail https://discord.gg/gHt2aGN_
_Minnow-Power channel https://discord.gg/WvFQzXu_ notify
_Steemit Lover https://discord.gg/EVKhssF_
_GuideSteemit https://discord.gg/nkwh36Y_
_BuildAWhale https://discord.gg/yebax27_
_Steemit ramble https://discord.gg/9pUSjv8_
_VotoVZLA https://discord.gg/VhgeFJQ_
_Steem Life https://discord.gg/SD3ReMm_
_SteemLab https://discord.gg/phWQveU_
_MinnowsUnite https://discord.gg/CJEEfgb_
_Steemians https://discord.gg/uR95R7t_
_Society for Narwhal https://discord.gg/repxc9v_
Territorial communities
Steemit Philippines https://discord.gg/VyG83AN | https://discord.gg/Q8956PF
Steem NIGERIA https://discord.gg/Y3u2z6T
East Coast Steem https://discord.gg/QXduBuk
Ukraine SteemOn https://discord.gg/cxq8JQd
Ru-Steem Trail https://discord.gg/8KyDBUx
Let us know if you know more or create new!
Alternative interfaces:
https://zappl.com
https://busy.org
https://steepshot.io (-mobile app have to)
Forums https://chainbb.com
Mobile app - eSteem :
for Android https://play.google.com/store/apps/details?id=com.netsolutions.esteem&hl=ru
for iOS https://itunes.apple.com/us/app/esteem-mobile/id1141397898?mt=8
Forget about youtube! There is https://d.tube!
Have fun and joke yourself with https://dmania.lol/
A public SQL database with all blockchain data http://steemsql.com https://sql.steemhelpers.com
From Developers https://steemconnect.com
Rewarding Open Source Contributors
https://utopian.io | https://discord.gg/kPYBCYK
Autocuration1 https://steemvoter.com
Autocuration2 https://streemian.com/profile/curationtrail/trailing/943
Bot Tracker https://s3.amazonaws.com/yabapmatt/bottracker/bottracker.html#paid
Use @minnowbooster for boost your rewards!
More https://www.minnowbooster.net
https://www.minnowbooster.net/minnowbannericon.jpg
You also need to select witnesses and vote for them. These are people who ensure decentralization of the work of the blockchain. Make your choice consciously, by choosing responsible and useful delegates
https://steemit.com/~witnesses
Golos wait for you too! Find more here about Golos.io blockchain platform - analogue Steemit! This is Steemit,s younger brother! Join us: https://golos.io/create_account
Regarding the correction, insertion or deletion of your information, please contact @Dimarss
OMG - That is insane! Brilliant stuff! Would love to play it. Welcome!!!
Thank you!!!
I'd love to show it to you some time
:)