边缘方攻击如何处理
我一直在努力了解国际象棋发动机攻击的魔术比特板。 我想我粗略地理解它们,但是每个人都无法正确解释的一件事是如何用边缘正方形处理阻滞剂
,此stackoverflow答案 https://stackoverflow.com/a/a/30862064/18749115
封锁蒙版是所有可以占据的正方形,并阻止您的零件进一步移动。边缘正方形不需要参与其中,因为您的作品无论如何都无法越过那个正方形
移动板是给定阻滞剂板的最终可用移动。这包括您作品的可能捕获。请注意,它还包括捕获自己的作品(但是您可以公正,而不是自己的零件位置来删除这些位置)。
在这里,他解释了不需要包含边缘广场,但是他给出的例子没有边方形,因此他很容易和
位。
我知道不包括边缘正方形会大大减少桌子的大小。 但是我很困惑,当敌人的作品恰好在边缘广场时,我们将如何发动攻击
I've been trying to understand magic bitboards for attack generation in chess engines.
I think I roughly understand them, but one thing everyone fails to explain properly is how to handle blockers with edge squares
For example, this stackoverflow answer
https://stackoverflow.com/a/30862064/18749115
The blocker mask is all of the squares that can be occupied and block your piece from moving further. The edge squares don't need to be a part of that, because your piece can't move further past that square anyway
The move board is the resulting available moves for your piece, for a given blocker board. This includes possible captures for your piece. Note that it also includes capturing your own pieces (but you can just AND it with a NOT of your own piece locations to remove those).
Here he explains edge squares don't need to be included, but the example he gave doesn't have an edge square, so he just easily and
the bitboard.
I understand that not including edge squares drastically reduce the size of the table.
But I'm confused how we would go about generating attacks when an enemy piece happens to be in an edge square
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关键是,边缘方形上是否有一块,在两种情况下,滑动件都会发生相同的攻击。如果边缘广场被占用(朋友或敌人)?该作品可以攻击它。如果没有占领?好吧,广场仍在攻击中,攻击模式相同。
最重要的是,无论其占用状态如何,滑动件都将始终能够攻击边缘正方形。
考虑以下板:
板上有3件。中间和另外两个碎片(什么都没关系)。新闻的攻击模式是什么?
现在,让我们考虑另一种板配置:
这次在D8上没有作品。什么是攻击模式?
完全相同。
D8上的作品的存在并没有改变攻击模式 - 如果不存在,我们会得到相同的攻击模式。因此,当我们探索预先计算的攻击表时,我们可以安全地掩盖我们用于关键计算的占用位比位的边缘正方形,因为我们知道,无论是否被占用,我们都会获得相同的攻击模式。这使我们能够用预先计算的攻击使我们的桌子稍小一点,并节省一些空间。
如果滑动件位于板的内部,则只需掩盖A和H文件,以及第一个和8个排名。唯一的问题是,当滑动件位于板的边缘时
,现在您必须谨慎考虑a文件的占用。您只能掩盖第一和第8级和H文件。
因此,掩模计算是:
The point is that it doesn't matter whether there's a piece on the edge square, the sliding piece will have the same attacks in either case. If an edge square is occupied (by either friend or foe)? The piece can attack it. If it isn't occupied? Well, the square is still under attack and the attack pattern is the same.
The bottom line is, the sliding piece will always be able to attack the edge square no matter it's occupancy status.
Consider the following board:
There's 3 pieces on the board. A rook in the middle and two other pieces (doesn't matter what pieces). What is the attack pattern for the rook?
Now let's consider another board configuration:
This time there is no piece on D8. What is the attack pattern?
It is exactly the same.
The presence of a piece on D8 did not change the attack pattern - we would get the same one if it was't there. So when we are probing our precalculated attacks table, we can safely mask off the edge squares from our occupancy bitboard that we use for the key calculation, because we know that we will get the same attack pattern whether they are occupied or not. This allows us to make our table with precalculated attacks a bit smaller and save some space.
If the sliding piece is located in the inner portion of the board, you can just mask off the A and H files, and 1st and 8nd rank entirely. The only issue is when the sliding piece is on the edge of the board
Now you have to be careful to consider the occupacy of the A file as well. You can only mask off 1st and 8th rank and H file.
So the mask calculation is: