Giter VIP home page Giter VIP logo

battleship's People

Contributors

carbocarde avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

elchappo

battleship's Issues

naive solver approach leads to lower precission heat-map

Hi,
Thanks for nice blog write up on problem I was trying to solve some months ago.
As for solver:

def ship_fits(i, j, ship, board=None) -> (int, int):

What solver tries to achieve is to create heat map of probability that part of the ship occupies the spot. There are two approaches here:

  • iterate over each of ships, try to place them on the board, count times spot is occupied by ship. This is current approach in solver
  • iterate all permutations of available ships and create heat map - how ships can be placed on board is function of non-occupied places, number of ships and rules which gives much more accurate heat map,using tremendously more computation than former approach.

Lets take a example:
3x3 board, available ships 1x3size + 2x1size, board initial conditions:

0 0 0
0 0 0
0 0 0
  • with current solver, quite uniform distribution (counting 1x3size ship + 2x1size ship)
4 4 4
4 4 4
4 4 4
  • with alternative: 3size ship can be place only on one side (ex horizontal bottom) with 2x1 size on only top-right and top-left corner
4 1 4
1 0 1
4 1 4

From probability side, improved heat-map is more precise when we reduce available space in board (either by sinking ships or by miss shots) ,also as it is heavy in calculating permutations, should be done on reduced ship size and board size - thus during mid-to-end game.

I was not able to create performant solution of such solver, I will leave that challenge to you ;)
Keep it up!

bug: calculator is not adjusting based on hit or miss

Description

The following behavior has been seen when toggling squares between hit or miss:

  • The circle for suggested next move does not change position.
  • The heatmap for probability of each square does not change.

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.