Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Authors
WinChess is developed and maintained by:
- **Touil Ghassen** � Project lead, software architecture, and chess-engine development
- **[BAZIZ Chafia](https://github.com/ChiChiNour310)** � Developer
- **[BOUAKAZ Ahlem](https://github.com/ahlambkz0923)** � Developer
## Contributors
Additional contributors are acknowledged through the Git commit history and
the GitHub contributors list.
## Authorship policy
Authors and co-authors must be credited only for work to which they actually
contributed. Joint commits should use Git's `Co-authored-by` trailers with an
email address associated with the contributor's GitHub account.
22 changes: 8 additions & 14 deletions ChessGUI/ChessGUI.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net10.0-windows</TargetFramework>
<AssemblyName>WinChess</AssemblyName>
<Product>WinChess</Product>
<Description>Windows chess application with a native C++ engine, WPF GUI, and UCI host.</Description>
<Authors>Ahlem Chafia; WinChess contributors</Authors>
<Description>Open-source Windows chess application with a native C++ engine, WPF GUI, and UCI host.</Description>
<Authors>Touil Ghassen; BAZIZ Chafia; BOUAKAZ Ahlem</Authors>
<Version>0.1.0</Version>
<RepositoryUrl>https://github.com/binarylab2022-del/WinChess</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand All @@ -20,8 +20,10 @@
prevents BadImageFormatException and keeps deployment deterministic. -->
<PlatformTarget>x64</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
<Company>BinaryLab</Company>
<Copyright>Copyright © 2026 Touil Ghassen, BAZIZ Chafia, BOUAKAZ Ahlem</Copyright>
<PackageProjectUrl>https://github.com/binarylab2022-del/WinChess</PackageProjectUrl>
</PropertyGroup>

<ItemGroup>
<None Remove="Pieces\bB.svg" />
<None Remove="Pieces\bK.svg" />
Expand All @@ -36,7 +38,6 @@
<None Remove="Pieces\wQ.svg" />
<None Remove="Pieces\wR.svg" />
</ItemGroup>

<ItemGroup>
<Content Include="Pieces\bB.svg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down Expand Up @@ -75,23 +76,16 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Include="SharpVectors.Wpf" Version="1.8.5" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ChessDLL\ChessDLL.vcxproj" />
</ItemGroup>

<Target Name="CopyNativeChessEngine" AfterTargets="Build">
<PropertyGroup>
<NativeChessDll>$(MSBuildProjectDirectory)\..\bin\x64\$(Configuration)\ChessDLL.dll</NativeChessDll>
</PropertyGroup>
<Copy SourceFiles="$(NativeChessDll)"
DestinationFolder="$(OutDir)"
SkipUnchangedFiles="true"
Condition="Exists('$(NativeChessDll)')" />
<Copy SourceFiles="$(NativeChessDll)" DestinationFolder="$(OutDir)" SkipUnchangedFiles="true" Condition="Exists('$(NativeChessDll)')" />
</Target>

</Project>
</Project>
38 changes: 22 additions & 16 deletions ChessGUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal BoardTheme(string name, Color light, Color dark)
};

private BoardSnapshot _boardSnapshot = new();
private Button selectedSquare = null;
private Button? selectedSquare;
private int selectedRow;
private int selectedCol;
private bool whiteIsHuman = true;
Expand All @@ -67,8 +67,8 @@ internal BoardTheme(string name, Color light, Color dark)
private bool _engineThinking = false;
private bool _boardFlipped = false;
private int _boardThemeIndex = 0;
private Button derniereFrom = null;
private Button derniereTo = null;
private Button? derniereFrom;
private Button? derniereTo;
private int depthWhite = 4;
private int depthBlack = 4;

Expand All @@ -89,7 +89,7 @@ internal BoardTheme(string name, Color light, Color dark)
private int _benchmarkDraws;
private int _benchmarkLosses;

private ContentPresenter GetPresenter(Button cell)
private ContentPresenter? GetPresenter(Button cell)
{
var innerGrid = cell.Content as Grid;
if (innerGrid == null) return null;
Expand Down Expand Up @@ -119,6 +119,10 @@ private Button GetCellForEngineCoordinate(int engineRow, int engineCol)
return squares[display.row, display.col];
}

/// <summary>
/// Initializes the WinChess main window, board controls,
/// native chess engine, and live-analysis services.
/// </summary>
public MainWindow()
{
InitializeComponent();
Expand All @@ -145,6 +149,7 @@ public MainWindow()
ComputerTurnIfNeeded();
}

/// <inheritdoc />
protected override void OnClosed(EventArgs e)
{
_benchmarkCts?.Cancel();
Expand Down Expand Up @@ -238,7 +243,7 @@ private void AfficherPiecesDepuisEngine()
{
var engine = ToEngineCoordinate(displayRow, displayCol);
PieceCode piece = _boardSnapshot.PieceAtCanonical(engine.row, engine.col);
ContentPresenter presenter = GetPresenter(squares[displayRow, displayCol]);
ContentPresenter? presenter = GetPresenter(squares[displayRow, displayCol]);
if (presenter != null)
presenter.Content = PieceToImage(piece);
}
Expand All @@ -248,10 +253,10 @@ private void AfficherPiecesDepuisEngine()
MettreAJourListeCoups();
}

private ImageSource ChargerSourcePiece(PieceCode piece)
private ImageSource? ChargerSourcePiece(PieceCode piece)
{
if (piece == PieceCode.Empty) return null;
if (_pieceSources.TryGetValue(piece, out ImageSource source)) return source;
if (_pieceSources.TryGetValue(piece, out ImageSource? source) && source is not null) return source;

string[] names =
{
Expand All @@ -266,7 +271,7 @@ private ImageSource ChargerSourcePiece(PieceCode piece)
TextAsGeometry = false
};
var converter = new FileSvgReader(settings);
DrawingGroup drawing = converter.Read(path);
DrawingGroup? drawing = converter.Read(path);
if (drawing == null) return null;

var image = new DrawingImage(drawing);
Expand All @@ -275,9 +280,9 @@ private ImageSource ChargerSourcePiece(PieceCode piece)
return image;
}

private Image PieceToImage(PieceCode piece)
private Image? PieceToImage(PieceCode piece)
{
ImageSource source = ChargerSourcePiece(piece);
ImageSource? source = ChargerSourcePiece(piece);
if (source == null) return null;
return new Image
{
Expand Down Expand Up @@ -345,7 +350,8 @@ private async void Cell_Click(object sender, RoutedEventArgs e)
int row = engine.row;
int col = engine.col;

if (selectedSquare == null)
Button? previousSelection = selectedSquare;
if (previousSelection is null)
{
PieceCode piece = _boardSnapshot.PieceAtCanonical(row, col);
if (piece == PieceCode.Empty) return;
Expand All @@ -360,7 +366,7 @@ private async void Cell_Click(object sender, RoutedEventArgs e)
return;
}

selectedSquare.BorderThickness = new Thickness(0);
previousSelection.BorderThickness = new Thickness(0);
EffacerSurbrillance();
ClearHintHighlight();

Expand Down Expand Up @@ -433,7 +439,7 @@ private int DemanderPromotion()
};
btn.Click += (s, ev) =>
{
result = (int)(s as Button).Tag;
if (s is Button button && button.Tag is int promotionValue) result = promotionValue;
dialog.Close();
};
panel.Children.Add(btn);
Expand Down Expand Up @@ -981,9 +987,9 @@ private async Task RunBenchmarkAsync(
{
TxtBenchmarkStatus.Text =
$"Game {game + 1}/{games}: {external.DisplayName} thinking…";
string response = await external.GetBestMoveAsync(
string? response = await external.GetBestMoveAsync(
ChessAPI.GetFENString(), timePerMove, token);
if (!PlayExternalUciMove(response))
if (string.IsNullOrWhiteSpace(response) || !PlayExternalUciMove(response))
{
++_benchmarkWins;
TxtBenchmarkStatus.Text =
Expand Down Expand Up @@ -1399,7 +1405,7 @@ private void AfficherPrises(WrapPanel panel, int[] manquantes, bool iconeNoire)
{
for (int j = 0; j < manquantes[i]; j++)
{
Image image = PieceToImage(pieces[i]);
Image? image = PieceToImage(pieces[i]);
if (image == null) continue;
image.Width = 22;
image.Height = 22;
Expand Down
2 changes: 1 addition & 1 deletion ChessUCI/ChessUCI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ int main() {
const std::string command = tokens[0];
if (command == "uci") {
writeLine("id name WinChess");
writeLine("id author Ahlem Chafia");
writeLine("id author Touil Ghassen, BAZIZ Chafia, BOUAKAZ Ahlem");
writeLine("option name Hash type spin default 64 min 1 max " + std::to_string(g_getHashMaximum()));
writeLine("option name Move Overhead type spin default 30 min 0 max 5000");
writeLine("option name Use PVS type check default true");
Expand Down
Loading