Computer Chess Club Archives


Search

Terms

Messages

Subject: jsut for kicks, ehre is my popcount function

Author: scott farrell

Date: 13:43:54 12/04/03

Go up one level in this thread


this seems to work fine, but as always its a fairly big part of my eval time as
I try to evaluate mobility of pieces to safeish squares.

//this is for the count(long) method
transient static final long ONES = 0x5555555555555555L;
transient static final long TWOS = 0x3333333333333333L;
transient static final int FOURS = 0x0f0f0f0f;


// with thanks to http://www.ics.uci.edu/~eppstein/180a/projects/fanorona/

 public static final int count(long set) {
	if (set ==0) return 0;
  set = (set & ONES) + ((set >>> 1) & ONES);
  set = (set & TWOS) + ((set >>> 2) & TWOS);
  int result = (int) (set & 0xffffffff) + (int) (set >>> 32);
  result = (result & FOURS) + ((result >>> 4) & FOURS);
  return (result * 0x01010101) >>> 24;
 }

Scott



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.