/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
- Copyright (C) 2008-2012 Marco Costalba, Joona Kiiski, Tord Romstad
+ Copyright (C) 2008-2013 Marco Costalba, Joona Kiiski, Tord Romstad
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
# include <xmmintrin.h> // Intel and Microsoft header for _mm_prefetch()
# endif
+#define CACHE_LINE_SIZE 64
#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
-# define CACHE_LINE_ALIGNMENT __declspec(align(64))
+# define CACHE_LINE_ALIGNMENT __declspec(align(CACHE_LINE_SIZE))
#else
-# define CACHE_LINE_ALIGNMENT __attribute__ ((aligned(64)))
+# define CACHE_LINE_ALIGNMENT __attribute__ ((aligned(CACHE_LINE_SIZE)))
#endif
#if defined(_MSC_VER)
DEPTH_ZERO = 0 * ONE_PLY,
DEPTH_QS_CHECKS = -1 * ONE_PLY,
DEPTH_QS_NO_CHECKS = -2 * ONE_PLY,
- DEPTH_QS_RECAPTURES = -5 * ONE_PLY,
+ DEPTH_QS_RECAPTURES = -7 * ONE_PLY,
DEPTH_NONE = -127 * ONE_PLY
};
/// Extracting the signed lower and upper 16 bits it not so trivial because
/// according to the standard a simple cast to short is implementation defined
/// and so is a right shift of a signed integer.
-inline Value mg_value(Score s) { return Value(((s + 32768) & ~0xffff) / 0x10000); }
+inline Value mg_value(Score s) { return Value(((s + 0x8000) & ~0xffff) / 0x10000); }
/// On Intel 64 bit we have a small speed regression with the standard conforming
/// version, so use a faster code in this case that, although not 100% standard
return make_score(mg_value(s) / i, eg_value(s) / i);
}
-/// Weight score v by score w trying to prevent overflow
-inline Score apply_weight(Score v, Score w) {
- return make_score((int(mg_value(v)) * mg_value(w)) / 0x100,
- (int(eg_value(v)) * eg_value(w)) / 0x100);
-}
-
#undef ENABLE_OPERATORS_ON
#undef ENABLE_SAFE_OPERATORS_ON
return SquareDistance[s1][s2];
}
-inline char file_to_char(File f) {
- return char(f - FILE_A + 'a');
+inline char file_to_char(File f, bool tolower = true) {
+ return char(f - FILE_A + (tolower ? 'a' : 'A'));
}
inline char rank_to_char(Rank r) {
return ch;
}
-/// Our insertion sort implementation, works with pointers and iterators and is
-/// guaranteed to be stable, as is needed.
-template<typename T, typename K>
-void sort(K begin, K end)
-{
- T tmp;
- K p, q;
-
- for (p = begin + 1; p < end; p++)
- {
- tmp = *p;
- for (q = p; q != begin && *(q-1) < tmp; --q)
- *q = *(q-1);
- *q = tmp;
- }
-}
-
#endif // !defined(TYPES_H_INCLUDED)