-4

私はこのc#クラスを持っており、これをf#に実装したい

    using System;
    using AIInterface;
    using Boards;

    namespace TTTAiCSharpAlphaBate
    {
        public class AI : IAI
        {
            private int symbol;
            Board cBoard;
            int aiLevel = 1;
            string IAI.GetAIName()
            {
                return "C#AlphaBetaAi";
            }

            string IAI.GetAIVersion()
            {
                return "1.0.0";
            }

            void IAI.SetAI(Boards.Board board, int level, int symbol)
            {
                cBoard = board;
                this.symbol = symbol;
                aiLevel = level;

            }

            int[] IAI.GetLevel()
            {
                return new int[1] { 3 };
            }

            int IAI.AIMove()
            {
                throw new NotImplementedException();
            }
        }
    }

これまでのところ私はここまで来ました

    #if Board
    #r @"c:\..\bin\Debug\Boards.dll"
    #r @"c:\..\bin\Debug\AIInterface.dll"
    #endif
    module TTTAiFSharpAlphaBeta
    open AIInterface
    open Boards
    type AI()= 
            interface IAI with
                member this.SetAI (board: Board ,level:int, symbol:int)  =

[ここでエラー] 式に予期しないキーワード 'member' があります

                    member this.cboard = board
                    member this.level = level
                    member this.symbol = symbol

[ここでエラー] 定義のこの時点またはそれ以前の構造化構造が不完全です。この時点または他のトークンの前に不完全な構造化構造が予期されます。

4

2 に答える 2

4

C# の場合と同様に、変数のバッキング ストアを宣言する必要があります。何かのようなもの

type AI()= 
        let mutable cboard = (*Something*)
        let mutable level = 0
        let mutable symbol = 0
        interface IAI with
            member this.SetAI (_board ,_level, _symbol)  =
                cboard <- _board
                level  <- _level
                symbol <- _symbol
于 2013-10-01T04:37:22.427 に答える
0
    #if Board
    #r @"L:\..\bin\Debug\Boards.dll"
    #r @"L:\..\bin\Debug\AIInterface.dll"
    #endif
    module TTTAiFSharpAlphaBeta
    open AIInterface
    open Boards
    type AI()= 
            let mutable cboard =new Board()
            let mutable level = 0
            let mutable symbol = 0
            interface IAI with
                member this.SetAI (board: Board ,_level, _symbol)  =
                     cboard <- board
                     level  <- _level
                     symbol <- _symbol
                member this.GetAIName()="F#DumbAssAI"
                member this.GetAIVersion()="0.0.1"
                member this.GetLevel()= [| 10 |];
                member this.AIMove()=1
于 2013-10-01T05:09:08.490 に答える