Skip to content

Instantly share code, notes, and snippets.

View madipally's full-sized avatar

Madipally Naveen Kumar madipally

View GitHub Profile

Keybase proof

I hereby claim:

To claim this, I am signing this object:

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@madipally
madipally / chess.rb
Created December 27, 2017 13:39
chess initialization
class Chess
PIECES = ['knight','rook','queen']
COLS = ['a','b','c','d','e','f','g','h']
ROWS = [1,2,3,4,5,6,7,8]
KNIGHT_MOVES_ARR = [[-1,-2],[1,-2],[-2,-1],[2,-1],[-1,2],[1,2],[-2,1],[2,1]]
QUEEN_MOVES_ARR = [[1,1],[-1,-1],[1,-1],[-1,1],[0,1],[0,-1],[1,0],[-1,0]]
ROOK_MOVES_ARR = [[0,1],[0,-1],[1,0],[-1,0]]
def move_col(pos,count)
@madipally
madipally / move_t_otarget
Created December 17, 2017 01:28
capturing the opponent while moving to target
require 'benchmark'
class MoveToTarget
COLS = ('a'..'h').to_a
ROWS = (1..8).to_a
def initialize
@knight_moves_arr = [[-1,-2],[1,-2],[-2,-1],[2,-1],[-1,2],[1,2],[-2,1],[2,1]]
@queen_moves_arr = [[1,1],[-1,-1],[1,-1],[-1,1],[0,1],[0,-1],[1,0],[-1,0]]
@madipally
madipally / chess_piece_moves.rb
Last active December 27, 2017 13:38
Moving Knight,Rook,Queen to a position on chess board
require 'benchmark'
require_relative 'chess'
class ChessPieceMoves < Chess
def initialize
@moves =[]
end
def piece_move(piece,pos)