Giter Club home page Giter Club logo

knights_travails's Introduction

Knight's Travails Project

The goal of this project is to implement a function #knight_moves that shows the simplest possible way to get from one square to another using a Chess Knight. The function will output all squares the knight will move to on its way. This is a variation on the shortest path problem.

This is a project from The Odin Project.

Knight Possible Moves Knight Movement

Screenshot

Installation

Open your Terminal/Command Line. Navigate to the directory where your version will live. Type in the following:

$ git clone https://github.com/JonathanYiv/knights_travails.git
$ cd knights_travails
$ ruby knights_travails.rb

Pre-Project Thoughts

  1. This project led me into my deepest rabbit hole yet: Algorithms and Asymptotic Notation. In order to develop a better understanding, I have:

    1. Gone through Khan Academy's Intro to JS: Drawing and Animation which is a prerequisite to:
    2. Khan Academy's Algorithms Course, and then to gain better understanding of Time Complexity:
    3. Watched mycodeschool's excellent YouTube series on Time Complexity Analysis and then:
    4. Read this excellent stackoverflow answer on Big O notation.
  2. I believe I have developed a better understanding of:

    1. Sorts, Implementation of Sorts, and Sort Efficiency
    2. Rudimentary Javascript
    3. Graphs: Vocabulary, Types, and the 3 Representations
      1. Edge Lists
      2. Adjacency Matrices
      3. Adjacency Lists
    4. Mathematical Proof of Asymptotic Notation (albeit still somewhat to very iffy comprehension...)
    5. Concept of Asymptotic Notation
      1. Big O Notation
      2. Big Θ Notation
      3. Big Ω Notation
  3. My only concern going forward is that I overloaded myself with information before practically applying it to this project. I guess I'll find out...

Post-Project Thoughts

  1. I know that fully implementing Chess is only two projects away, so I put in a little extra effort into fleshing out class Gameboard so it can handle displaying the game appropriately. I'm definitely excited to get to that project in the near future. Odin has me twiddling in RSpec and Git a little bit more and then I'll be there...

  2. The #knight_moves method was actually fairly easy to implement. First, I created a matrix of all existing positions. Then I performed a breadth-first search to fill an array 'distance_info' with each point's distance to the goal and their parent position. The breadth-first search continued until it reached the starting point. Then I iterated through the starting Knight's possible moves and selected the move that had the least distance from the goal position. This information was passed on to the display which moved the knight, and then searched for the next move until the full operation was complete.

  3. I am fairly proud of myself for completing this one.

  4. Eventually, I may touch it up and add options for input. The user would be able to run the script and input a starting point and ending point. The script would then display the step-by-step moves from the starting to ending point. However, I know I will be fully implementing Chess shortly so I am eager to push forwards.

  5. Apparently, I implemented Dijkstra's Algorithm.

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.