Giter Site home page Giter Site logo

shagunbose / 8-queen Goto Github PK

View Code? Open in Web Editor NEW
1.0 0.0 0.0 46 KB

How can you place 8 queens on a 8x8 chessboard such that they do not intercept each other? I wrote a recursive solution that incorporates backtracking as a strategy!

Java 98.98% Shell 1.02%
backtracking-algorithm recursive-algorithm java 8-queens

8-queen's Introduction

The 8 Queen puzzle basically asks the question of how you could place 8 queens on a 8x8 chessboard such that they do not intercept each other. A queen can move forwards, backwards and diagonally. 

Through this project i wanted to attempt writing a recursive solution that incorporates backtracking as a strategy! 

Notes: 
- I used a little bit GUI - where you can refresh the board to see different solution
- Please note that this GUI randomly places the  first queen in the first row and so sometimes you might press refresh but the board remains the same. 
- I have added an image of the blue crown instead of blue squares
- The recursive method is called findEightQueen, it uses the helper method calculateSafeSpots
- The methods paintComponent and update are for graphics. 
  I hope to animate the solutions so they pop up on the board as the computer calculates them, 
  but I have't been able to successfully do so yet.  
  
- IMPORTANT: I have commented out a certain print statement as the console was getting many lines of code, 
  however if you want to see what going on in the code at a deeper, feel free to uncomment it 
  It shows which tiles have been marked safe/unsafe by which queen

For future improvements: 
- I want to animate the game in such a way that you can watch it or play it manually. 
- In the automatic version, you should be able to watch as the program searches for the Queen whereas in the manual one the user can place queen and try to figure out where to place each queen. 

Compile and Run Instructions:
Compile by -  javac EightQueen.java
Run by -  java EightQueen

Thank you!

8-queen's People

Contributors

shagunbose avatar

Stargazers

 avatar

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.