⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 巫魔问题求解
💻 CPP
字号:
#include <Wum_Server/src/WorldModel.h>
#include <Wum_Server/src/AlgorithmInterface.h>
#include <Wum_Server/src/GameEngine.h>
#include <Wum_Graphics/src/GKernel.h>
#include <Wum_Algorithm/src/WorldModel.h>
#include <Wum_Algorithm/src/Perceptor.h>
#include <Wum_Algorithm/src/Effector.h>
#include <Wum_Algorithm/src/Thinker.h>
#include <Wum_Algorithm/src/Plan.h>
#include <iostream>

_server::GameEngine *afxpGE;
_server::AlgorithmInterface *afxpAI;
_algorithm::WorldModel *afxpWM;
_algorithm::Effector *afxpEff;
_algorithm::Perceptor *afxpPer;
_algorithm::Plan *afxpPlan;

void update(void);
void plan(void);
void print(void);
void save(void);

/////////////////////////////////////////////////////
int main(int argc, char *argv[])
{
    _server::GameEngine afxGE;
    _server::AlgorithmInterface afxAI(afxGE);
    _algorithm::WorldModel afxWM(4,4);
    _algorithm::Effector afxEff(afxAI);
    _algorithm::Perceptor afxPer(afxWM, afxAI);
    _algorithm::Plan afxPlan(afxWM, afxEff);
    afxpGE = &afxGE;
    afxpAI = &afxAI;
    afxpEff = &afxEff;
    afxpPer = &afxPer;
    afxpPlan = &afxPlan;

    if (argc == 2)
    {
        afxGE.Reset(argv[1]);
    }
    else
    {
        afxGE.Reset(4,4);
    }
    _graphics::GKernel::TheGKernel().BindExplorer(afxGE.TheWorldModel().TheExplorer());
    _graphics::GKernel::TheGKernel().BindGameEngine(afxGE);
    _graphics::GKernel::TheGKernel().BindBMP_Explorer(_server::Explorer::ED_Up,     "Cell_Up");
    _graphics::GKernel::TheGKernel().BindBMP_Explorer(_server::Explorer::ED_Down,   "Cell_Down");
    _graphics::GKernel::TheGKernel().BindBMP_Explorer(_server::Explorer::ED_Left,   "Cell_Left");
    _graphics::GKernel::TheGKernel().BindBMP_Explorer(_server::Explorer::ED_Right,  "Cell_Right");
    _graphics::GKernel::TheGKernel().BindBMP(_base::Cell::CT_None     | _base::Cell::CT_HasCame, "Cell_None");
    _graphics::GKernel::TheGKernel().BindBMP(_base::Cell::CT_Wumpus   | _base::Cell::CT_HasCame, "Cell_Wumpus");
    _graphics::GKernel::TheGKernel().BindBMP(_base::Cell::CT_Trap     | _base::Cell::CT_HasCame, "Cell_Trap");
    _graphics::GKernel::TheGKernel().BindBMP(_base::Cell::CT_Gold     | _base::Cell::CT_HasCame, "Cell_Gold");

    _graphics::GKernel::TheGKernel().BindBMP(_base::Cell::CT_None,    "Cell_None_1");
    _graphics::GKernel::TheGKernel().BindBMP(_base::Cell::CT_Wumpus,  "Cell_Wumpus_1");
    _graphics::GKernel::TheGKernel().BindBMP(_base::Cell::CT_Trap,    "Cell_Trap_1");
    _graphics::GKernel::TheGKernel().BindBMP(_base::Cell::CT_Gold,    "Cell_Gold_1");

    _graphics::GKernel::TheGKernel().RegistMouseFunction(GLUT_LEFT_BUTTON, GLUT_DOWN, update);
    _graphics::GKernel::TheGKernel().RegistMouseFunction(GLUT_LEFT_BUTTON, GLUT_DOWN, plan);
    _graphics::GKernel::TheGKernel().RegistMouseFunction(GLUT_LEFT_BUTTON, GLUT_DOWN, print);

    _graphics::GKernel::TheGKernel().RegistKeyFunction('s', save);
    print();
    _graphics::GKernel::TheGKernel().MainLoop();
    return 1;
}

void update(void)
{
    afxpPer->UpdateWorldModel();
}

void plan(void)
{
    afxpPlan->Step();
}

void print(void)
{
    afxpAI->Update();
    std::cout << std::endl << "##############New Step################" << std::endl;
    std::cout << "Score:" << afxpGE->GetScore() << std::endl
        << "Breeze:" << afxpAI->TheServerToClient().mIsBreeze  << std::endl
        << "Stench:" << afxpAI->TheServerToClient().mIsStench  << std::endl
        << "Gleam:"  << afxpAI->TheServerToClient().mIsGleam   << std::endl
        << "Howl:"   << afxpAI->TheServerToClient().mIsHowl    << std::endl
        << "Bump:"   << afxpAI->TheServerToClient().mIsBump    << std::endl
        << "X:"      << afxpAI->TheServerToClient().mPositionX << std::endl
        << "Y:"      << afxpAI->TheServerToClient().mPositionY << std::endl
        << std::endl;
}

void save(void)
{
    afxpGE->TheWorldModel().TheServerMap().Save("SavedMap_1.map");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -