From 71cdd7caef2e37afecea59d425324c2b3fafd02e Mon Sep 17 00:00:00 2001 From: ashishbeck Date: Mon, 14 Mar 2022 01:52:27 +0530 Subject: [PATCH] v1.0.3 - Bug fixes - Web app updated - README updated --- CHANGELOG.md | 6 + README.md | 22 +- docs/flutter_service_worker.js | 12 +- docs/index.html | 2 +- docs/main.dart.js | 16976 ++++++++++++++++--------------- docs/version.json | 2 +- lib/code/constants.dart | 2 +- lib/screen/puzzle.dart | 13 +- lib/ui/background.dart | 36 +- pubspec.yaml | 2 +- 10 files changed, 8551 insertions(+), 8522 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 616608c..005f7af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.0.3 + + - Bug fixes + - Web app updated + - README updated + ## 1.0.2 - Code cleanup diff --git a/README.md b/README.md index 77e2e61..920b4f0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 🧩 Retro Slide Puzzle -A retro-themed slide puzzle for the Flutter Puzzle Hack. -The live build is available to try [here](https://n-puzzle-solver-1.web.app/) ✨ +A retro-themed slide puzzle with a modern animated twist for the Flutter Puzzle Hack. +The live build is available to try [here](https://ashishbeck.github.io/slide_puzzle/) ✨ ## 🚀 Features - 【aesthetic】🌆 @@ -19,6 +19,22 @@ This project was created in Flutter 2.8.0 but the final build is produced with t ### Firebase This project uses firebase to anonymously sign in players and keep track of their scores in the firestore database. It also uses cloud functions to keep track of the community scores by pooling them in a single document for moves and times. Whenever a player creates a new score or breaks personal best, apart from updating their own user document in users' collections, the older stat is also removed and the newer one is added to the aforementioned pool. In order to achieve that, a very basic function is used here which fires on document updates of users' collection. This is done so that the rank can be easily calculated without having to pull in all the users' scores (document). The function can be found in the [gist here](https://gist.github.com/ashishbeck/2f5f3d1ab376d09a5cb5445b751380e8). Remember to turn off eslint otherwise, it won't deploy. It is not the cleanest piece of code I have ever written but it is what it is 🙄 +The security rules for the Firestore is as follows: +``` +rules_version = '2'; +service cloud.firestore { + match /databases/{database}/documents { + match /users/{useruid} { + allow read: if request.auth.uid != null; + allow write: if request.auth.uid == useruid; + } + match /community/{doc} { + allow read: if request.auth.uid != null; + allow write: if false; + } + } +} +``` ### Important! When building for release, please make sure to enable the CanvasKit renderer otherwise the custom painter used in the project does not work as intended and produces artifacts in HTML mode (auto mode defaults to HTML renderer for mobile devices). @@ -32,7 +48,7 @@ When building for release, please make sure to enable the CanvasKit renderer oth - Why not use popular plugins like `just_audio` for sound? Well, `soundpool` is amazing with loading assets into memory and executing them in a jiffy which makes for a great playing experience. It can also fire multiple instances of the same audio file at the same time which other packages fail to do. -- This game runs on Android, iOS, and the web. It is not really supposed to be multiplatform because not everything that is implemented here has support for all the platforms. `soundpool` for example has very experimental support for Windows and Linux. Firebase has issues in the said platforms as well. If given enough time and resources, these problems can be solved but it is currently not a priority at all for me. If I was to remove the sounds and Firebase integration for leaderboards, this app would become truly multiplatform and I don't see what else could be hindering it. +- This game runs on Android, iOS, and the web but has been only tested in web and android due to unavailability of a MacOS system. It is not really supposed to be multiplatform because not everything that is implemented here has support for all the platforms. `soundpool` for example has very experimental support for Windows and Linux. Firebase has issues in the said platforms as well. If given enough time and resources, these problems can be solved but it is currently not a priority at all for me. If I was to remove the sounds and Firebase integration for leaderboards, this app would become truly multiplatform and I don't see what else could be hindering it. - The solving function used here incorporates the IDA* algorithm (with pattern database heuristic) written in python (code modified from [Michael Schrandt](https://github.com/mschrandt/NPuzzle)) which is executed in Google Cloud Run and is accessed via HTTP requests. After trying to implement the algorithm in dart and realizing that it could result in potential UI freezes in the web along with many other technical problems, I decided to outsource the computational task. For a puzzle of grid size 3, it is able to solve the puzzle within seconds. A grid size of 4 takes quite some time and 5 is beyond the scope of the algorithm which also contributed to not including the 24-puzzle in the final build. The solution is definitely not optimal (usually 50+ moves) and I am not even trying to go for it because it will take a lot more time (sometimes over 2 minutes to solve with the manhattan distance heuristic). Moreover, the player wouldn't even understand the moves the AI makes so it is not ideal to go for the optimal solutions anyway. It is a purely aesthetic feature that just looks "cool" and is extremely satisfying to watch. diff --git a/docs/flutter_service_worker.js b/docs/flutter_service_worker.js index b891c12..bcce174 100644 --- a/docs/flutter_service_worker.js +++ b/docs/flutter_service_worker.js @@ -39,10 +39,6 @@ const RESOURCES = { "assets/fonts/MaterialIcons-Regular.otf": "4e6447691c9509f7acdbf8a931a85ca1", "assets/NOTICES": "0361e455055857169d430d113cd67346", "assets/packages/cupertino_icons/assets/CupertinoIcons.ttf": "6d342eb68f170c97609e9da345464e5e", -"canvaskit/canvaskit.js": "c2b4e5f3d7a3d82aed024e7249a78487", -"canvaskit/canvaskit.wasm": "4b83d89d9fecbea8ca46f2f760c5a9ba", -"canvaskit/profiling/canvaskit.js": "ae2949af4efc61d28a4a80fffa1db900", -"canvaskit/profiling/canvaskit.wasm": "95e736ab31147d1b2c7b25f11d4c32cd", "favicon.ico": "fbe35961c46b82a9ec070d8fb3072005", "icons/android-icon-144x144.png": "0e3e2760eebf638c25635429676e7e9a", "icons/android-icon-192x192.png": "3b11c81a36f1b7b466dc6ff47e9ec25b", @@ -68,11 +64,11 @@ const RESOURCES = { "icons/ms-icon-150x150.png": "38aceed2c86fd825d9638bf004a3580b", "icons/ms-icon-310x310.png": "345ecd66e502447fd6f0ba67d326d022", "icons/ms-icon-70x70.png": "50575ccdc19ea7ea6e2613dc49414f8d", -"index.html": "3e12c2590a2cedae42c0c840e3aa298d", -"/": "3e12c2590a2cedae42c0c840e3aa298d", -"main.dart.js": "ef791bd84e5eb5e1b0db6426299aa100", +"index.html": "a27b99bfa4fef36757b90a082ed62042", +"/": "a27b99bfa4fef36757b90a082ed62042", +"main.dart.js": "9216d31f99b7a722df6319fe2f154b0c", "manifest.json": "c79f1b83e117145946483a55fffce1b6", -"version.json": "9c99f11c6aee3f756a7021fcf92de2e0" +"version.json": "926859e2b5c4be6f4747fc5862c07050" }; // The application shell files that are downloaded before a service worker can diff --git a/docs/index.html b/docs/index.html index d79d8b7..e89fa0c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -52,7 +52,7 @@ application. For more information, see: https://developers.google.com/web/fundamentals/primers/service-workers -->