Add controller, external assembly loading and other fancy things

This commit is contained in:
Markus Himmel
2016-08-28 23:35:28 +02:00
parent c3abbf6966
commit ee4db90b0d
21 changed files with 560 additions and 20 deletions

View File

@@ -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
[<SelectorName("F# KI")>]
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