diff --git a/ExternalBotTest/AssemblyInfo.fs b/ExternalBotTest/AssemblyInfo.fs new file mode 100644 index 0000000..310e72e --- /dev/null +++ b/ExternalBotTest/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace ExternalBotTest.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[] +[] +[] +[] +[] +[] +[] +[] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [] +[] +[] + +do + () \ No newline at end of file diff --git a/ExternalBotTest/ExternalBotTest.fsproj b/ExternalBotTest/ExternalBotTest.fsproj new file mode 100644 index 0000000..27ab13c --- /dev/null +++ b/ExternalBotTest/ExternalBotTest.fsproj @@ -0,0 +1,76 @@ + + + + + Debug + AnyCPU + 2.0 + 712da2c7-1b88-4ddb-8b79-46af5d5f6b19 + Library + ExternalBotTest + ExternalBotTest + v4.5.2 + 4.4.0.0 + true + ExternalBotTest + + + true + full + false + false + bin\Debug\ + DEBUG;TRACE + 3 + bin\Debug\ExternalBotTest.XML + + + pdbonly + true + true + bin\Release\ + TRACE + 3 + bin\Release\ExternalBotTest.XML + + + + D:\Users\marku\Documents\Visual Studio 2015\Projects\Morris\Morris\bin\Debug\Morris.exe + + + + True + + + + + + + + + + + + 11 + + + + + $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets + + + + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets + + + + + + \ No newline at end of file diff --git a/ExternalBotTest/FSharpRandomBot.fs b/ExternalBotTest/FSharpRandomBot.fs new file mode 100644 index 0000000..9efb6c1 --- /dev/null +++ b/ExternalBotTest/FSharpRandomBot.fs @@ -0,0 +1,28 @@ +(* + * FSharpRandomBot.fs + * Copyright (c) 2016 Markus Himmel + * This file is distributed under the terms of the MIT license + *) + +namespace ExternalBotTest + +open Morris + +[] +type FSharpRandomBot() = + + let rng = System.Random () + let chooseRandom n = Seq.item (Seq.length n |> rng.Next) n + + interface IMoveProvider with + // Funktioniert exakt genauso wie das C#-Pendant + member this.GetNextMove state = + let chosen = state.BasicMoves () |> chooseRandom + + match state.IsValidMove chosen with + | MoveValidity.ClosesMill -> + [0..GameState.FIELD_SIZE - 1] + |> Seq.where (fun d -> int state.Board.[d] = int (state.NextToMove.Opponent())) + |> chooseRandom + |> chosen.WithRemove + | _ -> chosen diff --git a/ExternalBotTest/Script.fsx b/ExternalBotTest/Script.fsx new file mode 100644 index 0000000..e8b3a78 --- /dev/null +++ b/ExternalBotTest/Script.fsx @@ -0,0 +1,8 @@ +// Learn more about F# at http://fsharp.org. See the 'F# Tutorial' project +// for more guidance on F# programming. + +#load "Library1.fs" +open ExternalBotTest + +// Define your library scripting code here + diff --git a/Morris.sln b/Morris.sln index ec66193..361c3f5 100644 --- a/Morris.sln +++ b/Morris.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Morris", "Morris\Morris.csproj", "{E3CCB2E8-5840-4442-8A66-177F5DF4C4F5}" EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "ExternalBotTest", "ExternalBotTest\ExternalBotTest.fsproj", "{712DA2C7-1B88-4DDB-8B79-46AF5D5F6B19}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {E3CCB2E8-5840-4442-8A66-177F5DF4C4F5}.Debug|Any CPU.Build.0 = Debug|Any CPU {E3CCB2E8-5840-4442-8A66-177F5DF4C4F5}.Release|Any CPU.ActiveCfg = Release|Any CPU {E3CCB2E8-5840-4442-8A66-177F5DF4C4F5}.Release|Any CPU.Build.0 = Release|Any CPU + {712DA2C7-1B88-4DDB-8B79-46AF5D5F6B19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {712DA2C7-1B88-4DDB-8B79-46AF5D5F6B19}.Debug|Any CPU.Build.0 = Debug|Any CPU + {712DA2C7-1B88-4DDB-8B79-46AF5D5F6B19}.Release|Any CPU.ActiveCfg = Release|Any CPU + {712DA2C7-1B88-4DDB-8B79-46AF5D5F6B19}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Morris/ConsoleInteraction.cs b/Morris/ConsoleInteraction.cs index b4bf5f3..4455910 100644 --- a/Morris/ConsoleInteraction.cs +++ b/Morris/ConsoleInteraction.cs @@ -13,7 +13,8 @@ namespace Morris /// /// Ermöglicht Eingabe und Ausgabe der Spielsituation auf der Konsole. /// - class ConsoleInteraction : IGameStateObserver, IMoveProvider + [SelectorName("Konsole"), SingleInstance] + internal class ConsoleInteraction : IGameStateObserver, IMoveProvider { public ConsoleInteraction() { diff --git a/Morris/Controller.xaml b/Morris/Controller.xaml new file mode 100644 index 0000000..a66cc14 --- /dev/null +++ b/Morris/Controller.xaml @@ -0,0 +1,23 @@ + + + + +