]> git.sesse.net Git - stockfish/commit
Simplify BlockedByKing in pawn storms
authorprotonspring <mike@whiteley.org>
Wed, 18 Apr 2018 18:03:37 +0000 (20:03 +0200)
committerStéphane Nicolet <cassio@free.fr>
Wed, 18 Apr 2018 18:03:52 +0000 (20:03 +0200)
commitf7cc0026e3291cd281d2e3975a5f01f63be162aa
tree33c903c31ebb91ba44eb880883fe26a02c235197
parent73e8daa150173efd393a6b1987a4ca320664a397
Simplify BlockedByKing in pawn storms

This patch is non-functional. Current master does four operations to determine
whether an enemy pawn on this file is blocked by the king or not

```
f == file_of(ksq) && rkThem == relative_rank(Us, ksq) + 1 )
```

By adding a direction (based on the template color), this is reduced to two
operations. This works because b is limited to enemy pawns that are ahead of
the king and on the current file.

```
shift<Down>(b) & ksq
```

I've added a line of code, but the number of executing instructions is reduced
(I think). I'm not sure if this counts as a simplification, but it should
theoretically be a little faster (barely). The code line length is also reduced
making it a little easier to read.

Closes https://github.com/official-stockfish/Stockfish/pull/1552

No functional change.
src/pawns.cpp