我正在集思广益,想用 FPGA 创建一个国际象棋引擎。你该做什么、不该做什么?
首先,您可以轻松地将引擎分为两部分,移动生成器和板评估器,在 FPGA 中执行这两个操作或在 cpu 中执行此操作,在 FPGA 中执行这两个操作有什么好处。
我假设 FPGA 编程需要更多的努力,因为优化并不是那么明显,只要花时间,你总能找到更好、更快的方法。(这可能发生在我身上,因为我是 FPGA 编程的新手)
另外就是成本,一块FPGA要多少钱才能胜过1000美元的CPU?我知道这几乎不可能回答,但我想知道 500 美元是否是一个好的估计?
您认为这种 FPGA 方法会产生更好的结果吗?或者我应该将我的工作放入标准 CPU 国际象棋引擎中。我不确定标准引擎的进化和新方法还有多少空间。
我想了解基本的国际象棋算法.我还没有深入阅读文献,但经过一番思考后,我的尝试是:
1)为碎片分配重量值(即主教比棋子更有价值)
2)定义将值附加到特定移动的启发式函数
3)构建minimax树以存储所有可能的移动.通过alpha/beta修剪修剪树.
4)遍历树以找到每个玩家的最佳移动
这是国际象棋算法的核心"大局观"吗?有人能指出我对棋算法更深入的资源吗?
我正在学习使用Windows表格C#制作一个小型的国际象棋游戏,游戏只包括双方的棋子,我已经画了板并组织了那些地方的作品,但老实说我不知道如何开始实施通过单击工件上的鼠标移动,然后移动我要移动它的位置.
作为参考,黑色棋子被命名为棋子,白色棋子被命名为棋子
这是我的董事会代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AIchess
{
public partial class Form1 : Form
{
static System.Drawing.Bitmap piece = AIchess.Properties.Resources.piece;
ChessPiece Piece = new ChessPiece(piece, ChessColor.Black);
static System.Drawing.Bitmap pieceW = AIchess.Properties.Resources.pieceW;
ChessPiece PieceW = new ChessPiece(pieceW, ChessColor.White);
Square[,] square = new Square[8, 8];
public Form1()
{
InitializeComponent();
int i, j;
for (i = 0; i < 8; i++)
{
for (j = 0; j …
Run Code Online (Sandbox Code Playgroud) 我正在开发一个国际象棋游戏,并且能够让我的 Pawn 棋子向前移动一个和两个方格,并防止它在第一次移动后向前移动两个方格。此外,Pawn Piece 可以对角捕获棋子,但不进行快速捕获和 pawn 提升。对于典当促销,我需要一个关于如何在其 targetRow == 0 或 7 时将典当片与另一片交换的想法。如果有人可以帮助我提供有关如何实现这两个功能的逻辑或想法,我将不胜感激。
这是我的代码:
private boolean isValidPawnMove(int sourceRow, int sourceColumn, int targetRow, int
targetColumn){
boolean isValid = false;
if(isTargetLocationFree()){
if(sourceColumn == targetColumn){
//same column
if(sourcePiece.getColor() == Piece.YELLOW_COLOR){
//yellow
if(sourceRow + 1 == targetRow ){
//move one up
isValid = true;
}else if(sourceRow == 1 && targetRow == 3){
if(sourceRow + 2 == targetRow) {
isValid = true;
}
}else{
//not moving one up
isValid = false;
}
}else{
//brown
if(sourceRow …
Run Code Online (Sandbox Code Playgroud) 为什么这个字符串不在一行连接?我不是"\n"打破这条线,不应该像#"##"一样登录到控制台?
for (var i = 1; i <= 8; i++) {
var str = "";
if (i % 2 == 0)
str += "#";
else
str += " ";
console.log(str);
}
Run Code Online (Sandbox Code Playgroud) 例如,所有白棋子的攻击都是通过向左移动 7 或 9 位生成的(或者向右移动,我可能会弄错,但我认为很容易理解要点)。
所以白色的棋子位板看起来像这样
00000000000000000000000000000000000000001111111100000000
会被转移到这个
00000000000000000000000000000001111111100000000000000000
但是,如果您尝试在 8x8 阵列中描绘此示例,则其中一个棋子会穿过棋盘的边缘。
那么,当这些位被移动以生成攻击时,引擎如何防止自己生成穿过棋盘边缘的攻击呢?
我想写AI国际象棋,我有一个问题.我准备好了碎片移动规则,我正在尝试删除无效的移动(让国王受到检查等).我写了这样的话:
ValidateMove(board);
{
for(i=0;i<64;i++)
if(board[i]==king.opposite) kingpos=board[i];
createmoves(board);
if (moves.contains(kingpos)) return false;
}
Run Code Online (Sandbox Code Playgroud)
但是,我正在使用minimax + alpha beta,验证使我的搜索速度非常慢.
我从这里读了一个教程链接!这给了我一个基本的棋子布局,但现在我的棋子跳过其他棋子我可以知道如何检查源和目的地广场之间是否有一些中间硬币.
所以我想检查输入的位置在国际象棋棋盘中是否有效,
//returns true if the position is in the range of A1-H8
private boolean isValid(String position){
char first=position.charAt(0);
String letter=(""+first).toLowerCase();
boolean validLetter=position.equals("a") || position.equals("b") || position.equals("c")||
position.equals("d") || position.equals("e")|| position.equals("f") || position.equals("g") ||
position.equals("h");
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,布尔值非常难看,那么更好的方法是什么呢?
顺便问一下,你如何检查第二个字符是否是数字?
===编辑====谢谢大家!但是你的所有答案对我来说都很复杂,我只是开始学习java,所以请你给我一个更基本的方法来解决这个问题?
我正在尝试通过创建一个简单的国际象棋游戏来学习Haskell.但是,我无法定义代表电路板方块的功能
import Data.Char
type Board = [[Square]]
type Square = Maybe Piece
data Piece = Piece PieceColor PieceType deriving (Show, Eq)
data PieceColor = White | Black deriving (Show, Eq)
data PieceType = King | Queen | Rook | Bishop | Knight | Pawn deriving (Show, Eq)
...
displaySquare :: Square -> Char
displaySquare n
| n == Nothing = ' '
| n == Just (Piece White _) = displaySquare' n
| otherwise = toLower (displaySquare' n)
where
displaySquare' …
Run Code Online (Sandbox Code Playgroud) chess ×10
java ×3
string ×2
algorithm ×1
bitboard ×1
c# ×1
c++ ×1
eloquent ×1
field ×1
fpga ×1
haskell ×1
javascript ×1
maybe ×1
performance ×1
polymorphism ×1
validation ×1
winforms ×1