smack42 / colorfill Goto Github PK
View Code? Open in Web Editor NEWColorFill - yet another Flood-It clone (game and solver algorithm)
Home Page: https://github.com/smack42/ColorFill/wiki
License: GNU General Public License v3.0
ColorFill - yet another Flood-It clone (game and solver algorithm)
Home Page: https://github.com/smack42/ColorFill/wiki
License: GNU General Public License v3.0
ColorFill - yet another Flood-It clone (game and solver algorithm) Version 1.3.3 (2023-08-25) Homepage https://github.com/smack42/ColorFill/wiki about The game called Flood-It has been around for some years. There are many clones and variants available for desktop and mobile platforms. The game board is a grid of squares, colored at random in multiple colors. In each move the player changes the color of the "start square" and all squares of the same color that are connected to it. The objective is to fill the entire grid in a single color using as few moves as possible. This program, ColorFill, is yet another clone of this game. It includes an interactive GUI mode which lets you play the puzzles and explore the solutions that its integrated solver algorithms have found. The program also has a dedicated "solver mode" that uses the algorithms to solve two competition tasks that I've found on the internet: - "Programming Challenge 19" (1000 14x14 boards; see directory pc19) - "Code Golf 26232" (100000 19x19 boards; see directory codegolf26232) usage Java SE Runtime Environment (JRE version 8 or newer) is required to run this program. You can download Java here: https://www.oracle.com/java/technologies/downloads/ https://adoptium.net/ To run the program just doubleclick "colorfill.jar". On the command line run it like this: java -jar colorfill.jar license ColorFill game and solver Copyright (C) 2023 Michael Henke <[email protected]> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. This program uses: DesignGridLayout - Swing LayoutManager that implements "Canonical Grids" - https://web.archive.org/web/20170409233103/https://java.net/projects/designgridlayout/pages/Home - https://search.maven.org/artifact/net.java.dev.designgridlayout/designgridlayout - Copyright 2005-2013 Jason Aaron Osgood, Jean-Francois Poilpret - DesignGridLayout is open source licensed under the Apache License 2.0 FlatLaf - Flat Look and Feel (with Darcula/IntelliJ themes support) - https://www.formdev.com/flatlaf - https://github.com/JFormDesigner/FlatLaf - Copyright 2019 FormDev Software GmbH - FlatLaf is open source licensed under the Apache License 2.0 some links Online game http://unixpapa.com/floodit/ Android app https://play.google.com/store/apps/details?id=name.boyle.chris.sgtpuzzles https://play.google.com/store/apps/details?id=com.labpixies.flood https://play.google.com/store/apps/details?id=com.wetpalm.colorflood Programming https://web.archive.org/web/20150909200653/http://cplus.about.com/od/programmingchallenges/a/challenge19.htm https://stackoverflow.com/questions/1430962/how-to-optimally-solve-the-flood-fill-puzzle http://markgritter.livejournal.com/tag/floodit http://kunigami.wordpress.com/2012/09/16/flood-it-an-exact-approach/ https://codegolf.stackexchange.com/questions/26232/create-a-flood-paint-ai https://github.com/aaronpuchert/floodit https://github.com/Flolle/terminal-flood https://www.formdev.com/flatlaf https://github.com/JFormDesigner/FlatLaf https://github.com/manteuffel723/flood-it-boards
Hello!
First, I want to congratulate you on your program! Personally, I consider it the best Flood-It implementation playable on desktop PCs. ๐๐ป
But to get to the reason I'm writing you: I've been working on and off again on my own version of a Flood-It clone with an included solver (Flolle/terminal-flood). I wasn't originally intending to upload it to GitHub, but then I thought "What the hell, why not?". Even though I spent quite a bit of time optimizing it, it's still a bit slower than your program, which is OK as you seem to be more willing to write low level performant code than I am. I did however find one thing that might be of use to you: A fast inadmissible heuristic that's still able to find relatively close to optimal results.
To give two examples: My implementation of A* with the Puchert admissible heuristic when run single-threaded needs about 48s to finish the pc19 dataset, while my inadmissible heuristic needs about 8.5s and manages a score of 20189. Additionally, my inadmissible heuristic when using 12 threads needs less than 25min to finish the floodtest dataset with a score of 1992612. I did a bunch more benchmarks with additional datasets, you can check them out if you want.
The basic idea for the heuristic is based on the Puchert admissible heuristic, the difference being that you don't do color blind moves, but instead only take the two most promising colors. The basic rundown is:
You can check out how I implemented this exactly in my project if you want, the code for the heuristic is in the file Strategy.kt
. I implemented a couple more heuristics, maybe they are of interest to you too. I'm using the same license for my project as you do, so there shouldn't be any problems regarding that.
I'm mainly proposing this new heuristic as a way to have pretty good solutions available when playing the game with big boards. While you made great strides in regards to the performance of the Puchert heuristic, it's still quickly reaching its limits once you get to board sizes above 20x20 with 6 colors for example. The new heuristic would stay usable in terms of time needed to compute solutions a while longer.
I have looked a bit into your code, and while you have nice sub-optimal solvers, the exhaustive search you're doing is a bit slow.
Now, the "true" reason why I came here is because my brother and I are doing something similar (aaronpuchert/floodit). It even has the same license, so you can just rummage through it.
I've done some more work locally (mostly merging the master branch and the performance branch) and the resulting program took about 4 seconds on average for each of the codegolf grids, which would mean ~110 CPU hours in total (that was on a Phenom II x4 965).
From the partial runs I did, I'd expect around 1 986 000 moves for the 100 000 grids.
We use an A*-type algorithm with a heuristic similar to tigrou's (but actually admissible) and move pruning similar to Jump-Point Search.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.