diff --git a/Chess-Challenge/src/My Bot/MyBot.cs b/Chess-Challenge/src/My Bot/MyBot.cs index c5b8a26..e8c7cdf 100644 --- a/Chess-Challenge/src/My Bot/MyBot.cs +++ b/Chess-Challenge/src/My Bot/MyBot.cs @@ -82,23 +82,23 @@ private readonly /// There are 86 tokens in total: 64 decimal literals and 22 tokens to declare and unpack the table. /// private readonly byte[] pieceSquareTables = new[] { - 282266529097455053078799364m, 2455919912745106374728623108m, 3386797516431034209084386052m, 4935431509659988786767212548m, - 4623519203538509630205605124m, 4928159028382896809030460420m, 4919701269940020779892941828m, 283465991737381893962998788m, - 4306785287174623693249196061m, 6172167345646778025007526687m, 6798390920280049164742310684m, 6184251881691207953985125151m, - 6806843937762779303503609117m, 7416133087452950235235501593m, 7413715272853297914227537166m, 6166089567246312935719123209m, - 5545934344726408926104007435m, 6788710069059982090422926095m, 7724423412988483705405259284m, 8033903663476395000086151445m, - 8038729921805153149300918294m, 7724404504784780671022745626m, 8026631218733624710112886805m, 6480410354417102158320187660m, - 4929386880782585395265746184m, 6794759494522601928612591117m, 7723214487308196977710217997m, 8348224450575394892306071055m, - 8350632839034632866990471954m, 8348214968876604148506771472m, 7729240245243244616223569680m, 6175765788827324583463500555m, - 3999713462245760773649871366m, 5862672928194510734078194699m, 7103035597184991926547068683m, 8037530514933872240074110478m, - 8035103200114651698059753486m, 7416133180328127843165550349m, 6792317975636973077153855502m, 5243679204196604490360173320m, - 3378316145942088905196711430m, 4926950158122208307057537547m, 6172143789362025367686886410m, 6789909605768598753627616522m, - 6791113809221167563237242637m, 6480415132478751653932774667m, 5237620444964642779316368914m, 4616232555091577144835059467m, - 2758132459595079043790875397m, 3996072480721656458214321419m, 4922114399431180703583973385m, 5544711233498253872944722696m, - 5544701807140537563279405835m, 5227958464622172391882896399m, 3678110841365349248083570963m, 2749660460480540245411704842m, - 900008696921407705696314372m, 1517779290601516084563160580m, 2754515034776499494753610244m, 3681761249173421225934138628m, - 2135535662706613888346369540m, 3680542823136497829114425348m, 1821210171323644351172128516m, 276184047857016610036851716m, - }.SelectMany(decimal.GetBits).SelectMany(BitConverter.GetBytes).ToArray(); + 9628032156016814535290913796m, 3739330748943827784153569565m, 4346140379023522695215910152m, 3426147959350246416118058254m, + 1242794706542687070007659269m, 11185152669416276013139362820m, 20191758603732251806925534000m, 18326409823835205121727285320m, + 16465806633716380841595581490m, 14914764344115234867403699511m, 16156331252012037324214513188m, 18333663433733127431584560180m, + 20503661576453411624395554618m, 18020532775865811861281456449m, 17713460821314345596499016762m, 17090840319640865196304383034m, + 25161719169152913031866240334m, 25482117696392597169675261007m, 20502466910617455769214600001m, 20510943612998979672577753155m, + 20815588178586217362537659963m, 38537558833788493959778353732m, 39144382761321243443688076921m, 38214728249832672635115767679m, + 36973147192274645216514176886m, 38214728249905012794900314487m, 3744128588073985660939564149m, 2815692551881497707894479375m, + 8490926343178518757185281m, 288097816478208m, 3424981792940117276810940172m, 9010181171504603017860615691m, + 14923231673815173664332582928m, 13049301801847373640435642158m, 6835389865644938206073462304m, 6836584550432607576111191573m, + 4971178824858753753719249435m, 16168472605764084778784526352m, 21750102004030189768527724861m, 19893215724038636353437647683m, + 22055955459119738728114373697m, 19263327445006937425675633479m, 21747693652605739275697141305m, 20201472844570441812592051270m, + 22989284137175361503766267463m, 20821675475941777185291454537m, 21746475301080316520665007941m, 19576448732575938594042299463m, + 39149246871792652793025559932m, 37285059609438012619756370813m, 38838543472899645308311338622m, 36351764135737047554125822843m, + 38215932434766440880599103865m, 72697455234101068101695601017m, 76121147229683932814602924522m, 75816545442890526588652221945m, + 74568867569745798387815674348m, 70217910487879854167801262321m, 4654397478574698875870177256m, 5908129483642450534317625102m, + 8075723922871239506480600337m, 4977256676758788300349119002m, 5279435871242164628299648778m, 6096686604738895230472209m, + }.SelectMany(d => decimal.GetBits(d).Take(3)).SelectMany(BitConverter.GetBytes).ToArray(); [NoTokenCount] private string GetPV(Board board, Move move, int limit) @@ -185,12 +185,12 @@ int AlphaBeta(int depth, int alpha, int beta, bool nullMoveAllowed = true, bool ulong bitboard = board.GetPieceBitboard((PieceType)piece + 1, xor is 56); while (bitboard != 0) { - int index = piece + // piece index - 16 * (BitboardHelper.ClearAndGetIndexOfLSB(ref bitboard) // row of square - ^ xor); // flip board for white pieces + int index = piece * 64 // table start index + + BitboardHelper.ClearAndGetIndexOfLSB(ref bitboard) // square index in the table + ^ xor; // flip board for white pieces mgScore += pieceSquareTables[index]; - egScore += pieceSquareTables[index + 6]; + egScore += pieceSquareTables[index + 384]; phase += 0b_0100_0010_0001_0001_0000 >> 4 * piece & 0xF; } } diff --git a/Chess-Challenge/src/My Bot/PSQT.cs b/Chess-Challenge/src/My Bot/PSQT.cs index 7a68da9..343a51c 100644 --- a/Chess-Challenge/src/My Bot/PSQT.cs +++ b/Chess-Challenge/src/My Bot/PSQT.cs @@ -14,8 +14,8 @@ public static void Print() //NormalizePSQT(); var bytes = pieceSquareTables.Select(x => checked((byte)x)).ToArray(); - var transposed = TransposeTable(bytes); - var compressed = CompressAsDecimalArray(transposed); + //var transposed = TransposeTable(bytes); + var compressed = CompressAsDecimalArray(bytes); for (var i = 0; i < compressed.Length; i++) {