访问不同模块中的类

时间:2013-10-03 06:01:25

标签: class f#

注意:4天前开始F#所以请在给予否定投票之前考虑一下。或者至少让我知道我做错了什么来接受所有负面投票。

  

Inteligence.fs

module Inteligence
open TTTAiFSharpAlphaBeta
open Boards

type Node(board: Board, moveBox :int, point:int)=
    let mutable _moveBox:int=moveBox
    let mutable _point:int=point
    let mutable _board=new Board(board)
    let mutable _parent= board

    new() = Node(new Board(),0,0)
    new(board: Board)= new Node(new Board(board),0,0)

    member this.MoveBox with get() = _moveBox and set(value) = _moveBox <- value
    member this.Point with get() = _point and set(value) = _point <- value
    member this.Board with get() = _board and set(value) = _board <- value
    member this.Parent with get() = _parent and set(value) = _parent <- value

    member this.Copy(node: Node)= 
             _board<- new Board(node.Board)
             _moveBox<- node.MoveBox
             _point<- node.Point
             _parent<- node.Parent




type Inteligence(board:Board,symbol:int)=
    let mutable _nodeCount=0;
    let mutable _rootNode= new Node(board)
    let mutable _level = 0
    let mutable _symbol = symbol
    let mutable _reff = new Boards.Reffery()

    member this.NodeCount with get() = _nodeCount and set(value) = _nodeCount <- value
    member this.RootNode with get() = _rootNode and set(value) = _rootNode <- value
    member this.Level with get() = _level and set(value) = _level <- value
    member this.Symbol with get() = _symbol and set(value) = _symbol <- value

    member this.Move() :int = 0
    member this.MinMaxAlphaBeta(node:Node, min:bool,  alpha:int,  beta:int):int=0
    member this.BoardPoint(node:Node):int=0
  

AI.fs

    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#AlphaBetaAi"
                member this.GetAiVersion()="0.0.1"
                member this.GetLevel()= [| 3 |];
                member this.AiMove()=
                           Inteligence.Inteligence(cboard,symbol).Move()

问题是我无法访问

Move()

来自Inteligence.fs

member this.AiMove()=
         Inteligence.Inteligence(cboard,symbol).Move()
AI中的

获取错误未定义名称空间或模块“Inteligence” 我做错了什么?

1 个答案:

答案 0 :(得分:2)

我猜您正在使用fsi(来自#r)。

如果您需要使用

#load "Intelligence.fs"

如果在visual studio中你需要确保Intelligence.fs在项目列表中的另一个文件之前(F#对编译的订单文件很敏感)