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

📄 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 afxGE;
_server::AlgorithmInterface afxAI(afxGE);
_algorithm::WorldModel afxWM(4,4);
_algorithm::Effector afxEff(afxAI);

void GoAhead(void);
void TurnLeft(void);
void TurnRight(void);
void Shoot(void);
void Escape(void);
void Print(void);

/////////////////////////////////////////////////////
int main(void)
{
    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");
#if 1
    _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_None");
    _graphics::GKernel::TheGKernel().BindBMP(_base::Cell::CT_Trap     | _base::Cell::CT_HasCame, "Cell_None");
    _graphics::GKernel::TheGKernel().BindBMP(_base::Cell::CT_Gold     | _base::Cell::CT_HasCame, "Cell_None");

    _graphics::GKernel::TheGKernel().BindBMP(_base::Cell::CT_None,    "Cell_None_1");
    _graphics::GKernel::TheGKernel().BindBMP(_base::Cell::CT_Wumpus,  "Cell_None_1");
    _graphics::GKernel::TheGKernel().BindBMP(_base::Cell::CT_Trap,    "Cell_None_1");
    _graphics::GKernel::TheGKernel().BindBMP(_base::Cell::CT_Gold,    "Cell_None_1");
#else
    _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_None"*/"Cell_Wumpus");
    _graphics::GKernel::TheGKernel().BindBMP(_base::Cell::CT_Trap     | _base::Cell::CT_HasCame, /*"Cell_None"*/"Cell_Trap");
    _graphics::GKernel::TheGKernel().BindBMP(_base::Cell::CT_Gold     | _base::Cell::CT_HasCame, /*"Cell_None"*/"Cell_Gold");

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

#endif

    _graphics::GKernel::TheGKernel().RegistKeyFunction('w', GoAhead);
    _graphics::GKernel::TheGKernel().RegistKeyFunction('a', TurnLeft);
    _graphics::GKernel::TheGKernel().RegistKeyFunction('d', TurnRight);
    _graphics::GKernel::TheGKernel().RegistKeyFunction('s', Shoot);
    _graphics::GKernel::TheGKernel().RegistKeyFunction('q', Escape);
    _graphics::GKernel::TheGKernel().RegistKeyFunction_All(Print);
    _graphics::GKernel::TheGKernel().MainLoop();
    return 1;
}

void GoAhead(void)
{
    afxEff.GoAhead();
}

void TurnLeft(void)
{
    afxEff.TurnLeft();
}

void TurnRight(void)
{
    afxEff.TurnRight();
}

void Shoot(void)
{
    afxEff.Shoot();
}

void Escape(void)
{
    afxEff.Escape();
}

void Print(void)
{
    afxAI.Update();
    std::cout << "Score:" << afxGE.GetScore() << std::endl
        << "Breeze:" << afxAI.TheServerToClient().mIsBreeze << std::endl
        << "Stench:" << afxAI.TheServerToClient().mIsStench << std::endl
        << "Gleam:"  << afxAI.TheServerToClient().mIsGleam  << std::endl
        << "Howl:"   << afxAI.TheServerToClient().mIsHowl   << std::endl
        << "Bump:"   << afxAI.TheServerToClient().mIsBump   << std::endl
        << std::endl;
}

⌨️ 快捷键说明

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