2013-10-01 52 views
-4

我有這個C#類和我想要實現這個在F#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 this.cboard = board 
        member this.level = level 
        member this.symbol = symbol 

[錯誤這裏] 定義中的此點或之前的不完整結構化構造 。在此點或其他標記之前或之前構建的預期不完整結構 。

+1

東西在猜測,它顯示了很少的研究工作。 –

回答

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 
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