Skip to content

Commit

Permalink
Merge pull request #4 from Tearth/v4.0-dev
Browse files Browse the repository at this point in the history
v4.0 (Komekko), 22.01.2021
  • Loading branch information
Tearth authored Jan 22, 2021
2 parents 3fae7f2 + 0e456e9 commit 844ecd7
Show file tree
Hide file tree
Showing 119 changed files with 2,267 additions and 871 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,9 @@ MigrationBackup/
/cloc.bat
/Cosette.Arbiter/settings.json
/Cosette.Arbiter/book.bin
/Cosette.Tuner/settings.json
/Cosette.Tuner/book.bin
/Cosette.Tuner.SelfPlay/settings.json
/Cosette.Tuner.SelfPlay/book.bin
/Cosette.Tuner.Texel/settings.json
/Cosette.Tuner.Texel/positions.epd
/Cosette.Tuner.Web/Database.sqlite
/Cosette.Tuner.Web/wwwroot/lib/
25 changes: 17 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Version 4.0 (Komekko), 22.01.2021
- Added Texel project
- Added check extension
- Added check detection in quiescence search
- Added evasion moves generator
- Added static null-move pruning
- Added futility pruning
- Added new formulas calculating reduction for LMR and null move pruning
- Added a new way of building Piece-Square tables, better for tuning
- Fixed reduntant saving of transposition table entries
- Adjusted search parameters
- Adjusted evaluation parameters
- Improved threefold repetition detection
- Updated .NET runtime version to 5.0.102

# Version 3.0 (Luna), 12.12.2020
- Added better time control for Arbiter
- Added more UCI options
Expand Down Expand Up @@ -26,9 +41,7 @@
- Disabled returning of exact transposition table entries in the PV nodes
- Adjusted evaluation scores
- Optimized king safety evaluation
- Updated .NET Core runtime version to 5.0.100

Estimated strength: 2000 ELO
- Updated .NET runtime version to 5.0.100

# Version 2.0 (Darkness), 19.10.2020
- Added fifty-move rule detection
Expand All @@ -52,9 +65,5 @@ Estimated strength: 2000 ELO
- Adjusted move ordering scores
- Updated .NET Core runtime version to 3.1.403

Estimated strength: 1950 ELO

# Version 1.0 (Aqua), 19.09.2020
- Initial version

Estimated strength: 1900 ELO
- Initial version
2 changes: 2 additions & 0 deletions Cosette.Arbiter/Engine/EngineOperator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public BestMoveData Go(List<string> moves, int whiteClock, int blackClock)
if (moves.Count > 0)
{
Write($"position startpos moves {movesJoined}");
Write("isready");
WaitForMessage("readyok");
}

Write($"go wtime {whiteClock} btime {blackClock} winc {SettingsLoader.Data.IncTime} binc {SettingsLoader.Data.IncTime}");
Expand Down
2 changes: 1 addition & 1 deletion Cosette.Arbiter/Tournament/TournamentArbiter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private void WriteResults()
Console.WriteLine($"{participant.EngineData.Name} {originalRating} ELO ({performance:+0;-#}, {wonGamesPercent}%): " +
$"{participant.Wins} wins ({winsByTime} by time), {participant.Losses} losses ({lossesByTime} by time), " +
$"{participant.Draws} draws");
Console.WriteLine($" === {participant.AverageDepth:F1} average depth, {participant.AverageNodesCount} average nodes, " +
Console.WriteLine($" === {participant.AverageDepth:F} average depth, {participant.AverageNodesCount} average nodes, " +
$"{participant.AverageNps} average nodes per second");
Console.WriteLine($"Executable hash: {participant.EngineOperator.ExecutableHash.Value}");
Console.WriteLine();
Expand Down
6 changes: 4 additions & 2 deletions Cosette.Tests/AdvancedPerftTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Cosette.Engine.Board;
using Cosette.Engine.Ai.Score.PieceSquareTables;
using Cosette.Engine.Board;
using Cosette.Engine.Moves.Magic;
using Cosette.Engine.Perft;
using Xunit;
Expand All @@ -10,6 +11,7 @@ public class AdvancedPerftTests
public AdvancedPerftTests()
{
MagicBitboards.InitWithInternalKeys();
PieceSquareTablesData.BuildPieceSquareTables();
}

[Theory]
Expand All @@ -24,7 +26,7 @@ public AdvancedPerftTests()
public void AdvancedPerft_DefaultBoard(int depth, ulong expectedLeafsCount, ulong expectedCapturesCount, ulong expectedEnPassantsCount,
ulong expectedCastlesCount, ulong expectedChecksCount, ulong expectedCheckmatesCount)
{
var boardState = new BoardState();
var boardState = new BoardState(true);
boardState.SetDefaultState();

var result = AdvancedPerft.Run(boardState, depth);
Expand Down
6 changes: 4 additions & 2 deletions Cosette.Tests/DividedPerftTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Cosette.Engine.Board;
using Cosette.Engine.Ai.Score.PieceSquareTables;
using Cosette.Engine.Board;
using Cosette.Engine.Moves.Magic;
using Cosette.Engine.Perft;
using Xunit;
Expand All @@ -10,12 +11,13 @@ public class DividedPerftTests
public DividedPerftTests()
{
MagicBitboards.InitWithInternalKeys();
PieceSquareTablesData.BuildPieceSquareTables();
}

[Fact]
public void DividedPerft_DefaultBoard()
{
var boardState = new BoardState();
var boardState = new BoardState(true);
boardState.SetDefaultState();

var result = DividedPerft.Run(boardState, 6);
Expand Down
10 changes: 8 additions & 2 deletions Cosette.Tests/FenTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Cosette.Engine.Board;
using Cosette.Engine.Ai.Score.PieceSquareTables;
using Cosette.Engine.Board;
using Cosette.Engine.Fen;
using Cosette.Engine.Moves.Magic;
using Cosette.Engine.Perft;
Expand All @@ -8,6 +9,11 @@ namespace Cosette.Tests
{
public class FenTests
{
public FenTests()
{
PieceSquareTablesData.BuildPieceSquareTables();
}

[Theory]
[InlineData("5r2/2P4p/P5Pp/1b6/P1r1N2N/1pp4K/P7/5k2 w - - 0 10")]
[InlineData("3K2N1/k7/p1p3qB/3p1R1Q/6P1/1pP4r/P6r/8 w KQ - 20 25")]
Expand All @@ -16,7 +22,7 @@ public class FenTests
[InlineData("r5R1/8/2Bp3p/2kq4/2N1p3/2KPP3/2pRP1P1/8 w - h3 0 1")]
public void DividedPerft_DefaultBoard(string fen)
{
var boardFromFen = FenToBoard.Parse(fen);
var boardFromFen = FenToBoard.Parse(fen, true);
Assert.Equal(fen, boardFromFen.ToString());
}
}
Expand Down
8 changes: 5 additions & 3 deletions Cosette.Tests/SimplePerftTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Cosette.Engine.Ai.Score.PieceSquareTables;
using Cosette.Engine.Board;
using Cosette.Engine.Fen;
using Cosette.Engine.Moves.Magic;
Expand All @@ -11,6 +12,7 @@ public class SimplePerftTests
public SimplePerftTests()
{
MagicBitboards.InitWithInternalKeys();
PieceSquareTablesData.BuildPieceSquareTables();
}

[Theory]
Expand All @@ -24,7 +26,7 @@ public SimplePerftTests()
[InlineData(7, 3195901860)]
public void SimplePerft_DefaultBoard(int depth, ulong expectedLeafsCount)
{
var boardState = new BoardState();
var boardState = new BoardState(true);
boardState.SetDefaultState();

var result = SimplePerft.Run(boardState, depth);
Expand All @@ -40,7 +42,7 @@ public void SimplePerft_DefaultBoard(int depth, ulong expectedLeafsCount)
[InlineData(5, 120955130)]
public void SimplePerft_MidGameBoard(int depth, ulong expectedLeafsCount)
{
var boardState = FenToBoard.Parse("r2qr1k1/p2n1p2/1pb3pp/2ppN1P1/1R1PpP2/BQP1n1PB/P4N1P/1R4K1 w - - 0 21");
var boardState = FenToBoard.Parse("r2qr1k1/p2n1p2/1pb3pp/2ppN1P1/1R1PpP2/BQP1n1PB/P4N1P/1R4K1 w - - 0 21", true);

var result = SimplePerft.Run(boardState, depth);
Assert.Equal(expectedLeafsCount, result.LeafsCount);
Expand All @@ -56,7 +58,7 @@ public void SimplePerft_MidGameBoard(int depth, ulong expectedLeafsCount)
[InlineData(6, 108146453)]
public void SimplePerft_EndGameBoard(int depth, ulong expectedLeafsCount)
{
var boardState = FenToBoard.Parse("7r/8/2k3P1/1p1p2Kp/1P6/2P5/7r/Q7 w - - 0 1");
var boardState = FenToBoard.Parse("7r/8/2k3P1/1p1p2Kp/1P6/2P5/7r/Q7 w - - 0 1", true);

var result = SimplePerft.Run(boardState, depth);
Assert.Equal(expectedLeafsCount, result.LeafsCount);
Expand Down
2 changes: 2 additions & 0 deletions Cosette.Tests/StaticExchangeEvaluationTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Cosette.Engine.Ai.Ordering;
using Cosette.Engine.Ai.Score.PieceSquareTables;
using Cosette.Engine.Common;
using Xunit;

Expand All @@ -9,6 +10,7 @@ public class StaticExchangeEvaluationTests
public StaticExchangeEvaluationTests()
{
StaticExchangeEvaluation.Init();
PieceSquareTablesData.BuildPieceSquareTables();
}

[Theory]
Expand Down
10 changes: 6 additions & 4 deletions Cosette.Tests/VerificationPerftTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Cosette.Engine.Board;
using Cosette.Engine.Ai.Score.PieceSquareTables;
using Cosette.Engine.Board;
using Cosette.Engine.Fen;
using Cosette.Engine.Moves.Magic;
using Cosette.Engine.Perft;
Expand All @@ -11,12 +12,13 @@ public class VerificationPerftTests
public VerificationPerftTests()
{
MagicBitboards.InitWithInternalKeys();
PieceSquareTablesData.BuildPieceSquareTables();
}

[Fact]
public void VerificationPerft_DefaultBoard()
{
var boardState = new BoardState();
var boardState = new BoardState(true);
boardState.SetDefaultState();

var result = VerificationPerft.Run(boardState, 6);
Expand All @@ -26,7 +28,7 @@ public void VerificationPerft_DefaultBoard()
[Fact]
public void VerificationPerft_MidGameBoard()
{
var boardState = FenToBoard.Parse("r2qr1k1/p2n1p2/1pb3pp/2ppN1P1/1R1PpP2/BQP1n1PB/P4N1P/1R4K1 w - - 0 21");
var boardState = FenToBoard.Parse("r2qr1k1/p2n1p2/1pb3pp/2ppN1P1/1R1PpP2/BQP1n1PB/P4N1P/1R4K1 w - - 0 21", true);

var result = VerificationPerft.Run(boardState, 5);
Assert.True(result.VerificationSuccess);
Expand All @@ -35,7 +37,7 @@ public void VerificationPerft_MidGameBoard()
[Fact]
public void VerificationPerft_EndGameBoard()
{
var boardState = FenToBoard.Parse("7r/8/2k3P1/1p1p2Kp/1P6/2P5/7r/Q7 w - - 0 1");
var boardState = FenToBoard.Parse("7r/8/2k3P1/1p1p2Kp/1P6/2P5/7r/Q7 w - - 0 1", true);

var result = VerificationPerft.Run(boardState, 6);
Assert.True(result.VerificationSuccess);
Expand Down
4 changes: 4 additions & 0 deletions Cosette.Tuner.Common/Cosette.Tuner.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>

</Project>
9 changes: 3 additions & 6 deletions Cosette.Tuner.Common/Requests/ChromosomeDataRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ public class ChromosomeDataRequest
{
public int TestId { get; set; }
public double ElapsedTime { get; set; }
public int Fitness { get; set; }
public int ReferenceEngineWins { get; set; }
public int ExperimentalEngineWins { get; set; }
public int Draws { get; set; }
public double Fitness { get; set; }

public EngineStatisticsDataRequest ReferenceEngineStatistics { get; set; }
public EngineStatisticsDataRequest ExperimentalEngineStatistics { get; set; }
public SelfPlayStatisticsDataRequest ReferenceEngineStatistics { get; set; }
public SelfPlayStatisticsDataRequest ExperimentalEngineStatistics { get; set; }
public List<GeneDataRequest> Genes { get; set; }
}
}
2 changes: 1 addition & 1 deletion Cosette.Tuner.Common/Requests/GenerationDataRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class GenerationDataRequest
{
public int TestId { get; set; }
public double ElapsedTime { get; set; }
public int BestFitness { get; set; }
public double BestFitness { get; set; }

public List<GeneDataRequest> BestChromosomeGenes { get; set; }
}
Expand Down
7 changes: 7 additions & 0 deletions Cosette.Tuner.Common/Requests/RegisterTestRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Cosette.Tuner.Common.Requests
{
public class RegisterTestRequest
{
public TestType Type { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
namespace Cosette.Tuner.Common.Requests
{
public class EngineStatisticsDataRequest
public class SelfPlayStatisticsDataRequest
{
public double AverageTimePerGame { get; set; }
public double AverageDepth { get; set; }
public double AverageNodesCount { get; set; }
public double AverageNodesPerSecond { get; set; }
public int Wins { get; set; }
public int Draws { get; set; }
}
}
8 changes: 8 additions & 0 deletions Cosette.Tuner.Common/Requests/TestType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Cosette.Tuner.Common.Requests
{
public enum TestType
{
SelfPlay,
Texel
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using System;
using System.Net.Http;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using Cosette.Tuner.Common.Requests;
using Cosette.Tuner.Common.Responses;
using Newtonsoft.Json;

namespace Cosette.Tuner.Web
namespace Cosette.Tuner.Common.Services
{
public class WebService
{
Expand Down Expand Up @@ -42,7 +41,7 @@ public async Task EnableIfAvailable()
}
}

public async Task<int> RegisterTest()
public async Task<int> RegisterTest(RegisterTestRequest requestData)
{
if (!_enabled)
{
Expand All @@ -51,7 +50,8 @@ public async Task<int> RegisterTest()

try
{
var response = await _httpClient.SendAsync(new HttpRequestMessage(HttpMethod.Post, "test/register"));
var httpContent = new StringContent(JsonConvert.SerializeObject(requestData), Encoding.UTF8, "application/json");
var response = await _httpClient.PostAsync("test/register", httpContent);
var responseContent = await response.Content.ReadAsStringAsync();

if (response.IsSuccessStatusCode)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Cosette.Tuner.Engine
namespace Cosette.Tuner.SelfPlay.Engine
{
public class BestMoveData
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Cosette.Tuner.Settings;
using Cosette.Tuner.SelfPlay.Settings;

namespace Cosette.Tuner.Engine
namespace Cosette.Tuner.SelfPlay.Engine
{
public class EngineOperator
{
Expand Down Expand Up @@ -84,6 +84,8 @@ public BestMoveData Go(List<string> moves, int whiteClock, int blackClock)
if (moves.Count > 0)
{
Write($"position startpos moves {movesJoined}");
Write("isready");
WaitForMessage("readyok");
}

Write($"go wtime {whiteClock} btime {blackClock} winc {SettingsLoader.Data.IncTime} binc {SettingsLoader.Data.IncTime}");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;

namespace Cosette.Tuner.Engine
namespace Cosette.Tuner.SelfPlay.Engine
{
public class InfoData
{
Expand Down
Loading

0 comments on commit 844ecd7

Please sign in to comment.