Questions tagged [chess]

This tag is for concepts involving the game of Chess.

Filter by
Sorted by
Tagged with
5
votes
2answers
362 views

Chess Simulation

Part of the program I wrote simulates a Chess game choosing random moves for each player until it's a draw or win for either player. It takes 3 seconds to complete 1 simulation and since it trains ...
3
votes
1answer
73 views

Mark positions attacked by a queen on a chess board

Problem - Given a chess board and the position of only one queen piece in it, mark all the position where the queen can move with X. Kindly review this Scala code and suggest improvements. ...
10
votes
2answers
1k views

PHP Chess Version 2

For programming practice, I created a chess program in PHP (my most comfortable language). The program reads a FEN (a string with the location of all the pieces on the board) from the URL, generates ...
1
vote
0answers
378 views

PHP Chess Part 1 - ASCII Board & Import Position

I have been really into chess lately so I decided to program the game in PHP for practice. I want to get more comfortable with classes. Part 1 of the project is complete. I have a working ASCII board ...
0
votes
1answer
2k views

Object oriented design of chess game [closed]

I was trying to design a chess game in Java. I have just started learning design patterns and am not sure if my approach here is right. Could you please suggest ways to better this design ? Below is ...
3
votes
2answers
567 views

Demonstration of ChessBoard Traveling (CoderByte)

Problem Have the function ChessboardTraveling(str) read str which will be a string consisting of the location of a space ...
5
votes
2answers
600 views

Diagonal Movement Code for Python Chess Engine

I'm currently in the process of building my own Chess game engine and could really use some suggestions on how to make this segment of code for calculating diagonal moves more efficient. (This is ...
14
votes
2answers
12k views

Chess application in Java

This is my very first project in java. I would love some feedback on my design. How the same implementation can be better written. Idioms, conventions, anything that comes to your mind. I hope I have ...
5
votes
0answers
435 views

Backtracking solver for n queens problem and knight's tour

Playing with https://ocaml.org/learn/tutorials/99problems.html#Miscellaneous-Problems I wrote a backtracking solver for the n queens problem, then the knight's tour, and realised I could generalise ...
2
votes
1answer
75 views

Determine if 1 Queen can take King

This challenge was pretty simple - be given the coordinates of a king and a queen on a chess board and determine if the king is in check. Input is the number of test cases with each test case on a ...
3
votes
1answer
131 views

Solving Knight's Travails Problem without using vector for position

I'm trying to implement a solution to the The Odin Project - Project 2: Knight’s Travails in Clojure (Functional Programming) based on the solution posted by benjdelt. I would like to know your ...
4
votes
1answer
267 views

Generating and printing chess board in Rust

This is the beginning of a chess program I'm writing in Rust. I'm new to Rust, so while this program works, I'm sure there are many improvements that could be made. For instance, I wanted to declare ...
2
votes
2answers
1k views

HackerRank - Queens Attack II - Java

The problem definition can already be found here. Given a chess board with dimensions n × n (where n is up to 100000) and the (r, c) positions of various obstacles, how many squares can a queen at a ...
3
votes
3answers
399 views

Counting possible moves for a queen

The challenge is this: You have a function that is passed a board length (8x8 chess board), with the coordinates of the queen's location, along with an array of obstructions (opponents). Given the ...
-3
votes
1answer
3k views

Python class for chess pieces [closed]

Please review my current try of creating a class for chess pieces. I not only want to be able to play a game of chess with this but also solve chess puzzles, thats why I want a flexible board size and ...
8
votes
1answer
701 views

Beginner's Knight's tour in Python (BFS)

I wanted to implement this as short and effective as I could without using anything that is not basics, in order to improve my skills. I would appreciate input about things like memory leaks I missed,...
6
votes
1answer
274 views

Find total of non-attacked positions in a Chess board - UVA 10284

The input is until EOF, give in the FEN notation. The output should be the count of non-attacked positions. My code passes in all test cases in uDebug, but it doesn't pass on the hidden cases. All ...
5
votes
1answer
3k views

Calculate knight moves

This is my first little python project. I want to get to a point where i can solve chess puzzles like this one from puzzling.stackexchange. I want to be able to change the board size to something like ...
2
votes
1answer
2k views

Designing a chess application using object oriented principles

Right now, the purpose of this java program is to correctly move chess pieces with a driver class. ChessBoard.java ...
2
votes
1answer
8k views

Eight queens with Java

The following code works great but take too much time. placeQueens requires much time too. The program takes 5-10 seconds. ...
2
votes
3answers
3k views

Testing whether a chess move puts the king in check

This is my first time back in C++ after a year of Java and essay-writing (and/or crying). My current progress is, all by-definition moves implemented, including castling, en-passant, draw by ...
1
vote
3answers
80 views

Choosing a movement strategy based on the type of chess piece

PawnMovement ... KingMovement are of type Movement. This is implementation of strategy ...
8
votes
2answers
1k views

Python: Pawn race

Another day, another Chess related CodeFights problem. Pawn Race Pawn race is a game for two people, played on an ordinary 8 × 8 chessboard. The first player has a white pawn, the second one - a ...
10
votes
3answers
519 views

Function to test whether the source and destination squares represent a valid knight move

The following is my solution to a problem. While it works - I want to learn how to optimize this in a much better way (I'm new to C++). My original idea was the use a ...
8
votes
1answer
2k views

Python Amazon Checkmate

Found this challenge on CodeFights and would love a review of my style. Description An amazon (also known as a queen+knight compound) is an imaginary chess piece that can move like a queen or a ...
6
votes
3answers
3k views

OOP Chess design job interview practice

please comment on game flow, Solid principle and OOP concepts. ...
5
votes
1answer
470 views

Compute all valid configuration of eight queens on a 8x8 chess board

Write an algorithm to print all valid ways of arranging eight queens on an 8x8 chess board so that none of them attack any other. Following is my code for this. Do you see any performance or coding ...
1
vote
2answers
100 views

Detecting capturing moves that pawns can make, in both directions

I have this function that contains two similar if statements that is kind of hard to re-factor. I am saying this because these two share a significant portion of ...
11
votes
3answers
8k views

Chess engine in C++

I'm looking for experienced honest feedback on my chess engine. I don't know what you'd be looking for, but my goal is to become a better programmer. board.h ...
10
votes
1answer
191 views

Finding a checkmate with two bishops using Python

I've written a Python program to find the fastest way to a checkmate from a starting position. The stronger side has a King and two Bishops, and the weaker side has just a King. The weak King always ...
8
votes
1answer
22k views

Chess game in C++

I have written a chess game. No castling or en passant, pawn gets promoted to queen. Game isn't drawn after 50 moves. The AI is a naive minimax implementation. The chess AI algorithms can be improved,...
7
votes
1answer
938 views

Genetic Algorithm for N-queens is very slow

Using Genetic Algorithm to solve N-Queens problem where N=22. My program is functional and is capable of solving N-Queen problems up to around where N=15, but everything after that is absurdly slow. ...
2
votes
1answer
307 views

Non-recursive Knights Tour implementation in C using Warnsdoff's rule

Just trying to get used to writing programs in C so have written this program to find valid Knights Tours on a 8x8 board. I guess my queries are more focused on my use of the language and how I could ...
3
votes
1answer
2k views

Optimizing Recursion in Knight's Tour

I'm trying to write a program for a university project. It should count all possible open tours (i.e. the start and end fields are not the same) recursively on a chessboard depending on board size and ...
7
votes
1answer
3k views

First chess game

I am just new to programming I just have a 2 month experience in programming and a 2 week experience with python. This is my chess game written in python with pygame. Can some one help me how can I ...
6
votes
1answer
825 views

Bishop Diagonal

I have solved this kata on Codewars.com and it passes all tests. I am looking for refactoring tips and proper coding tips as well. Also I am a beginner that is trying to Improve. I would like to ...
2
votes
0answers
246 views

Alpha Beta Pruning

I'm implementing alpha-beta pruning for a chess engine in TypeScript Here's the code: ...
5
votes
1answer
143 views

Find all distinct 8x8 chessboards where 5 queens attack/occupy every square

Average time (without printBoard()) on Intel(R) Celeron(R) CPU N2840 of 100 runs: GCC 5.4.0 with -O3: 0.48885504s Clang 3.8.0 with -O3: 0.52578794s My ideas for ...
4
votes
1answer
354 views

Calculating the squares dominated by a queen on a chessboard

I have a JavaScript function that increments a counter for each square on the chessboard as it becomes dominated by a queen and decrements it if one of the dominating queens are removed (only queens, ...
4
votes
1answer
3k views

Hackerrank: KnightL on a Chessboard

Problem statement KnightL is a chess piece that moves in an L shape. We define the possible moves of KnightL(a,b) as any movement from some position (x1, y1) to ...
8
votes
3answers
2k views

N-Queens Recursive Implementation in C++11

I created a recursive, optimized, N-Queens implementation in CPP. Any suggestions for improvement? ...
10
votes
1answer
4k views

Chess Game in python

I started to try my hand at making a Chess Game. It works as a game, but I know this certainly not the most efficient way of doing it. I'm just looking for advice and critique on how to get better. ...
13
votes
1answer
4k views

Hackerrank Queen's Attack II

Problem statement A queen is standing on an \$n\$x\$n\$ chessboard. The chessboard's rows are numbered from \$1\$ to \$n\$, going from bottom to top; its columns are numbered from \$1\$ to \$n\$, ...
8
votes
3answers
753 views

UVA 750: 8 Queens Chess

In chess it is possible to place eight queens on the board so that no one queen can be taken by any other. Write a program that will determine all such possible arrangements for eight queens given ...
14
votes
2answers
1k views

Yet another piece of Chess software

I've written a piece of chess software which does some validation checks (check, checkmate etc). I've not implemented some of the more exotic Chess moves (e.g. rooking, en passant, promotion). I've ...
8
votes
3answers
2k views

Really fast Knight's Tour using concurrency and Goroutines

In less that 5 seconds on a normal PC, I found the answer in simple brute-force. Before I met Go, I didn't believe that it will be so easy to use all the power of the PC by using Go Goroutines for ...
4
votes
2answers
4k views

Find diagonal positions for bishop movement

In a chess board, I need to find the diagonals a bishop can move on, and more specifically, the coordinates of those squares. So, given a grid of any size and a position in that grid (expressed in ...
1
vote
1answer
338 views

Eight queens in C++

The idea behind this problem is to represent a configuration of 8 queens with a one-dimensional array. So a[0] represents the first row, a[1] the second row etc. and ...
14
votes
1answer
441 views

Grand Chess domain model and helper functions

So I am trying to write, essentially from a blank slate, a program that plays Grand Chess. In short, it is a chess variant that is played with two extra pieces, on a 10x10 board, no castling, and ...
4
votes
2answers
17k views

OOP chess game implementation in C++

I am attempting one of the questions from Cracking the Coding Interview: "Design a chess game using object oriented principles." The solutions are in Java and below is my attempt to create something ...