Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [chess]

This tag is for concepts involving the game of Chess.

4
votes
0answers
75 views

Move-generation for chess in rust

In the last couple of days I have been programming a chess move generator in Rust from scratch. While it's intent is to be later used in a fully functional engine, where the speed of the move-...
-1
votes
0answers
25 views

Minimum steps to reach target by a Knight In Scala

Given a chessboard of N size (square matrix), the position of Knight and position of a target find out minimum steps ( both count and exact steps) from start tp target for a Knight. If it is not ...
6
votes
4answers
189 views

Chess game design in C++

I built a chess game in C++. My main concern is the design. For example, in the board class it has a 2D array of pieces. This array represents the positions of the pieces, but the piece class also has ...
5
votes
2answers
91 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
47 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. ...
0
votes
0answers
37 views

N Queens on NxN board once more

I am quite new to C++ programming, and would appreciate any comments. How many combinations of N chess queens on a N×N board exist that there is no two queen attacking each other? Input <...
8
votes
2answers
227 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
78 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
500 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
176 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 ...
4
votes
1answer
90 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 ...
13
votes
2answers
2k 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 ...
4
votes
0answers
211 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
68 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
70 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
117 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
388 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
111 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
853 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
287 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
242 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
1k 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
792 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 ...
3
votes
1answer
2k 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
981 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
69 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
429 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 - ...
10
votes
3answers
422 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 ...
6
votes
1answer
390 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 ...
5
votes
3answers
2k views

OOP Chess design job interview practice

please comment on game flow, Solid principle and OOP concepts. ...
5
votes
1answer
310 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
74 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
2k 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
137 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 ...
0
votes
0answers
92 views

Knight-tour code taking very long time

I am trying to solve knight-tour problem using Racket. It seems to be working but it is taking a long time and I have not been able to get even one solution using this code (It reaches 62 positions ...
6
votes
1answer
4k 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
552 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
169 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
1k 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
691 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
379 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
176 views

Alpha Beta Pruning

I'm implementing alpha-beta pruning for a chess engine in TypeScript Here's the code: ...
5
votes
1answer
136 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
171 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
789 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? ...
9
votes
1answer
1k 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. ...
12
votes
1answer
2k 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
574 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 ...