chess

Adding Alpha Beta pruning to Negamax in Java

早过忘川 提交于 2019-12-14 03:55:24
问题 I am making a chess game in Java and (I think) have successfully implemented Negamax for the AI player. I am having some trouble adding alpha beta pruning to this to improve the algorithm. I have tried following tutorials and example code but just can't get my head around how it works. Below is the code I currently have to get the best move: private Move getBestMove() { System.out.println("Getting best move"); System.out.println("Thinking..."); List<Move> validMoves = generateMoves(true); int

In an online chess game, how to minimize the effect of lag to time controls?

自作多情 提交于 2019-12-12 17:11:52
问题 I'm planing to write a small web app where two players can play a chess game with blitz time controls. Here's a small description of how the process of making a move works: Player A thinks about what move to make Player A sends a move to my server My server processes the request My server sends a response to the push server The push server processes the request The push server sends a response to player B Player B thinks about what move to make It makes sense that step 1 will be running on

Beginner chess rook movement interruption in function [duplicate]

拜拜、爱过 提交于 2019-12-12 00:33:02
问题 This question already has an answer here : Rook movement function not finding interruptions (1 answer) Closed 4 years ago . How can I make a function to find if there are any letters (pieces) in between the king and the rook? I don't understand how to make the function stop when it finds something in between. Because as of now it shows that the king is in check even though it is not. My function moves 1 by 1 in the x and y axis on a 2 dimensional char array until it either finds something

Run thread in background in java

拈花ヽ惹草 提交于 2019-12-11 18:08:45
问题 I'm writing a chess program in java. So far things are coming along fine but I do have a problem with updating my UI. Here's a snippet of code from class ChessBoard which extends JPanel. This is called when a user tries to make a move: if ( isLegalMove( aMove ) ) { // If the move's legal makeMove( aMove ); // Make that move select = null; // Reset some info drag = null; toggleTurn(); // Change turns generateMoves( 0 ); // Get legal moves for CPU repaint(); // Redraw board thread.run(); // Run

Go - modify dereferenced struct pointer changes most struct values, but not slices

心不动则不痛 提交于 2019-12-11 13:08:20
问题 I'm trying to create a shallow copy of a struct Board (a chessboard). Before saving a move to the board, I need to check if that move puts the mover in check. To do so, within the Move method (method of a pointer), I dereference the pointer, update and check this possible board for Check. When I change the value of a single value of the Board type (such as possible.headers = "Possible Varient" ) the original b Board is not changed. But here when I call a method updateBoard() it updates both

How to get actual move rather than move value from mini max algorithm

纵饮孤独 提交于 2019-12-10 10:39:52
问题 I am currently writing a minimax algorithm with alpha beta pruning for Chess. From all the examples I have seen, minimax algorithm will return an int value that represents that best score or board state that will result from the best move. My question is how can we return the best move that is associated with the score return value? For example, my alphabeta() in pseudo below ... public int alphabeta(int depth, Board b, int alpha, int beta, boolean maxPlayer) { if(depth == 0) return

Programming a chess AI

时光怂恿深爱的人放手 提交于 2019-12-09 14:30:43
问题 I'm looking to try and write a chess AI. Is there something i can use on the .NET framework (or maybe even a chess program scripted in Lua) that will let me write and test a chess AI without worrying about actually makign a chess game? 回答1: Not sure about what you are trying to do. If you are looking for a ready-to-use chess GUI, you can use WinBoard. It is completely decoupled from the underlying chess engine(s), thanks to an established communication protocol. Your chess engine thus becomes

android chess game example

故事扮演 提交于 2019-12-09 14:05:35
问题 I'm wondering if there is an android open source code or tutorial in a book/blog for a chess game(can exclude A.I. as I would have to ignor it anyway as I am writing a game that would be similar but different enough to have to right my own A.I. anyway). I've done some looking and all I found was not of any real use because I can't read chinees congee, and even then those comments were very scattered. any help would be great, looking for a board game framework at the very least. 来源: https:/

Programmer Puzzle: Encoding a chess board state throughout a game

旧时模样 提交于 2019-12-09 04:00:39
问题 Not strictly a question, more of a puzzle... Over the years, I've been involved in a few technical interviews of new employees. Other than asking the standard "do you know X technology" questions, I've also tried to get a feel for how they approach problems. Typically, I'd send them the question by email the day before the interview, and expect them to come up with a solution by the following day. Often the results would be quite interesting - wrong, but interesting - and the person would

How does one integrate stockfish into an Android App?

故事扮演 提交于 2019-12-08 15:19:01
问题 I'm trying to work out how to integrate stockfish (or any UCI compatible engine) into my Android application. I've downloaded the stockfish Android zip from here: Download Stockfish Engine. Under the Android directory of the zip there are two files: stockfish-8-arm64-v8a stockfish-8-armeabi-v7a I have two questions: Do I just need to include these two files into my app (and if so where do I put them)? I'm hoping these are pre-built binaries so I don't need to worry about compiling myself. How