Difference between revisions of "Calculon"

From Chessprogramming wiki
Jump to: navigation, search
(Created page with "'''Home * Engines * Calculon''' FILE:Calculon.jpg|border|right|thumb|200px|link=https://fi.wikipedia.org/wiki/Tiedosto:Calculon.jpg| Calculon <ref>[https...")
 
Line 10: Line 10:
 
=getPiece=
 
=getPiece=
 
Calculon's ''getPiece'' routine to get a the [[Pieces#PieceTypeCoding|piece code]] of a square (the least significant one-bit of the passed bitboard pos, typically single populated)
 
Calculon's ''getPiece'' routine to get a the [[Pieces#PieceTypeCoding|piece code]] of a square (the least significant one-bit of the passed bitboard pos, typically single populated)
from the six [[Bitboard Board-Definition#SixTwo|six piece bitboards]] of its [[Board Representation|board representation]] is an idiosyncratic sample in avoiding a redundant [[8x8 Board|8x8 board]] as well in [[Avoiding Branches|avoiding branches]].
+
from the [[Bitboard Board-Definition#SixTwo|six piece bitboards]] of its [[Board Representation|board representation]] is an idiosyncratic sample in avoiding a redundant [[8x8 Board|8x8 board]] as well in [[Avoiding Branches|avoiding branches]].
 
Taking the [[General Setwise Operations#Union|union]] (val) of six piece-specific [[General Setwise Operations#Rotate|rotates]] (left by 1..6) of six piece disjoint [[General Setwise Operations#Intersection|intersections]]
 
Taking the [[General Setwise Operations#Union|union]] (val) of six piece-specific [[General Setwise Operations#Rotate|rotates]] (left by 1..6) of six piece disjoint [[General Setwise Operations#Intersection|intersections]]
 
for the absolute difference of the [[BitScan#TrailingZeroCount|trailing zero counts]] of that union and the passed square bitboard (pos) is a bit too much calculation for that purpose <ref>[https://github.com/BarrySW19/CalculonX/blob/master/src/main/java/barrysw19/calculon/engine/BitBoard.java#L418 CalculonX/BitBoard.java at master · BarrySW19/CalculonX · GitHub]</ref>.
 
for the absolute difference of the [[BitScan#TrailingZeroCount|trailing zero counts]] of that union and the passed square bitboard (pos) is a bit too much calculation for that purpose <ref>[https://github.com/BarrySW19/CalculonX/blob/master/src/main/java/barrysw19/calculon/engine/BitBoard.java#L418 CalculonX/BitBoard.java at master · BarrySW19/CalculonX · GitHub]</ref>.

Revision as of 21:57, 23 February 2020

Home * Engines * Calculon

Calculon [1]

Calculon,
a Java chess engine by Barry Smith named after the Futurama character. It is open source, licensed under the Apache License, Version 2.0 and hosted at GitHub [2]. Calculon is UCI compatible, uses bitboards as basic data structure, and applies Negamax alpha-beta. The engine regularly plays on ICC under the name CalculonX and has Blitz/Standard ratings there around the 1750 mark.

getPiece

Calculon's getPiece routine to get a the piece code of a square (the least significant one-bit of the passed bitboard pos, typically single populated) from the six piece bitboards of its board representation is an idiosyncratic sample in avoiding a redundant 8x8 board as well in avoiding branches. Taking the union (val) of six piece-specific rotates (left by 1..6) of six piece disjoint intersections for the absolute difference of the trailing zero counts of that union and the passed square bitboard (pos) is a bit too much calculation for that purpose [3].

public class BitBoard { // Position object

  public byte getPiece(long pos) {
    long val = Long.rotateLeft(bitmaps[MAP_PAWNS]   & pos, MAP_PAWNS)   
             | Long.rotateLeft(bitmaps[MAP_KNIGHTS] & pos, MAP_KNIGHTS) 
             | Long.rotateLeft(bitmaps[MAP_BISHOPS] & pos, MAP_BISHOPS) 
             | Long.rotateLeft(bitmaps[MAP_ROOKS]   & pos, MAP_ROOKS)   
             | Long.rotateLeft(bitmaps[MAP_QUEENS]  & pos, MAP_QUEENS)  
             | Long.rotateLeft(bitmaps[MAP_KINGS]   & pos, MAP_KINGS);  
    if(val == 0) {
      return Piece.EMPTY;
    }
    return (byte) ((Long.numberOfTrailingZeros(val) - Long.numberOfTrailingZeros(pos)) & 0x07);
  }
}

External Links

Chess Engine

Misc

References

Up one Level