diff --git a/Chess-Challenge/src/Framework/Application/Core/ChallengeController.cs b/Chess-Challenge/src/Framework/Application/Core/ChallengeController.cs
index 4d6822875..554fe7cad 100644
--- a/Chess-Challenge/src/Framework/Application/Core/ChallengeController.cs
+++ b/Chess-Challenge/src/Framework/Application/Core/ChallengeController.cs
@@ -13,6 +13,12 @@
namespace ChessChallenge.Application
{
+ ///
+ /// Main orchestrator class for the appplication. Contains the handles for when buttons are
+ /// pushed and triggers the UI drawing methods accordingly.
+ /// Maintains the application's state. The app's state includes things such as:
+ /// Aggregated game stats, current running game flag, current game's ID, current game's player types, etc.
+ ///
public class ChallengeController
{
public enum PlayerType
@@ -159,8 +165,10 @@ Move GetBotMove()
return Move.NullMove;
}
-
-
+ ///
+ /// If next player to move is human it enables the HumanPlayer's update() loop.
+ /// If next player to move is a bot then it gets the next bot move, updates the bot's clock and attempts to play it.
+ ///
void NotifyTurnToMove()
{
//playerToMove.NotifyTurnToMove(board);
@@ -256,9 +264,12 @@ void PlayMove(Move move)
bool animate = PlayerToMove.IsBot;
lastMoveMadeTime = (float)Raylib.GetTime();
+ // Paint/make move on the board
board.MakeMove(move, false);
boardUI.UpdatePosition(board, move, animate);
+ // Update the game state and notify the opponent that its their turn.
+ // End game if applicable.
GameResult result = Arbiter.GetGameState(board);
if (result == GameResult.InProgress)
{
diff --git a/Chess-Challenge/src/Framework/Application/Core/Program.cs b/Chess-Challenge/src/Framework/Application/Core/Program.cs
index 134db7645..60f4d971e 100644
--- a/Chess-Challenge/src/Framework/Application/Core/Program.cs
+++ b/Chess-Challenge/src/Framework/Application/Core/Program.cs
@@ -5,6 +5,11 @@
namespace ChessChallenge.Application
{
+ ///
+ /// Contains the app's entry point and UI update loop.
+ /// This project uses the Raylib game engine.
+ /// Familiarize yourself with it before making any changes to the code.
+ ///
static class Program
{
const bool hideRaylibLogs = true;
@@ -31,6 +36,7 @@ public static void Main()
ChallengeController controller = new();
+ // The app's main update loop.
while (!Raylib.WindowShouldClose())
{
Raylib.BeginDrawing();
diff --git a/Chess-Challenge/src/Framework/Application/Players/HumanPlayer.cs b/Chess-Challenge/src/Framework/Application/Players/HumanPlayer.cs
index b8396a069..6226fbdc5 100644
--- a/Chess-Challenge/src/Framework/Application/Players/HumanPlayer.cs
+++ b/Chess-Challenge/src/Framework/Application/Players/HumanPlayer.cs
@@ -4,6 +4,9 @@
namespace ChessChallenge.Application
{
+ ///
+ /// Contains state and methods necessary to control a human player in the framework.
+ ///
public class HumanPlayer
{
public event System.Action? MoveChosen;
@@ -84,6 +87,11 @@ void CancelDrag()
boardUI.ResetSquareColours(true);
}
+ ///
+ /// First checks if the chosen move is valid. If it is then the move is played.
+ ///
+ ///
+ ///
void TryMakeMove(int startSquare, int targetSquare)
{
bool isLegal = false;
diff --git a/Chess-Challenge/src/Framework/Chess/Move Generation/MoveGenerator.cs b/Chess-Challenge/src/Framework/Chess/Move Generation/MoveGenerator.cs
index af6e8976c..99ad76f78 100644
--- a/Chess-Challenge/src/Framework/Chess/Move Generation/MoveGenerator.cs
+++ b/Chess-Challenge/src/Framework/Chess/Move Generation/MoveGenerator.cs
@@ -3,6 +3,10 @@ namespace ChessChallenge.Chess
using System;
using static PrecomputedMoveData;
+ ///
+ /// Keeps the state of the current game (piece location, in-check flag, etc) and uses it to generate a collection of valid moves
+ /// for the current position.
+ ///
public class MoveGenerator
{
public const int MaxMoves = 218;
@@ -46,6 +50,8 @@ public enum PromotionMode { All, QueenOnly, QueenAndKnight }
// Otherwise it will have 1s everywhere.
ulong moveTypeMask;
+ // Generates list of legal moves in current position.
+ // Quiet moves (non captures) can optionally be excluded. This is used in quiescence search.
public System.Span GenerateMoves(Board board, bool includeQuietMoves = true)
{
System.Span moves = new Move[MaxMoves];
diff --git a/Chess-Challenge/src/Framework/Chess/Result/Arbiter.cs b/Chess-Challenge/src/Framework/Chess/Result/Arbiter.cs
index c2cd01b39..4a9556e2a 100644
--- a/Chess-Challenge/src/Framework/Chess/Result/Arbiter.cs
+++ b/Chess-Challenge/src/Framework/Chess/Result/Arbiter.cs
@@ -2,6 +2,10 @@
{
using System.Linq;
+ ///
+ /// Contains methods to determine the status of a game (Draw, Win, etc) based on an instance of
+ /// the class.
+ ///
public static class Arbiter
{
public static bool IsDrawResult(GameResult result)
diff --git a/Chess-Challenge/src/My Bot/MyBot.cs b/Chess-Challenge/src/My Bot/MyBot.cs
index 3c2a704a7..583329b4e 100644
--- a/Chess-Challenge/src/My Bot/MyBot.cs
+++ b/Chess-Challenge/src/My Bot/MyBot.cs
@@ -2,6 +2,14 @@
public class MyBot : IChessBot
{
+ ///
+ /// This method is called automatically by the framework whenever it's this bot's turn to move.
+ /// Illegal moves will be rejected by the framework.
+ /// Use the methods in such as GetLegalMoves() to help in making a decision for the bot's next move.
+ ///
+ /// The current board's status.
+ /// This bot's timer.
+ ///
public Move Think(Board board, Timer timer)
{
Move[] moves = board.GetLegalMoves();