[gray-matter] r1608 committed - bad JUJU. Reverting to 1602....

0 views
Skip to first unread message

codesite...@google.com

unread,
Jul 29, 2010, 1:54:47 AM7/29/10
to gray-matter-...@googlegroups.com
Revision: 1608
Author: protonspring
Date: Wed Jul 28 22:54:14 2010
Log: bad JUJU. Reverting to 1602.
Issue 44 is still a problem and
check for insufficient material is disabled.


http://code.google.com/p/gray-matter/source/detail?r=1608

Modified:
/trunk/inc/bitboard.h
/trunk/inc/board_base.h
/trunk/inc/library.h
/trunk/src/board_base.cpp
/trunk/src/board_heuristic.cpp
/trunk/src/book.cpp
/trunk/src/clock.cpp
/trunk/src/configfile.cpp
/trunk/src/library.cpp
/trunk/src/search_base.cpp
/trunk/src/search_mtdf.cpp
/trunk/src/xboard.cpp

=======================================
--- /trunk/inc/bitboard.h Wed Jul 28 10:11:39 2010
+++ /trunk/inc/bitboard.h Wed Jul 28 22:54:14 2010
@@ -50,11 +50,11 @@
public:
bitboard_t hashes[MAX_MOVES_PER_GAME];
unsigned mNumElements;
- inline bitBoardArray()
+ inline bitBoardArray()
{
mNumElements = 0;
}
- inline unsigned size() const
+ inline unsigned size() const
{
return mNumElements;
}
=======================================
--- /trunk/inc/board_base.h Wed Jul 28 10:11:39 2010
+++ /trunk/inc/board_base.h Wed Jul 28 22:54:14 2010
@@ -72,7 +72,7 @@
inline static bitboard_t DIAG_SET(int n, bitrow_t d){return
((bitboard_t) (d) << diag_index[n]);}

// This macro finds the first set bit in a BitBoard.
- inline static int FST(bitboard_t b){return (Library::find_64(b) - 1);}
+ inline static int FST(bitboard_t b){return (find_64(b) - 1);}

// Convenient BitBoards:
static const bitboard_t SQUARES_CENTER =
0x0000001818000000ULL; // 4 center squares.
=======================================
--- /trunk/inc/library.h Wed Jul 28 11:04:14 2010
+++ /trunk/inc/library.h Wed Jul 28 22:54:14 2010
@@ -67,6 +67,7 @@

// Win32 header files:
#ifdef _MSDEV_WINDOWS
+#define _WIN32_WINNT 0x0501
#include "MSDEVstdint.h"
#else
#include <stdint.h>
@@ -88,61 +89,38 @@

#endif

-
-class Library
-{
- public:
- //this method helps look up bits
- static const int MultiplyDeBruijnBitPosition[32];
-
- //Windows needs a variable to hold the time per move
- //since it seems to get lost/corrupted in the current
- //threading model
- static unsigned int timePerMove;
-
- // Function prototypes related to threads:
- static int thread_create(thread_t *thread, entry_t entry, void *arg);
- static int thread_wait(thread_t *thread);
- static int thread_destroy(thread_t *thread);
-
- // Function prototypes related to mutexes:
- static int mutex_create(mutex_t *mutex);
- static int mutex_try_lock(mutex_t *mutex);
- static int mutex_lock(mutex_t *mutex);
- static int mutex_unlock(mutex_t *mutex);
- static int mutex_destroy(mutex_t *mutex);
-
- // Function prototypes related to condition variables:
- static int cond_create(cond_t *cond, void *attr);
- static int cond_wait(cond_t *cond, mutex_t *mutex);
- static int cond_signal(cond_t *cond);
- static int cond_broadcast(cond_t *cond);
- static int cond_destroy(cond_t *cond);
-
- // Function prototypes related to timers:
- static int timer_function(void (*function)(void *), void *data);
- static int timer_set(int csec);
- static int timer_cancel();
-
- // Function prototypes related to 64-bit pseudo-random number generation
and
- // bitwise operations:
- static uint64_t rand_64();
- static int count_64(uint64_t n);
- static int find_64(uint64_t n);
- static int find_32(uint32_t n);
-
- // Filesystem utilities
- static char* get_home_directory();
-
- static void (*callback)(void*);
- static void *callback_data;
-};
-
-#if defined(LINUX) || defined(OS_X)
- void timer_handler(int num);
-#endif
-#if defined(_MINGW_WINDOWS)
- unsigned long timer_handler(LPVOID arg);
-#endif
+// Function prototypes related to threads:
+int thread_create(thread_t *thread, entry_t entry, void *arg);
+int thread_wait(thread_t *thread);
+int thread_destroy(thread_t *thread);
+
+// Function prototypes related to mutexes:
+int mutex_create(mutex_t *mutex);
+int mutex_try_lock(mutex_t *mutex);
+int mutex_lock(mutex_t *mutex);
+int mutex_unlock(mutex_t *mutex);
+int mutex_destroy(mutex_t *mutex);
+
+// Function prototypes related to condition variables:
+int cond_create(cond_t *cond, void *attr);
+int cond_wait(cond_t *cond, mutex_t *mutex);
+int cond_signal(cond_t *cond);
+int cond_broadcast(cond_t *cond);
+int cond_destroy(cond_t *cond);
+
+// Function prototypes related to timers:
+int timer_function(void (*function)(void *), void *data);
+int timer_set(int csec);
+int timer_cancel();
+
+// Function prototypes related to 64-bit pseudo-random number generation
and
+// bitwise operations:
+uint64_t rand_64();
+int count_64(uint64_t n);
+int find_64(uint64_t n);
+int find_32(uint32_t n);
+
+// Filesystem utilities
+char* get_home_directory();

#endif
=======================================
--- /trunk/src/board_base.cpp Wed Jul 28 10:11:39 2010
+++ /trunk/src/board_base.cpp Wed Jul 28 22:54:14 2010
@@ -180,7 +180,7 @@
}
set_board();

- Library::mutex_create(&mutex);
+ mutex_create(&mutex);
}


/*----------------------------------------------------------------------------*\
@@ -191,7 +191,7 @@

/// Destructor.

- Library::mutex_destroy(&mutex);
+ mutex_destroy(&mutex);
}


/*----------------------------------------------------------------------------*\
@@ -384,7 +384,7 @@
// string. For now, just make sure that both colors have one king each
// and that the color off move isn't in check.
for (int color = WHITE; color <= BLACK; color++)
- if (Library::count_64(state.piece[color][KING]) != 1)
+ if (count_64(state.piece[color][KING]) != 1)
return set_board_fen_error(fen, "One color has no king.", x,
y);
if (check(state.piece[OFF_MOVE][KING], ON_MOVE))
return set_board_fen_error(fen, "Color off move is in check.", x,
y);
@@ -429,7 +429,7 @@

/// Wait for the board, then grab the board.

- Library::mutex_lock(&mutex);
+ mutex_lock(&mutex);
}


/*----------------------------------------------------------------------------*\
@@ -440,7 +440,7 @@

/// Release the board.

- Library::mutex_unlock(&mutex);
+ mutex_unlock(&mutex);
}


/*----------------------------------------------------------------------------*\
@@ -471,20 +471,23 @@
int board_base::get_status(bool mate_test)
{

- /// Determine the status of the game. This must be one of:
- /// - still in progress
- /// - stalemated
- /// - drawn due to insufficient material
- /// - drawn due to threefold repetition
- /// - drawn due to the fifty move rule
- /// - checkmated
- /// - illegal position
- ///
- /// For speed, try to test in order of likelyhood of happening.
-
- // can a king be taken? (do this before insufficient test)
- if (check(state.piece[OFF_MOVE][KING], ON_MOVE))
- return ILLEGAL;
+ /// Determine the status of the game. This must be one of:
+ ///· still in progress
+ ///· stalemated
+ ///· drawn due to insufficient material
+ ///· drawn due to threefold repetition
+ ///· drawn due to the fifty move rule
+ ///· checkmated
+ ///· illegal position
+
+ // Is a king missing?
+ if (!state.piece[WHITE][KING] || !state.piece[BLACK][KING])
+ return ILLEGAL;
+
+ // Are the kings attacking one other?
+ int n = FST(state.piece[WHITE][KING]);
+ if (squares_king[n & 0x7][n >> 3] & state.piece[BLACK][KING])
+ return ILLEGAL;

if (mate_test)
switch (mate())
@@ -492,17 +495,13 @@
case STALEMATE: return STALEMATE;
case CHECKMATE: return CHECKMATE;
}
+ //if (insufficient())
+ //return INSUFFICIENT;
if (three())
return THREE;
- if (insufficient())
- return INSUFFICIENT;
if (fifty())
return FIFTY;

- // Is a king missing?
- if (!state.piece[WHITE][KING] || !state.piece[BLACK][KING])
- return ILLEGAL;
-
return IN_PROGRESS;
}

@@ -544,7 +543,9 @@

\*----------------------------------------------------------------------------*/
bool board_base::check(bool off_move) const
{
- return check(state.piece[off_move][KING], !off_move);
+ bool defense = off_move ? OFF_MOVE : ON_MOVE;
+ bool offense = off_move ? ON_MOVE : OFF_MOVE;
+ return check(state.piece[defense][KING], offense);
}


/*----------------------------------------------------------------------------*\
@@ -1294,18 +1295,18 @@
for (int shape = PAWN; shape <= KING; shape++)
for (int y = 0; y <= 7; y++)
for (int x = 0; x <= 7; x++)
- key_piece[color][shape][x][y] = Library::rand_64();
+ key_piece[color][shape][x][y] = rand_64();

for (int side = QUEEN_SIDE; side <= KING_SIDE; side++)
for (int stat = CAN_CASTLE; stat <= HAS_CASTLED; stat++)
- key_castle[color][side][stat] = Library::rand_64();
+ key_castle[color][side][stat] = rand_64();
}

- key_no_en_passant = Library::rand_64();
+ key_no_en_passant = rand_64();
for (int x = 0; x < 8; ++x)
- key_en_passant[x] = Library::rand_64();
-
- key_on_move = Library::rand_64();
+ key_en_passant[x] = rand_64();
+
+ key_on_move = rand_64();
}


/*----------------------------------------------------------------------------*\
@@ -1844,10 +1845,10 @@

for (int color = WHITE; color <= BLACK; color++)
{
- n_count += Library::count_64(state.piece[color][KNIGHT]);
- b_count += Library::count_64(state.piece[color][BISHOP]);
- b_array[color][WHITE] =
Library::count_64(state.piece[color][BISHOP] & SQUARES_WHITE);
- b_array[color][BLACK] =
Library::count_64(state.piece[color][BISHOP] & SQUARES_BLACK);
+ n_count += count_64(state.piece[color][KNIGHT]);
+ b_count += count_64(state.piece[color][BISHOP]);
+ b_array[color][WHITE] = count_64(state.piece[color][BISHOP] &
SQUARES_WHITE);
+ b_array[color][BLACK] = count_64(state.piece[color][BISHOP] &
SQUARES_BLACK);
}
return (n_count + b_count <= 1) ||
((n_count == 0) && (b_count == 2) &&
=======================================
--- /trunk/src/board_heuristic.cpp Wed Jul 28 10:11:39 2010
+++ /trunk/src/board_heuristic.cpp Wed Jul 28 22:54:14 2010
@@ -267,7 +267,7 @@
//
bitboard_t pawns = state.piece[color][PAWN];
bitboard_t pawns_on_col = pawns & COL_MSK(y);
- int num_on_col = Library::count_64(pawns_on_col);
+ int num_on_col = count_64(pawns_on_col);

if (!(pawns & squares_adj_cols[x]))
{
@@ -384,7 +384,7 @@

// Reward bishops (over knights) during endgames with pawns on
both
// sides of the board.
- int friendly_piece_count = Library::count_64(ALL(state,
color));
+ int friendly_piece_count = count_64(ALL(state, color));
bool endgame = friendly_piece_count < 7;
if (!endgame)
goto no_bishop_over_knight;
@@ -472,7 +472,7 @@
sum += sign * value_rook_on_7th;
rooks = state.piece[color][ROOK];
rooks_on_7th = rooks & seventh_row;
- num_rooks_on_7th = Library::count_64(rooks_on_7th);
+ num_rooks_on_7th = count_64(rooks_on_7th);
if (num_rooks_on_7th < 2)
goto no_rook_on_7th;
sum += sign * value_rooks_on_7th;
@@ -534,7 +534,7 @@
no_queen_on_7th:

//
- if (Library::count_64(state.piece[color][PAWN]) > 4)
+ if (count_64(state.piece[color][PAWN]) > 4)
{
int enemy_king_n = FST(state.piece[!color][KING]);
int enemy_king_x = enemy_king_n & 0x7;
=======================================
--- /trunk/src/book.cpp Wed Jul 28 10:48:07 2010
+++ /trunk/src/book.cpp Wed Jul 28 22:54:14 2010
@@ -22,7 +22,6 @@
#include "gray.h"
#include "book.h"
#include "board_heuristic.h"
-#include <time.h>

using namespace std;

@@ -92,7 +91,7 @@
if (moves.empty())
continue;
//randomly put game on front or back
- srand((unsigned)time(NULL));
+ srand(time(NULL));
if (rand() % 1)
games.push_back(moves);
else
=======================================
--- /trunk/src/clock.cpp Wed Jul 28 10:11:39 2010
+++ /trunk/src/clock.cpp Wed Jul 28 22:54:14 2010
@@ -37,7 +37,7 @@
for (int color = WHITE; color <= BLACK; color++)
set_mode(color, 40, 5 * 60 * 100, 0);
overhead = o;
- Library::timer_function(sound_alarm, this);
+ timer_function(sound_alarm, this);
note_time();
}

@@ -107,7 +107,7 @@
#ifndef _MSDEV_WINDOWS
DEBUG_SEARCH_PRINT("Setting alarm to %d csecs from now.",
csecs_per_move);
#endif
- Library::timer_set(csecs_per_move);
+ timer_set(csecs_per_move);
}


/*----------------------------------------------------------------------------*\
@@ -130,7 +130,7 @@

/// Cancel the alarm.

- Library::timer_cancel();
+ timer_cancel();
}


/*----------------------------------------------------------------------------*\
=======================================
--- /trunk/src/configfile.cpp Wed Jul 28 10:11:39 2010
+++ /trunk/src/configfile.cpp Wed Jul 28 22:54:14 2010
@@ -54,7 +54,7 @@
ConfigFile::ConfigFile() {

ostringstream ostr;
- ostr << Library::get_home_directory() << "/.graymatter";
+ ostr << get_home_directory() << "/.graymatter";
ifstream file(ostr.str().c_str());

// Setting default values
=======================================
--- /trunk/src/library.cpp Wed Jul 28 11:04:14 2010
+++ /trunk/src/library.cpp Wed Jul 28 22:54:14 2010
@@ -22,21 +22,28 @@
#include "library.h"
#include <iostream>

-unsigned int Library::timePerMove = 0;
-
-void (*Library::callback)(void*) = NULL;
-void *Library::callback_data = NULL;
-
-const int Library::MultiplyDeBruijnBitPosition[32] =
+//fast bit index lookup assistance
+//static const int MultiplyDeBruijnBitPosition[32] =
+//{
+// 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
+// 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
+//};
+static const int MultiplyDeBruijnBitPosition[32] =
{
1,2,29,3,30,15,25,4,31,23,21,16,26,18,5,9,
32,28,14,24,22,20,17,8,27,13,19,7,12,6,11,10
};

+
+//Windows needs a variable to hold the time per move
+//since it seems to get lost/corrupted in the current
+//threading model
+unsigned int timePerMove = 0;
+

/*----------------------------------------------------------------------------*\
|
thread_create() |

\*----------------------------------------------------------------------------*/
-int Library::thread_create(thread_t *thread, entry_t entry, void *arg)
+int thread_create(thread_t *thread, entry_t entry, void *arg)
{

// Create a thread.
@@ -51,7 +58,7 @@

/*----------------------------------------------------------------------------*\
|
thread_wait() |

\*----------------------------------------------------------------------------*/
-int Library::thread_wait(thread_t *thread)
+int thread_wait(thread_t *thread)
{

// Wait for a thread to exit.
@@ -66,7 +73,7 @@

/*----------------------------------------------------------------------------*\
|
thread_destroy() |

\*----------------------------------------------------------------------------*/
-int Library::thread_destroy(thread_t *thread)
+int thread_destroy(thread_t *thread)
{

// Destroy a thread. If thread is NULL, destroy the calling thread.
Otherwise,
@@ -103,7 +110,7 @@

/*----------------------------------------------------------------------------*\
|
mutex_create() |

\*----------------------------------------------------------------------------*/
-int Library::mutex_create(mutex_t *mutex)
+int mutex_create(mutex_t *mutex)
{
#if defined(LINUX) || defined(OS_X)
return pthread_mutex_init(mutex, NULL) ? CRITICAL : SUCCESSFUL;
@@ -116,7 +123,7 @@

/*----------------------------------------------------------------------------*\
|
mutex_try_lock() |

\*----------------------------------------------------------------------------*/
-int Library::mutex_try_lock(mutex_t *mutex)
+int mutex_try_lock(mutex_t *mutex)
{
#if defined(LINUX) || defined(OS_X)
switch (pthread_mutex_trylock(mutex))
@@ -133,7 +140,7 @@

/*----------------------------------------------------------------------------*\
|
mutex_lock() |

\*----------------------------------------------------------------------------*/
-int Library::mutex_lock(mutex_t *mutex)
+int mutex_lock(mutex_t *mutex)
{
#if defined(LINUX) || defined(OS_X)
return pthread_mutex_lock(mutex) ? CRITICAL : SUCCESSFUL;
@@ -145,7 +152,7 @@

/*----------------------------------------------------------------------------*\
|
mutex_unlock() |

\*----------------------------------------------------------------------------*/
-int Library::mutex_unlock(mutex_t *mutex)
+int mutex_unlock(mutex_t *mutex)
{
#if defined(LINUX) || defined(OS_X)
return pthread_mutex_unlock(mutex) ? CRITICAL : SUCCESSFUL;
@@ -157,7 +164,7 @@

/*----------------------------------------------------------------------------*\
|
mutex_destroy() |

\*----------------------------------------------------------------------------*/
-int Library::mutex_destroy(mutex_t *mutex)
+int mutex_destroy(mutex_t *mutex)
{
#if defined(LINUX) || defined(OS_X)
return pthread_mutex_destroy(mutex) ? CRITICAL : SUCCESSFUL;
@@ -169,7 +176,7 @@

/*----------------------------------------------------------------------------*\
|
cond_create() |

\*----------------------------------------------------------------------------*/
-int Library::cond_create(cond_t *cond, void *attr)
+int cond_create(cond_t *cond, void *attr)
{
#if defined(LINUX) || defined(OS_X)
return pthread_cond_init(cond, (pthread_condattr_t *) attr) ?
CRITICAL : SUCCESSFUL;
@@ -188,7 +195,7 @@

/*----------------------------------------------------------------------------*\
|
cond_wait() |

\*----------------------------------------------------------------------------*/
-int Library::cond_wait(cond_t *cond, mutex_t *mutex)
+int cond_wait(cond_t *cond, mutex_t *mutex)
{
#if defined(LINUX) || defined(OS_X)
return pthread_cond_wait(cond, mutex) ? CRITICAL : SUCCESSFUL;
@@ -215,7 +222,7 @@

/*----------------------------------------------------------------------------*\
|
cond_signal() |

\*----------------------------------------------------------------------------*/
-int Library::cond_signal(cond_t *cond)
+int cond_signal(cond_t *cond)
{
#if defined(LINUX) || defined(OS_X)
return pthread_cond_signal(cond) ? CRITICAL : SUCCESSFUL;
@@ -233,7 +240,7 @@

/*----------------------------------------------------------------------------*\
|
cond_broadcast() |

\*----------------------------------------------------------------------------*/
-int Library::cond_broadcast(cond_t *cond)
+int cond_broadcast(cond_t *cond)
{
#if defined(LINUX) || defined(OS_X)
return pthread_cond_broadcast(cond) ? CRITICAL : SUCCESSFUL;
@@ -263,7 +270,7 @@

/*----------------------------------------------------------------------------*\
|
cond_destroy() |

\*----------------------------------------------------------------------------*/
-int Library::cond_destroy(cond_t *cond)
+int cond_destroy(cond_t *cond)
{
#if defined(LINUX) || defined(OS_X)
return pthread_cond_destroy(cond) ? CRITICAL : SUCCESSFUL;
@@ -277,7 +284,9 @@
#endif
}

-
+// Global variables:
+void (*callback)(void*);
+void *callback_data;
#if defined(_MINGW_WINDOWS)
thread_t timer_thread = INVALID_HANDLE_VALUE;
#endif
@@ -292,7 +301,7 @@
// On Linux and OS X, the alarm has sounded. Call the previously specified
// function.

- (*Library::callback)(Library::callback_data);
+ (*callback)(callback_data);
}
#elif defined(_MINGW_WINDOWS)
DWORD timer_handler(LPVOID arg)
@@ -319,7 +328,7 @@
// notifying the
other
// thread.

- double dTimeInterval = (double)Library::timePerMove;
+ double dTimeInterval = (double)timePerMove;

HANDLE timer_id = INVALID_HANDLE_VALUE;

@@ -342,13 +351,13 @@
goto end;

// Notify the other thread - call the previously specified function.
- (*Library::callback)(Library::callback_data);
+ (*callback)(callback_data);

// Exit the timer thread.
end:
if (timer_id != INVALID_HANDLE_VALUE)
CloseHandle(timer_id);
- Library::thread_destroy(&timer_thread);
+ thread_destroy(&timer_thread);
return 0;
}
#endif
@@ -356,7 +365,7 @@

/*----------------------------------------------------------------------------*\
|
timer_function() |

\*----------------------------------------------------------------------------*/
-int Library::timer_function(void (*function)(void *), void *data)
+int timer_function(void (*function)(void *), void *data)
{

// Specify the function to be called once the alarm has sounded.
@@ -372,7 +381,7 @@

/*----------------------------------------------------------------------------*\
|
timer_set() |

\*----------------------------------------------------------------------------*/
-int Library::timer_set(int csec)
+int timer_set(int csec)
{

// Set the alarm to sound after the specified number of seconds.
@@ -397,7 +406,7 @@

/*----------------------------------------------------------------------------*\
|
timer_cancel() |

\*----------------------------------------------------------------------------*/
-int Library::timer_cancel()
+int timer_cancel()
{

// Cancel any pending alarm.
@@ -421,7 +430,7 @@

/*----------------------------------------------------------------------------*\
|
rand_64() |

\*----------------------------------------------------------------------------*/
-uint64_t Library::rand_64()
+uint64_t rand_64()
{

// Generate a 64-bit pseudo-random number.
@@ -439,7 +448,7 @@
|
count_64() |
| Count the number of set bits in a 64-bit integer.

\*----------------------------------------------------------------------------*/
-int Library::count_64(uint64_t n)
+int count_64(uint64_t n)
{
n = n - ((n >> 1) & (uint64_t)~(uint64_t)0/3);
n = (n & (uint64_t)~(uint64_t)0/15*3) +
@@ -447,11 +456,15 @@
n = (n + (n >> 4)) & (uint64_t)~(uint64_t)0/255*15;
return (uint64_t)(n * ((uint64_t)~(uint64_t)0/255)) >> (sizeof(n) - 1)
* 8;
}
+
+// These next two functions, we shamelessly yoinked from the GNU C Library,
+// version 2.5, copyright © 1991-1998, the Free Software Foundation,
originally
+// written by Torbjorn Granlund <te...@sics.se>.


/*----------------------------------------------------------------------------*\
|
find_64() |

\*----------------------------------------------------------------------------*/
-int Library::find_64(uint64_t n)
+int find_64(uint64_t n)
{
// Find the first (least significant) set bit in a 64-bit integer. The
return
// value ranges from 0 (for no bit set), to 1 (for the least significant
bit
@@ -469,7 +482,7 @@

/*----------------------------------------------------------------------------*\
|
find_32() |

\*----------------------------------------------------------------------------*/
-int Library::find_32(uint32_t n)
+int find_32(uint32_t n)
{
// Find the first (least significant) set bit in a 32-bit integer. The
return
// value ranges from 0 (for no bit set), to 1 (for the least significant
bit
@@ -484,7 +497,7 @@
|
get_home_directory() |

\*----------------------------------------------------------------------------*/
/** Return the current user's home directory. */
-char* Library::get_home_directory()
+char* get_home_directory()
{
#if defined(LINUX)
return getenv("HOME");
=======================================
--- /trunk/src/search_base.cpp Wed Jul 28 10:11:39 2010
+++ /trunk/src/search_base.cpp Wed Jul 28 22:54:14 2010
@@ -53,11 +53,11 @@
clock_ptr = c;
xboard_ptr = x;

- Library::mutex_create(&timeout_mutex);
+ mutex_create(&timeout_mutex);
clock_ptr->set_callback((clock_callback_t) _handle, this);
- Library::mutex_create(&search_mutex);
- Library::cond_create(&search_cond, NULL);
- Library::thread_create(&search_thread, (entry_t) _start, this);
+ mutex_create(&search_mutex);
+ cond_create(&search_cond, NULL);
+ thread_create(&search_thread, (entry_t) _start, this);
}


/*----------------------------------------------------------------------------*\
@@ -68,9 +68,9 @@

/// Destructor.

- Library::cond_destroy(&search_cond);
- Library::mutex_destroy(&search_mutex);
- Library::mutex_destroy(&timeout_mutex);
+ cond_destroy(&search_cond);
+ mutex_destroy(&search_mutex);
+ mutex_destroy(&timeout_mutex);
}


/*----------------------------------------------------------------------------*\
@@ -147,9 +147,9 @@
{
if (search_status != THINKING)
return;
- Library::mutex_lock(&timeout_mutex);
+ mutex_lock(&timeout_mutex);
timeout_flag = true;
- Library::mutex_unlock(&timeout_mutex);
+ mutex_unlock(&timeout_mutex);
}


/*----------------------------------------------------------------------------*\
@@ -196,9 +196,9 @@
/// 12 start thinking

// Force pondering timeout.
- Library::mutex_lock(&timeout_mutex);
+ mutex_lock(&timeout_mutex);
timeout_flag = true;
- Library::mutex_unlock(&timeout_mutex);
+ mutex_unlock(&timeout_mutex);

// Wait for the board, grab the board, set the board position, and
release
// the board.
@@ -209,15 +209,15 @@
board_ptr->unlock();

// Send the command to think.
- Library::mutex_lock(&search_mutex);
+ mutex_lock(&search_mutex);
#ifndef _MSDEV_WINDOWS
DEBUG_SEARCH_PRINTA("search_base::change changes state from %s to %s.",
status_to_string(search_status).c_str(),
status_to_string(s).c_str());
#endif
search_status = s;
token_update++;
- Library::cond_signal(&search_cond);
- Library::mutex_unlock(&search_mutex);
+ cond_signal(&search_cond);
+ mutex_unlock(&search_mutex);
}


/*----------------------------------------------------------------------------*\
@@ -236,12 +236,12 @@

/// The alarm has sounded. Handle it.

- Library::mutex_lock(&timeout_mutex);
+ mutex_lock(&timeout_mutex);
#ifndef _MSDEV_WINDOWS
DEBUG_SEARCH_PRINT("Setting timeout flag");
#endif
timeout_flag = true;
- Library::mutex_unlock(&timeout_mutex);
+ mutex_unlock(&timeout_mutex);
}


/*----------------------------------------------------------------------------*\
@@ -268,11 +268,11 @@
do
{
// Wait for either the status or the board to change.
- Library::mutex_lock(&search_mutex);
+ mutex_lock(&search_mutex);
while (!token_update)
- Library::cond_wait(&search_cond, &search_mutex);
+ cond_wait(&search_cond, &search_mutex);
token_update = 0;
- Library::mutex_unlock(&search_mutex);
+ mutex_unlock(&search_mutex);

// Do the requested work - idle, analyze, think, ponder, or quit.
#ifndef _MSDEV_WINDOWS
@@ -285,14 +285,14 @@
search_status == THINKING ||
search_status == PONDERING)
{
- Library::mutex_lock(&timeout_mutex);
+ mutex_lock(&timeout_mutex);
timeout_flag = false;
- Library::mutex_unlock(&timeout_mutex);
+ mutex_unlock(&timeout_mutex);
iterate(search_status);
}
} while (search_status != QUITTING);

- Library::thread_destroy(NULL);
+ thread_destroy(NULL);
}


/*----------------------------------------------------------------------------*\
=======================================
--- /trunk/src/search_mtdf.cpp Tue Jul 27 16:56:47 2010
+++ /trunk/src/search_mtdf.cpp Wed Jul 28 22:54:14 2010
@@ -463,8 +463,8 @@
//if we didn't hit the timeout flag, then this position is
//a terminal one, store it with max depth so we always return
//it on a hash table probe (we'll never want to explore deeper).
- if (!timeout_flag)
- table_ptr->store(hash, max_depth-depth, EXACT, m);
+ //if (!timeout_flag)
+ //table_ptr->store(hash, max_depth-depth, EXACT, m);
#ifndef _MSDEV_WINDOWS
DEBUG_SEARCH_PRINT("%s.", m.value == VALUE_ILLEGAL ? "Illegal
position" : m.value == VALUE_CONTEMPT ? "Stalemated" : "Checkmated");
#endif
@@ -482,12 +482,12 @@
// interest of robustness.
if ((max_depth-depth) > 3)
table_ptr->store(hash, max_depth-depth-1, EXACT, m);
- else if (m.value <= saved_alpha)
- table_ptr->store(hash, max_depth-depth, UPPER, m);
- }
- else // m.value >= saved_beta
- {
- table_ptr->store(hash, max_depth-depth, LOWER, m);
+ //else if (m.value <= saved_alpha)
+ //table_ptr->store(hash, max_depth-depth, UPPER, m);
+ //}
+ //else // m.value >= saved_beta
+ //{
+ //table_ptr->store(hash, max_depth-depth, LOWER, m);
}
history_ptr->store(whose, m); //this seems like a good move
}
=======================================
--- /trunk/src/xboard.cpp Wed Jul 28 10:11:39 2010
+++ /trunk/src/xboard.cpp Wed Jul 28 22:54:14 2010
@@ -350,7 +350,7 @@
{
thread_t thread = search_ptr->get_thread();
search_ptr->change(QUITTING, *board_ptr);
- Library::thread_wait(&thread);
+ thread_wait(&thread);
}


/*----------------------------------------------------------------------------*\
Reply all
Reply to author
Forward
0 new messages