From 7946f4bafd15ec6df9d3f6f5f7da580a75ea5694 Mon Sep 17 00:00:00 2001 From: hypercross Date: Mon, 20 Jul 2026 16:30:02 +0800 Subject: [PATCH] refactor: reorganize project structure and move examples - Move examples (Blackjack, TicTacToe) to the root directory - Convert example projects from Console applications to Libraries - Add Directory.Build.props for shared build settings - Update solution file and project references to reflect new paths --- Blackjack/Blackjack.csproj | 17 ++ .../Commands/HitCommand.cs | 0 .../Commands/NewRoundCommand.cs | 0 .../Commands/PlaceBetCommand.cs | 0 .../Commands/StandCommand.cs | 0 .../Components/Card.cs | 0 .../Components/DealerHand.cs | 0 .../Components/Deck.cs | 0 .../Components/Holds.cs | 0 .../Components/InDeck.cs | 0 .../Components/PlayerHand.cs | 0 .../Components/Rank.cs | 0 .../Components/Suit.cs | 0 .../Blackjack => Blackjack}/Mulberry32.cs | 0 .../Singletons/GamePhase.cs | 0 .../Singletons/GameState.cs | 0 .../Singletons/RoundResult.cs | 0 .../Systems/DealSystem.cs | 0 .../Systems/DealerSystem.cs | 0 .../Systems/DeckSetupSystem.cs | 0 .../Systems/HandUtil.cs | 0 .../Systems/PlayerBustCheckSystem.cs | 0 Directory.Build.props | 9 ++ .../ComponentDiscoveryGenerator.cs | 0 .../OECS.SourceGen.csproj | 3 - .../OECS.Tests => OECS.Tests}/CommandTests.cs | 0 {tests/OECS.Tests => OECS.Tests}/CoreTests.cs | 0 .../EdgeCaseTests.cs | 0 .../OECS.Tests.csproj | 7 +- .../QueryAndSystemTests.cs | 0 .../ReactivityTests.cs | 0 .../RelationshipTests.cs | 0 .../SingletonTests.cs | 0 OECS.sln | 55 ++++--- {src/OECS => OECS}/ChangeBuffer.cs | 0 {src/OECS => OECS}/ChangeKind.cs | 0 {src/OECS => OECS}/ChangeSet.cs | 0 {src/OECS => OECS}/CommandQueue.cs | 0 {src/OECS => OECS}/ComponentDescriptor.cs | 0 {src/OECS => OECS}/ComponentRegistry.cs | 0 {src/OECS => OECS}/ComponentStore.cs | 0 {src/OECS => OECS}/Entity.cs | 0 {src/OECS => OECS}/EntityAllocator.cs | 0 {src/OECS => OECS}/EntityChange.cs | 0 {src/OECS => OECS}/EntityIterator.cs | 0 {src/OECS => OECS}/ForEachAction.cs | 0 {src/OECS => OECS}/ICommand.cs | 0 {src/OECS => OECS}/IRelationship.cs | 0 {src/OECS => OECS}/ISystem.cs | 0 {src/OECS => OECS}/ITickedSystem.cs | 0 {src/OECS => OECS}/OECS.csproj | 3 - {src/OECS => OECS}/QueryBuilder.cs | 0 {src/OECS => OECS}/QueryDescriptor.cs | 0 {src/OECS => OECS}/QueryExecutor.cs | 0 {src/OECS => OECS}/Relationship.cs | 0 {src/OECS => OECS}/RelationshipIndex.cs | 0 {src/OECS => OECS}/SparseSet.cs | 0 {src/OECS => OECS}/SystemGroup.cs | 0 {src/OECS => OECS}/Tick.cs | 0 {src/OECS => OECS}/World.cs | 0 {src/OECS => OECS}/WorldSerializer.cs | 0 {src/OECS => OECS}/WorldSnapshot.cs | 0 .../Commands/PlaceMarkCommand.cs | 0 .../Components/Cell.cs | 0 .../Components/Mark.cs | 0 .../Components/Player.cs | 0 .../TicTacToe => TicTacToe}/CsvLoader.cs | 0 .../TicTacToe => TicTacToe}/Data/board.csv | 0 .../Singletons/GameState.cs | 0 .../Singletons/GameStatus.cs | 0 .../Systems/WinCheckSystem.cs | 0 .../TicTacToe => TicTacToe}/TicTacToe.csproj | 9 +- examples/Blackjack/Blackjack.csproj | 20 --- examples/Blackjack/Program.cs | 114 ------------- examples/Blackjack/Systems/RenderSystem.cs | 148 ----------------- examples/TicTacToe/Program.cs | 153 ------------------ examples/TicTacToe/Systems/RenderSystem.cs | 61 ------- examples/TicTacToe/test_input.txt | 5 - examples/TicTacToe/test_load.txt | 3 - examples/TicTacToe/test_save.txt | 3 - 80 files changed, 61 insertions(+), 549 deletions(-) create mode 100644 Blackjack/Blackjack.csproj rename {examples/Blackjack => Blackjack}/Commands/HitCommand.cs (100%) rename {examples/Blackjack => Blackjack}/Commands/NewRoundCommand.cs (100%) rename {examples/Blackjack => Blackjack}/Commands/PlaceBetCommand.cs (100%) rename {examples/Blackjack => Blackjack}/Commands/StandCommand.cs (100%) rename {examples/Blackjack => Blackjack}/Components/Card.cs (100%) rename {examples/Blackjack => Blackjack}/Components/DealerHand.cs (100%) rename {examples/Blackjack => Blackjack}/Components/Deck.cs (100%) rename {examples/Blackjack => Blackjack}/Components/Holds.cs (100%) rename {examples/Blackjack => Blackjack}/Components/InDeck.cs (100%) rename {examples/Blackjack => Blackjack}/Components/PlayerHand.cs (100%) rename {examples/Blackjack => Blackjack}/Components/Rank.cs (100%) rename {examples/Blackjack => Blackjack}/Components/Suit.cs (100%) rename {examples/Blackjack => Blackjack}/Mulberry32.cs (100%) rename {examples/Blackjack => Blackjack}/Singletons/GamePhase.cs (100%) rename {examples/Blackjack => Blackjack}/Singletons/GameState.cs (100%) rename {examples/Blackjack => Blackjack}/Singletons/RoundResult.cs (100%) rename {examples/Blackjack => Blackjack}/Systems/DealSystem.cs (100%) rename {examples/Blackjack => Blackjack}/Systems/DealerSystem.cs (100%) rename {examples/Blackjack => Blackjack}/Systems/DeckSetupSystem.cs (100%) rename {examples/Blackjack => Blackjack}/Systems/HandUtil.cs (100%) rename {examples/Blackjack => Blackjack}/Systems/PlayerBustCheckSystem.cs (100%) create mode 100644 Directory.Build.props rename {src/OECS.SourceGen => OECS.SourceGen}/ComponentDiscoveryGenerator.cs (100%) rename {src/OECS.SourceGen => OECS.SourceGen}/OECS.SourceGen.csproj (87%) rename {tests/OECS.Tests => OECS.Tests}/CommandTests.cs (100%) rename {tests/OECS.Tests => OECS.Tests}/CoreTests.cs (100%) rename {tests/OECS.Tests => OECS.Tests}/EdgeCaseTests.cs (100%) rename {tests/OECS.Tests => OECS.Tests}/OECS.Tests.csproj (75%) rename {tests/OECS.Tests => OECS.Tests}/QueryAndSystemTests.cs (100%) rename {tests/OECS.Tests => OECS.Tests}/ReactivityTests.cs (100%) rename {tests/OECS.Tests => OECS.Tests}/RelationshipTests.cs (100%) rename {tests/OECS.Tests => OECS.Tests}/SingletonTests.cs (100%) rename {src/OECS => OECS}/ChangeBuffer.cs (100%) rename {src/OECS => OECS}/ChangeKind.cs (100%) rename {src/OECS => OECS}/ChangeSet.cs (100%) rename {src/OECS => OECS}/CommandQueue.cs (100%) rename {src/OECS => OECS}/ComponentDescriptor.cs (100%) rename {src/OECS => OECS}/ComponentRegistry.cs (100%) rename {src/OECS => OECS}/ComponentStore.cs (100%) rename {src/OECS => OECS}/Entity.cs (100%) rename {src/OECS => OECS}/EntityAllocator.cs (100%) rename {src/OECS => OECS}/EntityChange.cs (100%) rename {src/OECS => OECS}/EntityIterator.cs (100%) rename {src/OECS => OECS}/ForEachAction.cs (100%) rename {src/OECS => OECS}/ICommand.cs (100%) rename {src/OECS => OECS}/IRelationship.cs (100%) rename {src/OECS => OECS}/ISystem.cs (100%) rename {src/OECS => OECS}/ITickedSystem.cs (100%) rename {src/OECS => OECS}/OECS.csproj (92%) rename {src/OECS => OECS}/QueryBuilder.cs (100%) rename {src/OECS => OECS}/QueryDescriptor.cs (100%) rename {src/OECS => OECS}/QueryExecutor.cs (100%) rename {src/OECS => OECS}/Relationship.cs (100%) rename {src/OECS => OECS}/RelationshipIndex.cs (100%) rename {src/OECS => OECS}/SparseSet.cs (100%) rename {src/OECS => OECS}/SystemGroup.cs (100%) rename {src/OECS => OECS}/Tick.cs (100%) rename {src/OECS => OECS}/World.cs (100%) rename {src/OECS => OECS}/WorldSerializer.cs (100%) rename {src/OECS => OECS}/WorldSnapshot.cs (100%) rename {examples/TicTacToe => TicTacToe}/Commands/PlaceMarkCommand.cs (100%) rename {examples/TicTacToe => TicTacToe}/Components/Cell.cs (100%) rename {examples/TicTacToe => TicTacToe}/Components/Mark.cs (100%) rename {examples/TicTacToe => TicTacToe}/Components/Player.cs (100%) rename {examples/TicTacToe => TicTacToe}/CsvLoader.cs (100%) rename {examples/TicTacToe => TicTacToe}/Data/board.csv (100%) rename {examples/TicTacToe => TicTacToe}/Singletons/GameState.cs (100%) rename {examples/TicTacToe => TicTacToe}/Singletons/GameStatus.cs (100%) rename {examples/TicTacToe => TicTacToe}/Systems/WinCheckSystem.cs (100%) rename {examples/TicTacToe => TicTacToe}/TicTacToe.csproj (57%) delete mode 100644 examples/Blackjack/Blackjack.csproj delete mode 100644 examples/Blackjack/Program.cs delete mode 100644 examples/Blackjack/Systems/RenderSystem.cs delete mode 100644 examples/TicTacToe/Program.cs delete mode 100644 examples/TicTacToe/Systems/RenderSystem.cs delete mode 100644 examples/TicTacToe/test_input.txt delete mode 100644 examples/TicTacToe/test_load.txt delete mode 100644 examples/TicTacToe/test_save.txt diff --git a/Blackjack/Blackjack.csproj b/Blackjack/Blackjack.csproj new file mode 100644 index 0000000..3e7319f --- /dev/null +++ b/Blackjack/Blackjack.csproj @@ -0,0 +1,17 @@ + + + + Library + Blackjack + + + + + + + + + + + \ No newline at end of file diff --git a/examples/Blackjack/Commands/HitCommand.cs b/Blackjack/Commands/HitCommand.cs similarity index 100% rename from examples/Blackjack/Commands/HitCommand.cs rename to Blackjack/Commands/HitCommand.cs diff --git a/examples/Blackjack/Commands/NewRoundCommand.cs b/Blackjack/Commands/NewRoundCommand.cs similarity index 100% rename from examples/Blackjack/Commands/NewRoundCommand.cs rename to Blackjack/Commands/NewRoundCommand.cs diff --git a/examples/Blackjack/Commands/PlaceBetCommand.cs b/Blackjack/Commands/PlaceBetCommand.cs similarity index 100% rename from examples/Blackjack/Commands/PlaceBetCommand.cs rename to Blackjack/Commands/PlaceBetCommand.cs diff --git a/examples/Blackjack/Commands/StandCommand.cs b/Blackjack/Commands/StandCommand.cs similarity index 100% rename from examples/Blackjack/Commands/StandCommand.cs rename to Blackjack/Commands/StandCommand.cs diff --git a/examples/Blackjack/Components/Card.cs b/Blackjack/Components/Card.cs similarity index 100% rename from examples/Blackjack/Components/Card.cs rename to Blackjack/Components/Card.cs diff --git a/examples/Blackjack/Components/DealerHand.cs b/Blackjack/Components/DealerHand.cs similarity index 100% rename from examples/Blackjack/Components/DealerHand.cs rename to Blackjack/Components/DealerHand.cs diff --git a/examples/Blackjack/Components/Deck.cs b/Blackjack/Components/Deck.cs similarity index 100% rename from examples/Blackjack/Components/Deck.cs rename to Blackjack/Components/Deck.cs diff --git a/examples/Blackjack/Components/Holds.cs b/Blackjack/Components/Holds.cs similarity index 100% rename from examples/Blackjack/Components/Holds.cs rename to Blackjack/Components/Holds.cs diff --git a/examples/Blackjack/Components/InDeck.cs b/Blackjack/Components/InDeck.cs similarity index 100% rename from examples/Blackjack/Components/InDeck.cs rename to Blackjack/Components/InDeck.cs diff --git a/examples/Blackjack/Components/PlayerHand.cs b/Blackjack/Components/PlayerHand.cs similarity index 100% rename from examples/Blackjack/Components/PlayerHand.cs rename to Blackjack/Components/PlayerHand.cs diff --git a/examples/Blackjack/Components/Rank.cs b/Blackjack/Components/Rank.cs similarity index 100% rename from examples/Blackjack/Components/Rank.cs rename to Blackjack/Components/Rank.cs diff --git a/examples/Blackjack/Components/Suit.cs b/Blackjack/Components/Suit.cs similarity index 100% rename from examples/Blackjack/Components/Suit.cs rename to Blackjack/Components/Suit.cs diff --git a/examples/Blackjack/Mulberry32.cs b/Blackjack/Mulberry32.cs similarity index 100% rename from examples/Blackjack/Mulberry32.cs rename to Blackjack/Mulberry32.cs diff --git a/examples/Blackjack/Singletons/GamePhase.cs b/Blackjack/Singletons/GamePhase.cs similarity index 100% rename from examples/Blackjack/Singletons/GamePhase.cs rename to Blackjack/Singletons/GamePhase.cs diff --git a/examples/Blackjack/Singletons/GameState.cs b/Blackjack/Singletons/GameState.cs similarity index 100% rename from examples/Blackjack/Singletons/GameState.cs rename to Blackjack/Singletons/GameState.cs diff --git a/examples/Blackjack/Singletons/RoundResult.cs b/Blackjack/Singletons/RoundResult.cs similarity index 100% rename from examples/Blackjack/Singletons/RoundResult.cs rename to Blackjack/Singletons/RoundResult.cs diff --git a/examples/Blackjack/Systems/DealSystem.cs b/Blackjack/Systems/DealSystem.cs similarity index 100% rename from examples/Blackjack/Systems/DealSystem.cs rename to Blackjack/Systems/DealSystem.cs diff --git a/examples/Blackjack/Systems/DealerSystem.cs b/Blackjack/Systems/DealerSystem.cs similarity index 100% rename from examples/Blackjack/Systems/DealerSystem.cs rename to Blackjack/Systems/DealerSystem.cs diff --git a/examples/Blackjack/Systems/DeckSetupSystem.cs b/Blackjack/Systems/DeckSetupSystem.cs similarity index 100% rename from examples/Blackjack/Systems/DeckSetupSystem.cs rename to Blackjack/Systems/DeckSetupSystem.cs diff --git a/examples/Blackjack/Systems/HandUtil.cs b/Blackjack/Systems/HandUtil.cs similarity index 100% rename from examples/Blackjack/Systems/HandUtil.cs rename to Blackjack/Systems/HandUtil.cs diff --git a/examples/Blackjack/Systems/PlayerBustCheckSystem.cs b/Blackjack/Systems/PlayerBustCheckSystem.cs similarity index 100% rename from examples/Blackjack/Systems/PlayerBustCheckSystem.cs rename to Blackjack/Systems/PlayerBustCheckSystem.cs diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..6920e4d --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + 12 + + diff --git a/src/OECS.SourceGen/ComponentDiscoveryGenerator.cs b/OECS.SourceGen/ComponentDiscoveryGenerator.cs similarity index 100% rename from src/OECS.SourceGen/ComponentDiscoveryGenerator.cs rename to OECS.SourceGen/ComponentDiscoveryGenerator.cs diff --git a/src/OECS.SourceGen/OECS.SourceGen.csproj b/OECS.SourceGen/OECS.SourceGen.csproj similarity index 87% rename from src/OECS.SourceGen/OECS.SourceGen.csproj rename to OECS.SourceGen/OECS.SourceGen.csproj index b7a71b9..652e034 100644 --- a/src/OECS.SourceGen/OECS.SourceGen.csproj +++ b/OECS.SourceGen/OECS.SourceGen.csproj @@ -2,9 +2,6 @@ netstandard2.0 - enable - enable - 12 OECS.SourceGen OECS.SourceGen true diff --git a/tests/OECS.Tests/CommandTests.cs b/OECS.Tests/CommandTests.cs similarity index 100% rename from tests/OECS.Tests/CommandTests.cs rename to OECS.Tests/CommandTests.cs diff --git a/tests/OECS.Tests/CoreTests.cs b/OECS.Tests/CoreTests.cs similarity index 100% rename from tests/OECS.Tests/CoreTests.cs rename to OECS.Tests/CoreTests.cs diff --git a/tests/OECS.Tests/EdgeCaseTests.cs b/OECS.Tests/EdgeCaseTests.cs similarity index 100% rename from tests/OECS.Tests/EdgeCaseTests.cs rename to OECS.Tests/EdgeCaseTests.cs diff --git a/tests/OECS.Tests/OECS.Tests.csproj b/OECS.Tests/OECS.Tests.csproj similarity index 75% rename from tests/OECS.Tests/OECS.Tests.csproj rename to OECS.Tests/OECS.Tests.csproj index be47b57..a2e3f40 100644 --- a/tests/OECS.Tests/OECS.Tests.csproj +++ b/OECS.Tests/OECS.Tests.csproj @@ -1,9 +1,6 @@ - net8.0 - enable - enable OECS.Tests false true @@ -20,11 +17,11 @@ - + - diff --git a/tests/OECS.Tests/QueryAndSystemTests.cs b/OECS.Tests/QueryAndSystemTests.cs similarity index 100% rename from tests/OECS.Tests/QueryAndSystemTests.cs rename to OECS.Tests/QueryAndSystemTests.cs diff --git a/tests/OECS.Tests/ReactivityTests.cs b/OECS.Tests/ReactivityTests.cs similarity index 100% rename from tests/OECS.Tests/ReactivityTests.cs rename to OECS.Tests/ReactivityTests.cs diff --git a/tests/OECS.Tests/RelationshipTests.cs b/OECS.Tests/RelationshipTests.cs similarity index 100% rename from tests/OECS.Tests/RelationshipTests.cs rename to OECS.Tests/RelationshipTests.cs diff --git a/tests/OECS.Tests/SingletonTests.cs b/OECS.Tests/SingletonTests.cs similarity index 100% rename from tests/OECS.Tests/SingletonTests.cs rename to OECS.Tests/SingletonTests.cs diff --git a/OECS.sln b/OECS.sln index dab7a30..4f78a39 100644 --- a/OECS.sln +++ b/OECS.sln @@ -1,19 +1,16 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 +Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OECS.SourceGen", "src\OECS.SourceGen\OECS.SourceGen.csproj", "{C3D4E5F6-A7B8-9012-CDEF-123456789012}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OECS", "OECS\OECS.csproj", "{A1B2C3D4-E5F6-7890-ABCD-EF1234567890}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OECS", "src\OECS\OECS.csproj", "{A1B2C3D4-E5F6-7890-ABCD-EF1234567890}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OECS.SourceGen", "OECS.SourceGen\OECS.SourceGen.csproj", "{C3D4E5F6-A7B8-9012-CDEF-123456789012}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OECS.Tests", "tests\OECS.Tests\OECS.Tests.csproj", "{B2C3D4E5-F6A7-8901-BCDE-F12345678901}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OECS.Tests", "OECS.Tests\OECS.Tests.csproj", "{B2C3D4E5-F6A7-8901-BCDE-F12345678901}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{B36A84DF-456D-A817-6EDD-3EC3E7F6E11F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Blackjack", "Blackjack\Blackjack.csproj", "{85631EDE-F984-4DA6-8EE9-0715AF1204E6}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Blackjack", "examples\Blackjack\Blackjack.csproj", "{85631EDE-F984-4DA6-8EE9-0715AF1204E6}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TicTacToe", "TicTacToe\TicTacToe.csproj", "{D4E5F6A7-B8C9-0123-DEF4-567890ABCDEF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -25,18 +22,6 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Debug|x64.ActiveCfg = Debug|Any CPU - {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Debug|x64.Build.0 = Debug|Any CPU - {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Debug|x86.ActiveCfg = Debug|Any CPU - {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Debug|x86.Build.0 = Debug|Any CPU - {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Release|Any CPU.Build.0 = Release|Any CPU - {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Release|x64.ActiveCfg = Release|Any CPU - {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Release|x64.Build.0 = Release|Any CPU - {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Release|x86.ActiveCfg = Release|Any CPU - {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Release|x86.Build.0 = Release|Any CPU {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Debug|Any CPU.Build.0 = Debug|Any CPU {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -49,6 +34,18 @@ Global {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Release|x64.Build.0 = Release|Any CPU {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Release|x86.ActiveCfg = Release|Any CPU {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}.Release|x86.Build.0 = Release|Any CPU + {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Debug|x64.ActiveCfg = Debug|Any CPU + {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Debug|x64.Build.0 = Debug|Any CPU + {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Debug|x86.ActiveCfg = Debug|Any CPU + {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Debug|x86.Build.0 = Debug|Any CPU + {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Release|Any CPU.Build.0 = Release|Any CPU + {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Release|x64.ActiveCfg = Release|Any CPU + {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Release|x64.Build.0 = Release|Any CPU + {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Release|x86.ActiveCfg = Release|Any CPU + {C3D4E5F6-A7B8-9012-CDEF-123456789012}.Release|x86.Build.0 = Release|Any CPU {B2C3D4E5-F6A7-8901-BCDE-F12345678901}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B2C3D4E5-F6A7-8901-BCDE-F12345678901}.Debug|Any CPU.Build.0 = Debug|Any CPU {B2C3D4E5-F6A7-8901-BCDE-F12345678901}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -73,12 +70,20 @@ Global {85631EDE-F984-4DA6-8EE9-0715AF1204E6}.Release|x64.Build.0 = Release|Any CPU {85631EDE-F984-4DA6-8EE9-0715AF1204E6}.Release|x86.ActiveCfg = Release|Any CPU {85631EDE-F984-4DA6-8EE9-0715AF1204E6}.Release|x86.Build.0 = Release|Any CPU + {D4E5F6A7-B8C9-0123-DEF4-567890ABCDEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D4E5F6A7-B8C9-0123-DEF4-567890ABCDEF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D4E5F6A7-B8C9-0123-DEF4-567890ABCDEF}.Debug|x64.ActiveCfg = Debug|Any CPU + {D4E5F6A7-B8C9-0123-DEF4-567890ABCDEF}.Debug|x64.Build.0 = Debug|Any CPU + {D4E5F6A7-B8C9-0123-DEF4-567890ABCDEF}.Debug|x86.ActiveCfg = Debug|Any CPU + {D4E5F6A7-B8C9-0123-DEF4-567890ABCDEF}.Debug|x86.Build.0 = Debug|Any CPU + {D4E5F6A7-B8C9-0123-DEF4-567890ABCDEF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D4E5F6A7-B8C9-0123-DEF4-567890ABCDEF}.Release|Any CPU.Build.0 = Release|Any CPU + {D4E5F6A7-B8C9-0123-DEF4-567890ABCDEF}.Release|x64.ActiveCfg = Release|Any CPU + {D4E5F6A7-B8C9-0123-DEF4-567890ABCDEF}.Release|x64.Build.0 = Release|Any CPU + {D4E5F6A7-B8C9-0123-DEF4-567890ABCDEF}.Release|x86.ActiveCfg = Release|Any CPU + {D4E5F6A7-B8C9-0123-DEF4-567890ABCDEF}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {C3D4E5F6-A7B8-9012-CDEF-123456789012} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B} - {85631EDE-F984-4DA6-8EE9-0715AF1204E6} = {B36A84DF-456D-A817-6EDD-3EC3E7F6E11F} - EndGlobalSection EndGlobal diff --git a/src/OECS/ChangeBuffer.cs b/OECS/ChangeBuffer.cs similarity index 100% rename from src/OECS/ChangeBuffer.cs rename to OECS/ChangeBuffer.cs diff --git a/src/OECS/ChangeKind.cs b/OECS/ChangeKind.cs similarity index 100% rename from src/OECS/ChangeKind.cs rename to OECS/ChangeKind.cs diff --git a/src/OECS/ChangeSet.cs b/OECS/ChangeSet.cs similarity index 100% rename from src/OECS/ChangeSet.cs rename to OECS/ChangeSet.cs diff --git a/src/OECS/CommandQueue.cs b/OECS/CommandQueue.cs similarity index 100% rename from src/OECS/CommandQueue.cs rename to OECS/CommandQueue.cs diff --git a/src/OECS/ComponentDescriptor.cs b/OECS/ComponentDescriptor.cs similarity index 100% rename from src/OECS/ComponentDescriptor.cs rename to OECS/ComponentDescriptor.cs diff --git a/src/OECS/ComponentRegistry.cs b/OECS/ComponentRegistry.cs similarity index 100% rename from src/OECS/ComponentRegistry.cs rename to OECS/ComponentRegistry.cs diff --git a/src/OECS/ComponentStore.cs b/OECS/ComponentStore.cs similarity index 100% rename from src/OECS/ComponentStore.cs rename to OECS/ComponentStore.cs diff --git a/src/OECS/Entity.cs b/OECS/Entity.cs similarity index 100% rename from src/OECS/Entity.cs rename to OECS/Entity.cs diff --git a/src/OECS/EntityAllocator.cs b/OECS/EntityAllocator.cs similarity index 100% rename from src/OECS/EntityAllocator.cs rename to OECS/EntityAllocator.cs diff --git a/src/OECS/EntityChange.cs b/OECS/EntityChange.cs similarity index 100% rename from src/OECS/EntityChange.cs rename to OECS/EntityChange.cs diff --git a/src/OECS/EntityIterator.cs b/OECS/EntityIterator.cs similarity index 100% rename from src/OECS/EntityIterator.cs rename to OECS/EntityIterator.cs diff --git a/src/OECS/ForEachAction.cs b/OECS/ForEachAction.cs similarity index 100% rename from src/OECS/ForEachAction.cs rename to OECS/ForEachAction.cs diff --git a/src/OECS/ICommand.cs b/OECS/ICommand.cs similarity index 100% rename from src/OECS/ICommand.cs rename to OECS/ICommand.cs diff --git a/src/OECS/IRelationship.cs b/OECS/IRelationship.cs similarity index 100% rename from src/OECS/IRelationship.cs rename to OECS/IRelationship.cs diff --git a/src/OECS/ISystem.cs b/OECS/ISystem.cs similarity index 100% rename from src/OECS/ISystem.cs rename to OECS/ISystem.cs diff --git a/src/OECS/ITickedSystem.cs b/OECS/ITickedSystem.cs similarity index 100% rename from src/OECS/ITickedSystem.cs rename to OECS/ITickedSystem.cs diff --git a/src/OECS/OECS.csproj b/OECS/OECS.csproj similarity index 92% rename from src/OECS/OECS.csproj rename to OECS/OECS.csproj index 5042c48..0de7e61 100644 --- a/src/OECS/OECS.csproj +++ b/OECS/OECS.csproj @@ -1,9 +1,6 @@ - net8.0 - enable - enable OECS OECS diff --git a/src/OECS/QueryBuilder.cs b/OECS/QueryBuilder.cs similarity index 100% rename from src/OECS/QueryBuilder.cs rename to OECS/QueryBuilder.cs diff --git a/src/OECS/QueryDescriptor.cs b/OECS/QueryDescriptor.cs similarity index 100% rename from src/OECS/QueryDescriptor.cs rename to OECS/QueryDescriptor.cs diff --git a/src/OECS/QueryExecutor.cs b/OECS/QueryExecutor.cs similarity index 100% rename from src/OECS/QueryExecutor.cs rename to OECS/QueryExecutor.cs diff --git a/src/OECS/Relationship.cs b/OECS/Relationship.cs similarity index 100% rename from src/OECS/Relationship.cs rename to OECS/Relationship.cs diff --git a/src/OECS/RelationshipIndex.cs b/OECS/RelationshipIndex.cs similarity index 100% rename from src/OECS/RelationshipIndex.cs rename to OECS/RelationshipIndex.cs diff --git a/src/OECS/SparseSet.cs b/OECS/SparseSet.cs similarity index 100% rename from src/OECS/SparseSet.cs rename to OECS/SparseSet.cs diff --git a/src/OECS/SystemGroup.cs b/OECS/SystemGroup.cs similarity index 100% rename from src/OECS/SystemGroup.cs rename to OECS/SystemGroup.cs diff --git a/src/OECS/Tick.cs b/OECS/Tick.cs similarity index 100% rename from src/OECS/Tick.cs rename to OECS/Tick.cs diff --git a/src/OECS/World.cs b/OECS/World.cs similarity index 100% rename from src/OECS/World.cs rename to OECS/World.cs diff --git a/src/OECS/WorldSerializer.cs b/OECS/WorldSerializer.cs similarity index 100% rename from src/OECS/WorldSerializer.cs rename to OECS/WorldSerializer.cs diff --git a/src/OECS/WorldSnapshot.cs b/OECS/WorldSnapshot.cs similarity index 100% rename from src/OECS/WorldSnapshot.cs rename to OECS/WorldSnapshot.cs diff --git a/examples/TicTacToe/Commands/PlaceMarkCommand.cs b/TicTacToe/Commands/PlaceMarkCommand.cs similarity index 100% rename from examples/TicTacToe/Commands/PlaceMarkCommand.cs rename to TicTacToe/Commands/PlaceMarkCommand.cs diff --git a/examples/TicTacToe/Components/Cell.cs b/TicTacToe/Components/Cell.cs similarity index 100% rename from examples/TicTacToe/Components/Cell.cs rename to TicTacToe/Components/Cell.cs diff --git a/examples/TicTacToe/Components/Mark.cs b/TicTacToe/Components/Mark.cs similarity index 100% rename from examples/TicTacToe/Components/Mark.cs rename to TicTacToe/Components/Mark.cs diff --git a/examples/TicTacToe/Components/Player.cs b/TicTacToe/Components/Player.cs similarity index 100% rename from examples/TicTacToe/Components/Player.cs rename to TicTacToe/Components/Player.cs diff --git a/examples/TicTacToe/CsvLoader.cs b/TicTacToe/CsvLoader.cs similarity index 100% rename from examples/TicTacToe/CsvLoader.cs rename to TicTacToe/CsvLoader.cs diff --git a/examples/TicTacToe/Data/board.csv b/TicTacToe/Data/board.csv similarity index 100% rename from examples/TicTacToe/Data/board.csv rename to TicTacToe/Data/board.csv diff --git a/examples/TicTacToe/Singletons/GameState.cs b/TicTacToe/Singletons/GameState.cs similarity index 100% rename from examples/TicTacToe/Singletons/GameState.cs rename to TicTacToe/Singletons/GameState.cs diff --git a/examples/TicTacToe/Singletons/GameStatus.cs b/TicTacToe/Singletons/GameStatus.cs similarity index 100% rename from examples/TicTacToe/Singletons/GameStatus.cs rename to TicTacToe/Singletons/GameStatus.cs diff --git a/examples/TicTacToe/Systems/WinCheckSystem.cs b/TicTacToe/Systems/WinCheckSystem.cs similarity index 100% rename from examples/TicTacToe/Systems/WinCheckSystem.cs rename to TicTacToe/Systems/WinCheckSystem.cs diff --git a/examples/TicTacToe/TicTacToe.csproj b/TicTacToe/TicTacToe.csproj similarity index 57% rename from examples/TicTacToe/TicTacToe.csproj rename to TicTacToe/TicTacToe.csproj index c4b6b7f..cc9eefa 100644 --- a/examples/TicTacToe/TicTacToe.csproj +++ b/TicTacToe/TicTacToe.csproj @@ -1,19 +1,16 @@ - Exe - net8.0 - enable - enable + Library TicTacToe - + - diff --git a/examples/Blackjack/Blackjack.csproj b/examples/Blackjack/Blackjack.csproj deleted file mode 100644 index c0cd25f..0000000 --- a/examples/Blackjack/Blackjack.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - Exe - net8.0 - enable - enable - Blackjack - - - - - - - - - - - \ No newline at end of file diff --git a/examples/Blackjack/Program.cs b/examples/Blackjack/Program.cs deleted file mode 100644 index 0b97dcc..0000000 --- a/examples/Blackjack/Program.cs +++ /dev/null @@ -1,114 +0,0 @@ -using OECS; - -namespace Blackjack; - -public static class Program -{ - public static void Main() - { - var world = new World(); - - // ── Initialize game state ───────────────────────────────────── - - // Use a seed based on current time, or a fixed seed for reproducibility. - uint seed = (uint)Environment.TickCount; - // Uncomment the next line for a deterministic game: - // seed = 12345u; - - world.SetSingleton(new GameState - { - Phase = GamePhase.Betting, - Result = RoundResult.None, - Chips = 100, - CurrentBet = 0, - RoundNumber = 1, - Seed = seed - }); - world.PostChanges(); - - // ── Wire up systems ─────────────────────────────────────────── - - var group = new SystemGroup(world); - group.Add(new DeckSetupSystem()); - group.Add(new DealSystem()); - group.Add(new PlayerBustCheckSystem()); - group.Add(new DealerSystem()); - group.Add(new RenderSystem()); - - // ── Game loop ───────────────────────────────────────────────── - - group.RunLogical(); - - while (true) - { - var state = world.ReadSingleton(); - - // Check for game over (out of chips). - if (state.Chips <= 0 && state.Phase == GamePhase.Betting) - { - Console.WriteLine(); - Console.WriteLine(" You're out of chips! Game over."); - break; - } - - switch (state.Phase) - { - case GamePhase.Betting: - var input = Console.ReadLine(); - if (string.IsNullOrWhiteSpace(input)) - continue; - if (input.Trim().ToLower() == "quit") - return; - - if (int.TryParse(input.Trim(), out var bet)) - { - world.Commands.Enqueue(new PlaceBetCommand { Amount = bet }); - } - else - { - Console.WriteLine(" Invalid bet. Enter a number."); - continue; - } - break; - - case GamePhase.PlayerTurn: - var choice = Console.ReadLine(); - if (string.IsNullOrWhiteSpace(choice)) - continue; - if (choice.Trim().ToLower() == "quit") - return; - - switch (choice.Trim().ToLower()) - { - case "h": - case "hit": - world.Commands.Enqueue(new HitCommand()); - break; - case "s": - case "stand": - world.Commands.Enqueue(new StandCommand()); - break; - default: - Console.WriteLine(" Invalid choice. Enter H or S."); - continue; - } - break; - - case GamePhase.RoundOver: - Console.ReadLine(); - ref var roundState = ref world.GetSingleton(); - roundState.RoundNumber++; - world.MarkModified(World.SingletonEntity); - world.PostChanges(); - world.Commands.Enqueue(new NewRoundCommand()); - break; - - default: - // Dealing, DealerTurn — systems handle these automatically. - break; - } - - group.RunLogical(); - } - } -} \ No newline at end of file diff --git a/examples/Blackjack/Systems/RenderSystem.cs b/examples/Blackjack/Systems/RenderSystem.cs deleted file mode 100644 index f325e41..0000000 --- a/examples/Blackjack/Systems/RenderSystem.cs +++ /dev/null @@ -1,148 +0,0 @@ -using OECS; - -namespace Blackjack; - -/// -/// Renders the current game state to the console. -/// -public class RenderSystem : ISystem -{ - public void Run(World world) - { - var state = world.ReadSingleton(); - - Console.WriteLine(); - Console.WriteLine(" Blackjack"); - Console.WriteLine(" ═════════"); - Console.WriteLine(); - Console.WriteLine($" Chips: {state.Chips} | Round: {state.RoundNumber}"); - Console.WriteLine(); - - // Show dealer's hand. - var dealerTotal = HandUtil.CalculateHand(world, DealerHandTag.Instance); - Console.Write(" Dealer: "); - if (state.Phase == GamePhase.PlayerTurn) - { - // Hide first card (hole card) during player's turn. - Console.Write("?? "); - PrintHand(world, DealerHandTag.Instance, skipFirst: true); - } - else - { - PrintHand(world, DealerHandTag.Instance); - Console.Write($" ({dealerTotal})"); - } - Console.WriteLine(); - - // Show player's hand. - var playerTotal = HandUtil.CalculateHand(world, PlayerHandTag.Instance); - Console.Write(" Player: "); - PrintHand(world, PlayerHandTag.Instance); - Console.Write($" ({playerTotal})"); - Console.WriteLine(); - Console.WriteLine(); - - // Status line. - switch (state.Phase) - { - case GamePhase.Betting: - Console.Write($" Enter bet (1–{state.Chips}): "); - break; - case GamePhase.PlayerTurn: - Console.Write(" [H]it or [S]tand: "); - break; - case GamePhase.RoundOver: - Console.WriteLine($" {ResultText(state.Result)}"); - Console.WriteLine(); - Console.Write(" Press Enter for next round..."); - break; - default: - break; - } - } - - private static void PrintHand(World world, DealerHand hand, bool skipFirst = false) - { - PrintHandImpl(world, hand, skipFirst); - } - - private static void PrintHand(World world, PlayerHand hand) - { - PrintHandImpl(world, hand, skipFirst: false); - } - - private static void PrintHandImpl(World world, T handTag, bool skipFirst) - where T : struct - { - Entity handEntity = Entity.Null; - using (var iter = world.Select()) - { - while (iter.MoveNext()) - { - if (iter.CurrentEntity != World.SingletonEntity) - { - handEntity = iter.CurrentEntity; - break; - } - } - } - - if (handEntity == Entity.Null) - return; - - var cards = world.GetSources(handEntity); - var ordered = cards.OrderByDescending(c => - { - var card = world.ReadComponent(c); - return (int)card.Rank; - }).ToList(); - - bool first = true; - foreach (var cardEntity in ordered) - { - if (skipFirst && first) - { - first = false; - continue; - } - first = false; - var card = world.ReadComponent(cardEntity); - Console.Write(CardToString(card)); - Console.Write(" "); - } - } - - private static string CardToString(Card card) - { - var suit = card.Suit switch - { - Suit.Hearts => "♥", - Suit.Diamonds => "♦", - Suit.Clubs => "♣", - Suit.Spades => "♠", - _ => "?" - }; - - var rank = card.Rank switch - { - Rank.Ace => "A", - Rank.Jack => "J", - Rank.Queen => "Q", - Rank.King => "K", - _ => ((int)card.Rank).ToString() - }; - - return $"{rank}{suit}"; - } - - private static string ResultText(RoundResult result) => result switch - { - RoundResult.PlayerBust => "You bust! Dealer wins.", - RoundResult.DealerBust => "Dealer busts! You win!", - RoundResult.PlayerWin => "You win!", - RoundResult.DealerWin => "Dealer wins.", - RoundResult.Push => "Push — it's a tie!", - RoundResult.Blackjack => "Blackjack!", - _ => "" - }; -} \ No newline at end of file diff --git a/examples/TicTacToe/Program.cs b/examples/TicTacToe/Program.cs deleted file mode 100644 index 92d9192..0000000 --- a/examples/TicTacToe/Program.cs +++ /dev/null @@ -1,153 +0,0 @@ -using OECS; -using R3; - -namespace TicTacToe; - -public static class Program -{ - private static readonly string SavePath = Path.Combine( - AppContext.BaseDirectory, "save.bin"); - - public static void Main() - { - var world = new World(); - var reactivityLog = new List(); - SetupReactivityLogging(world, reactivityLog); - - // ── Try to load a saved game ────────────────────────────────── - - bool loaded = false; - if (File.Exists(SavePath)) - { - Console.Write("Saved game found. Load it? (y/n): "); - if (Console.ReadLine()?.Trim().ToLower() == "y") - { - using var stream = File.OpenRead(SavePath); - WorldSerializer.Load(world, stream); - loaded = true; - Console.WriteLine("Game loaded!"); - Console.WriteLine(); - } - } - - // ── Load fresh board from CSV (if not loaded) ───────────────── - - if (!loaded) - { - var csvPath = Path.Combine(AppContext.BaseDirectory, "Data", "board.csv"); - CsvLoader.LoadCells(world, csvPath); - world.PostChanges(); - - world.SetSingleton(new GameState - { - CurrentPlayer = Player.X, - Status = GameStatus.Playing, - MoveCount = 0 - }); - world.PostChanges(); - } - - // ── Wire up systems ─────────────────────────────────────────── - - var group = new SystemGroup(world); - group.Add(new WinCheckSystem()); - group.Add(new RenderSystem()); - - // ── Game loop ───────────────────────────────────────────────── - - group.RunLogical(); - PrintReactivityLog(reactivityLog); - - while (true) - { - ref var state = ref world.GetSingleton(); - if (state.Status != GameStatus.Playing) - break; - - var input = Console.ReadLine(); - if (string.IsNullOrWhiteSpace(input)) - continue; - - // "save" command. - if (input.Trim().ToLower() == "save") - { - SaveGame(world); - Console.WriteLine(" Game saved."); - continue; - } - - var parts = input.Trim().Split(' ', StringSplitOptions.RemoveEmptyEntries); - if (parts.Length != 2 || - !int.TryParse(parts[0], out var row) || - !int.TryParse(parts[1], out var col)) - { - Console.WriteLine(" Invalid input. Try \"1 2\" or \"save\"."); - continue; - } - - if (row < 0 || row > 2 || col < 0 || col > 2) - { - Console.WriteLine(" Row and col must be 0–2."); - continue; - } - - world.Commands.Enqueue(new PlaceMarkCommand { Row = row, Col = col }); - group.RunLogical(); - PrintReactivityLog(reactivityLog); - - // Auto-save after every move. - SaveGame(world); - } - - // ── Final state ─────────────────────────────────────────────── - - Console.WriteLine(); - Console.WriteLine("=== Game over ==="); - PrintReactivityLog(reactivityLog); - - // Clean up save file on game over. - if (File.Exists(SavePath)) - File.Delete(SavePath); - } - - private static void SaveGame(World world) - { - using var stream = File.Create(SavePath); - WorldSerializer.Save(world, stream); - } - - private static void SetupReactivityLogging(World world, List log) - { - world.ObserveEntityChanges().Subscribe(change => - { - if (change.ComponentType != null) return; - log.Add($"[react] {change}"); - }); - - world.ObserveComponentChanges().Subscribe(change => - { - log.Add($"[react] {change}"); - }); - - world.ObserveComponentChanges().Subscribe(change => - { - log.Add($"[react] {change}"); - }); - - var markedQuery = world.Query().With().With().Build(); - world.ObserveQuery(markedQuery).Subscribe(change => - { - log.Add($"[react:query] {change}"); - }); - } - - private static void PrintReactivityLog(List log) - { - if (log.Count == 0) return; - Console.WriteLine("── reactivity log ──"); - foreach (var entry in log) - Console.WriteLine(entry); - Console.WriteLine(); - log.Clear(); - } -} \ No newline at end of file diff --git a/examples/TicTacToe/Systems/RenderSystem.cs b/examples/TicTacToe/Systems/RenderSystem.cs deleted file mode 100644 index 5c4e25f..0000000 --- a/examples/TicTacToe/Systems/RenderSystem.cs +++ /dev/null @@ -1,61 +0,0 @@ -using OECS; - -namespace TicTacToe; - -/// -/// Prints the board to the console. -/// -public class RenderSystem : ISystem -{ - public void Run(World world) - { - var state = world.ReadSingleton(); - - // Build a 3×3 grid. - var grid = new char[3, 3]; - for (int r = 0; r < 3; r++) - for (int c = 0; c < 3; c++) - grid[r, c] = '.'; - - // Fill in placed marks using the iterator API. - using var markIter = world.Select(); - while (markIter.MoveNext()) - { - grid[markIter.Current1.Row, markIter.Current1.Col] = - markIter.Current2.Player == Player.X ? 'X' : 'O'; - } - - Console.WriteLine(); - Console.WriteLine(" Tic-Tac-Toe"); - Console.WriteLine(" ═══════════"); - Console.WriteLine(); - Console.WriteLine(" 0 1 2"); - Console.WriteLine(" ┌───┬───┬───┐"); - for (int r = 0; r < 3; r++) - { - Console.Write($"{r} │"); - for (int c = 0; c < 3; c++) - { - Console.Write($" {grid[r, c]} "); - if (c < 2) Console.Write("│"); - } - Console.WriteLine("│"); - if (r < 2) Console.WriteLine(" ├───┼───┼───┤"); - } - Console.WriteLine(" └───┴───┴───┘"); - Console.WriteLine(); - - // Status line. - var statusText = state.Status switch - { - GameStatus.Playing => $"{(state.CurrentPlayer == Player.X ? 'X' : 'O')}'s turn (move {state.MoveCount + 1})", - GameStatus.XWon => "X wins!", - GameStatus.OWon => "O wins!", - GameStatus.Draw => "It's a draw!", - _ => "" - }; - Console.WriteLine($" {statusText}"); - Console.WriteLine(); - Console.Write(" Enter row col (e.g. \"1 2\"): "); - } -} \ No newline at end of file diff --git a/examples/TicTacToe/test_input.txt b/examples/TicTacToe/test_input.txt deleted file mode 100644 index 75b2559..0000000 --- a/examples/TicTacToe/test_input.txt +++ /dev/null @@ -1,5 +0,0 @@ -0 0 -1 1 -0 1 -1 0 -0 2 diff --git a/examples/TicTacToe/test_load.txt b/examples/TicTacToe/test_load.txt deleted file mode 100644 index 1f5a4b4..0000000 --- a/examples/TicTacToe/test_load.txt +++ /dev/null @@ -1,3 +0,0 @@ -y -1 0 -0 2 \ No newline at end of file diff --git a/examples/TicTacToe/test_save.txt b/examples/TicTacToe/test_save.txt deleted file mode 100644 index 498f27a..0000000 --- a/examples/TicTacToe/test_save.txt +++ /dev/null @@ -1,3 +0,0 @@ -0 0 -1 1 -0 1 \ No newline at end of file