Code Monkey home page Code Monkey logo

knight-map's Introduction

banner

Knight Map

version: 1.0.0
author: Paul Clayberg
license: GPL 3.0

PURPOSE

Generates a map based on the movements of the knight piece in chess.

Given coordinates (x,y), the knight can move to squares within the following set:

N(x,y)  =  ( x ± a, y ± b )  ∪  ( x ± b, y ± a )
        for a=1, b=2

The knight's complex movement gives rise to many interesting patterns and scenarios. Because the vector is not a pair of even or odd numbers, the knight is forced to change color each time it moves. Due to this, it can only attack squares of an opposite color to its own. Moreover, once the knight moves, it will be able to attack only the same colored squares as that from which it came.

This color-swapping compulsion makes some squares quickly reachable, but can be unforgiving in other cases. By making these movement patterns both visible and configurable, this tool aims to help to provide a better understanding of how the knight maneuvers around its environment. The movement vector (a,b) can also be changed to allow the study of other jumping pieces. The default value is (1,2), but it can be set to any pair of positive, non-zero integers.

Output settings can be changed by modifying the parameters in knight.py. By placing more knights, friendly pieces, or changing the grid dimensions, countless scenarios can be studied.

SYNOPSIS

python knight.py

DEPENDENCIES

  • python (3.8.10)
  • color terminal emulator (eg xterm)

LICENSE

Copyright (C) 2022 Paul Clayberg

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

SCREENSHOTS

[1] Knight in the center, no labels

knight1

[2] Knight unable to reach corner due to being blocked by friendlies

knight2

[3] Knight unable to leave corner due to being blocked by friendlies

knight3

[4] Two knights in opposite corners with some friendlies

knight4

[5] Knight with only one escape path

knight5

[6] Knight in corner, unblocked

knight6

knight-map's People

Contributors

paulpls avatar

Watchers

 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.