[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GO engine interface



Hi, there,

I were using Borland C++ Builder to write GO GUI for easy coding, and using
MS VC++ to write GO Engine for easy debugging. The GUI accesses the Engine
only through an interface class AbsGO:

// -------------------------------------------------------------------------
--
#ifndef AbsGoH
#define AbsGoH
// -------------------------------------------------------------------------
--
class AbsGO
{
public:
    AbsGO() {};
    virtual ~AbsGO() {};

    // game playing interface
    virtual bool GameStart(int iHandicap, int  iBoardSize)=0;
    virtual bool GameBoard(int& iPlayer,  int  iX, int  iY)=0;
    virtual bool LastMove (int& iPlayer,  int& iX, int& iY)=0;
    virtual bool IsLegalMove(int iX, int iY)=0;
    virtual bool HasStoneKilled()=0;
    virtual bool IsGameEnd()=0;

    virtual bool MoveTo(int iPlayer, int iX, int iY)=0;
    virtual bool Suggestion(int iPlayer, int& iX, int& iY)=0;
    virtual bool BackOneMove()=0;

    virtual bool ScoreGame(int& iBlackScore, int& iWhiteScore)=0;
    virtual bool SaveGame(char* sFile, int iStyle = 0)=0;
    virtual bool LoadGame(char* sFile)=0;

    // informational
    virtual bool InternalStatus(int iBoardType,
                                double& dPositionValue,
                                int iX,
                                int iY)=0;
    virtual bool EngineLoaded()=0;

    // machine learning interface
    virtual bool BatchLearn(char* sFile, int iMethod)=0;
    virtual bool SaveLearnt(char* sFile, int iMethod)=0;
    virtual bool LoadLearnt(char* sFile, int iMethod)=0;
};
#endif

For my implementation, the above interface class seems good enough. If a GO
environment or a UI object has similar interface, change an Engine or a UI
should not be a pain.

Some suggestions?

Weimin