Questions tagged [chess]

This tag is for concepts involving the game of Chess.

Filter by
Sorted by
Tagged with
76
votes
6answers
213k views

Design a chess game using object-oriented principles

I would like to know if my approach is correct and how could it could be improved? Also, is there a way to get rid of the relation between the Piece and the ...
32
votes
5answers
5k views

Chess game for my students

I teach programming, and I currently teach my class about inheritance, abstract classes, and mixins. I wrote this code as an example, and I want to be sure it is as good as possible before I release ...
20
votes
2answers
2k views

Enum, constants, or other to represent chess pieces

I'm learning C# and I decided to write a chess program to help me practice the concepts I'm learning in my book. I started the Board class tonight, which is going to handle 1) the board state and 2) ...
18
votes
4answers
73k views

Chess game in Python

I have programmed for 2 months, and I began writing a Chess game. I am a beginner programmer in Python, so please assess my code. ...
18
votes
2answers
836 views

Finding legal knight moves in a chessboard in APL

I wrote a function that takes as input a vector with two integers between 1 and 8 representing a position in a chessboard and ...
16
votes
2answers
3k views

C++ chess game engine using Minimax and alpha-beta pruning;

My chess game is over, everything has been finished, except for some special (like en passant)moves. The main part of the game is its engine which I have coded using the Minimax algorithm with alpha-...
16
votes
2answers
6k views

Simple Chess Game, Part 2: The Pieces

As I was writing my first part of my Chess question, I realized that I couldn't fit all my code into one question (I exceeded the character limit), so I will continue here. The pieces all share the ...
16
votes
2answers
16k views

Simple Chess Game, Part 1: The Board

I am currently creating a chess game, and have so far done the board. The board is pretty much a two-dimensional array, where Pieces are stored in their positions. ...
14
votes
4answers
3k views

Chess engine for chess without checks in C++

Project Description: Chess without checks: A chess variant where you can take the enemy king. This engine implementation is for chess without checks. Since checks don't exist, expect the code to not ...
14
votes
3answers
3k views

N-Queens - Brute force - bit by bit

A discussion in The 2nd Monitor made me realize I had never 'solved' the N-Queens problem. Additionally, as I read up on it, I realized that the 64-squares in a chess board would work well if ...
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 ...
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 ...
14
votes
1answer
440 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 ...
14
votes
0answers
290 views

Ruby chess engine gem

This is my first Ruby gem that claims to provide all the rules of the chess game. My goal was to keep this library as simple as possible via OOP principles, and I'd be glad to hear any feedback from ...
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\$, ...
13
votes
1answer
2k views

Object-Oriented Chess Game in Ruby

I wrote a chess game in Ruby using object-oriented principles. One of the challenges was deciding which particular methods/actions belonged to a particular class, as there were some that felt as if ...
12
votes
3answers
3k views

Printing Command Line Unicode Chess Board

Let me preface this by detailing some of my design philosophy. The intent is to view the board from the perspective of the active player. Player moves are also factored into the design. When ...
12
votes
2answers
661 views

N-Queens functional

I'm trying to get a better grip on the new functional possibilities of Java 8. As an example, I took this very elegant Haskell snippet: ...
11
votes
2answers
1k views

Python Chess Game

I'm developing chess in python, and I've decided to make everything text-based before creating a GUI because it'd be my first time doing the latter. I haven't got around to the actual gameplay, but I'...
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
3answers
989 views

First Chess project

I'd made a project using pygame in python around 3 months ago. This was my first big project after I started learning how to program in college. Now I'd like to know just how good my programming ...
10
votes
4answers
2k views

Chess Architecture

I am currently developing a chess game but have made the mistake of putting all my Java code in one .java file. I need help cutting up my code into more manageable chucks. Could someone show me how ...
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 ...
10
votes
2answers
1k views

Piece of chess engine, which accomplishes move generation

This is a piece of a chess - engine which accomplishes the generation of all (yet unvalidated) moves given a legal board. However, I have the strong doubt this is well written. The following action ...
10
votes
2answers
387 views

Parsing a Chess FEN

What is an FEN? Link to the Wikipedia page: Forsyth–Edwards Notation An FEN is a very simple way of representing a chess position in a single line string. It contains the following data Which piece ...
10
votes
2answers
999 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 ...
10
votes
1answer
140 views

Game of Runes: a similar concept to chess

I have created a game called 'runes' in C. It is similar to Chess, but has a bigger board and different pieces. I would like to know how I can improve the code, for example, by adding proper error ...
10
votes
1answer
150 views

Queens placement

The code below is intended to be a learning material for high school intermediate programming class, as an introduction to recursion and backtracking. I was thinking of rook placement and found it too ...
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 ...
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. ...
9
votes
4answers
414 views

Checking if a Chess space has been attacked

I have this list of at least seven else-if. When their condition is met, I change the same boolean is_attacked to ...
9
votes
3answers
38k views

Generating possible Chess moves

Here is the solution to generating possible moves and keeping the king safe. If someone is willing to look it over and come with some suggestion to perhaps improve it, I would appreciate it. Full ...
9
votes
2answers
14k views

Chess game in Windows Forms Part #1

I've recently created my own 2-player chess game, no AI... at least for now. I do plan to do that in the future, so one of my concerns is if the code is flexible enough to just use the same classes in ...
8
votes
2answers
11k views

Knight moves in Chess game

I am trying to learn Java by doing some (easy) ACM ICPC problems. The problem consist to check if the knight in a chess game can move from a point A(r1, c1) to <...
8
votes
2answers
127 views

Game of Runes: revised version

I have created a game called Runes in C. It is similar to Chess, but has a bigger board and different pieces. I would like to know how I can improve the code, for example, with user interface ...
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 ...
8
votes
3answers
316 views

Unicode Chess PvP with Move Validation

Main Purpose This script allows two players to play chess on a virtual chessboard printed on the screen by making use of the Unicode chess characters. Visual appearence ...
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? ...
8
votes
3answers
519 views

Python program to calculate what pawns are safe

In chess there are eight rows numbered from 1 to 8 and 8 columns a-h. Pawns which are on the lowest row are always in danger to be captured. The objective of the program is to calculate which pawns ...
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 ...
8
votes
3answers
6k views

Minimum number of moves for a knight

The problem is to find the minimum number of moves that a knight will take to go from one square to another on a 'n' cross 'n' chessboard. The code below is based on backtracking. It works well until <...
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 ...
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,...
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 ...
8
votes
1answer
697 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,...
8
votes
1answer
103 views

Printing Colored, CLId Unicode Chess Board - follow-up

Follow up to: Printing Command Line Unicode Chess Board A couple people from the previous question mentioned looking into coloring the command line with ANSI escape sequences. In Python, ...
7
votes
4answers
8k views

Enumerating moves for a chess piece

I'm just at the beginning stages of making a simple chess engine. I have a function that when passed the x and y coordinates on a 2D list can enumerate all possible moves for a piece. It assumes there ...
7
votes
3answers
383 views

Chess puzzle improvement

Is it possible to optimize this solution to the N-queens puzzle? ...
7
votes
2answers
128 views

Hackerrank's Queen's Attack II

https://www.hackerrank.com/challenges/queens-attack-2/problem A queen is standing on an nxn chessboard. The chessboard's rows are numbered from 1 to n, going from bottom to top; its columns are ...
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 ...