Coder Social home page Coder Social logo

davidnhill / jsminesweeper Goto Github PK

View Code? Open in Web Editor NEW
91.0 4.0 17.0 3.68 MB

Minesweeper player, solver and analyser in javascript

Home Page: https://davidnhill.github.io/JSMinesweeper/

License: MIT License

JavaScript 95.07% HTML 3.68% CSS 1.25%
minesweeper javascript game playable solver

jsminesweeper's Issues

massive bug re. invalid state in analyser

TL;DR: i THINK analyzer breaks when leftclicking/leftdragging THROUGH cells that have a mine in

finds board is in invalid state when it absolutely isn't. says tile is invalid
sometimes even just refreshing the tab corrects the problem with the same exact state of the board

i do hope the invalid state "pinpointer" stays but right now it is overdoing it

edit: it suffices to say the necessary leftclick/leftdragging to rebuild analyzing situations is still easily the weakest point (UX-wise) of this otherwise monumental MS tool at this point :)

[Board solver] Error: Uncaught (in promise) TypeError: commonClears is null

Steps

  1. Go to https://davidnhill.github.io/JSMinesweeper/
  2. Uncheck analyses mode
  3. Check use seed , set it to 3297235678736273
  4. Check opening on start
  5. Uncheck fast mode
  6. Select custom game, set it to 10 width , 19 height , 71 mines
  7. Select new game
  8. Check "show hints"
  9. Check "Auto play"
  10. Check "Accept guesses"
  11. Now click 2,2 in the grid

Expected

I would expect the solver (to try) to solve the grid, and guess tiles, like it has done flawlessly for many other seeds

Actual

This seed combination causes the solver to error out, locking out the game canvas

afbeelding

Reprocebility:

Always on Firefox 89.0.2 on Ubuntu x64
Always on Chromium 91.0.4472.114 on Ubuntu x64

Error traces:

Firefox 89.0.2:

Uncaught (in promise) TypeError: commonClears is null
    secondarySafetyAnalysis https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/solver_main.js:1024
    tieBreak https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/solver_main.js:518
    doSolve https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/solver_main.js:456
    solver https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/solver_main.js:52
    sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1238
    sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1278
    setTimeout handler*sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1278
    sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    setTimeout handler*sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    setTimeout handler*sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    setTimeout handler*sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    setTimeout handler*sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    setTimeout handler*sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    setTimeout handler*sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    setTimeout handler*sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    setTimeout handler*sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    setTimeout handler*sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    setTimeout handler*sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    setTimeout handler*sendActionsMessage https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:1267
    on_click https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:907
    startup https://davidnhill.github.io/JSMinesweeper/Minesweeper/client/main.js:152

Chromium 91.0.4472.114:

Uncaught (in promise) TypeError: Cannot read property 'length' of null
    at secondarySafetyAnalysis (solver_main.js:1024)
    at tieBreak (solver_main.js:518)
    at doSolve (solver_main.js:456)
    at solver (solver_main.js:52)
    at sendActionsMessage (main.js:1238)
    at main.js:1278

making inputs a little easier in Analysis mode

love the solver so far, especially the JS one, I would appreciate if we can make setting up boards in Analysis mode a little easier. i have come up with 2 small suggestions for now:

  1. instead of left-clicking each and every cell i would love to be able to keep the left click pressed so we fill out larger patches more quickly

  2. [an option so that] mousewheel down to set the cell's minecount at first does not take into account flags and mines around it (i.e. first mousewheel down always sets a 1). left click is still there doing it normally then.

i dont know if i missed out on any keyboard hotkeys, i dont think i have found any. would love a hotkey for the "Analyze" button for example.

Obviously these are not github issues but I didnt wanna dig to deep for direct contact possibilities.

Thank you.

instances of efficiency mode not doing a free chord

might be related to that last update?

ive encountered this several times now.

reproducible if u recreate the board in the img (web js version)

sorry if this is not a bug but an efficiency trick i do not know about...
edit: yea i think it only does that if it is 100% sure clicking then chording is definitely not gonna take more clicks...i still think these are new occurences and haven't appeared until recently.
chrome_2021-07-04_02-38-15

Progress chance calculations ?

When starting an Expert game and clicking analyse, the corner tiles are marked as having a 39.57% chance of progress. If my understanding is correct, it is the probability none of the adjacent tiles are mines, which should be approx 79^3=50% ?
I also have a question about the way the engine choses its move when guessing. In the file I send along with this post, the engine recommends I play (0,5) which is insane considering the engine thinks it has worse safety, secondary safety and progress than (1,2).
Something else that confuses me : if you for example replace the bottom left corner's 2 by a 1, the engine will stop calculating the secondary safety and progress of (0,5) despite it being shown in yellow and being within the 10% cutoff range (83.33%*0.9=75% and (0,5) has a safety of 79.48).

I am using the solver through the link on the github.
Maybe these issues are related, so I throw them together.
Hopefully I expressed myself clearly enough. Thanks for the great tool.

the board position (image since can't send .mine) :
image

Question About Extracting Solver Script

The algorithm and overall functionality work wonderfully. However, I need the solver script to be separate from the visual code. I want to work on automation using my own board and different technologies. How can I extract the solver script so I can input my board and get the optimal moves and mines as output in pure JavaScript? Do you have any plans to write a standalone solver algorithm without the visual component?

Efficiency mode broken?

Maybe I'm doing something wrong, but playing efficiency mode with hints on, I can't figure out how to use chording. Also, after placing a mine the game seems to freeze up and not let me click anything. Please help, thank you

[enhancement] webassembly for more performance

first, it's an amazing tool, best among what i've found and seen yet, also like what i always wanted to create! (but took few action)
then title says it all.
btw the code smells like translated by hands? you might consider using haxe language (which looks like js/ts (when not doing weird things and deep customization) and compiles to js, but also c/c++/c#/more!) to port the solver core into many languages.
although, it's always harder to port into webassembly....

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.