当前位置: 首页>>代码示例>>C++>>正文


C++ DoomGame::setDoomGamePath方法代码示例

本文整理汇总了C++中DoomGame::setDoomGamePath方法的典型用法代码示例。如果您正苦于以下问题:C++ DoomGame::setDoomGamePath方法的具体用法?C++ DoomGame::setDoomGamePath怎么用?C++ DoomGame::setDoomGamePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DoomGame的用法示例。


在下文中一共展示了DoomGame::setDoomGamePath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(){

    std::cout << "\n\nCIG HOST EXAMPLE\n\n";


    DoomGame* game = new DoomGame();

    // Use CIG example config or Your own.
    game->loadConfig("../../scenarios/cig.cfg");

    // Select game and map You want to use.
    game->setDoomGamePath("../../scenarios/freedoom2.wad");
    //game->setDoomGamePath("../../scenarios/doom2.wad");      // Not provided with environment due to licences.

    game->setDoomMap("map01");      // Limited deathmatch.
    //game->setDoomMap("map02");      // Full deathmatch.

    // Host game with options that will be used in the competition.
    game->addGameArgs("-host 8 "                // This machine will function as a host for a multiplayer game with this many players (including this machine). It will wait for other machines to connect using the -join parameter and then start the game when everyone is connected.
                      "-deathmatch "            // Deathmatch rules are used for the game.
                      "+timelimit 10.0 "        // The game (episode) will end after this many minutes have elapsed.
                      "+sv_forcerespawn 1 "     // Players will respawn automatically after they die.
                      "+sv_noautoaim 1 "        // Autoaim is disabled for all players.
                      "+sv_respawnprotect 1 "   // Players will be invulnerable for two second after spawning.
                      "+sv_spawnfarthest 1 "    // Players will be spawned as far as possible from any other players.
                      "+viz_nocheat 1");        // Disables depth buffer and the ability to use commands that could interfere with multiplayer game.

    // Name your agent and select color
    // colors: 0 - green, 1 - gray, 2 - brown, 3 - red, 4 - light gray, 5 - light brown, 6 - light red, 7 - light blue
    game->addGameArgs("+name AI +colorset 0");


    game->setMode(ASYNC_PLAYER);
    game->init();

    while(!game->isEpisodeFinished()){          // Play until the game (episode) is over.

        if(game->isPlayerDead()){
            game->respawnPlayer();              // Use this to respawn immediately after death, new state will be available.

            // Or observe the game until automatic respawn.
            //game->advanceAction();
            //continue;
        }

        GameStatePtr state = game->getState();
        // Analyze the state.

        std::vector<int> action(game->getAvailableButtonsSize());
        // Set your action.

        game->makeAction(action);

        std::cout << game->getEpisodeTime() << " Frags: " << game->getGameVariable(FRAGCOUNT) << std::endl;
    }

    game->close();
}
开发者ID:Marqt,项目名称:ViZDoom,代码行数:58,代码来源:CIGHost.cpp

示例2: GetObject

/*
 * Class:     DoomGame
 * Method:    setDoomGamePath
 * Signature: (Ljava/lang/String;)V
 */
JNIEXPORT void JNICALL Java_vizdoom_DoomGame_setDoomGamePath
  (JNIEnv *env, jobject obj, jstring jstr){
    try{
        DoomGame* game = GetObject(env,obj);
        JSTR_2_STR(jstr, str)
        game->setDoomGamePath(str);
    }
    catch(...){
        throwAsJavaException(env);
    }
}
开发者ID:datbdude,项目名称:ViZDoom,代码行数:16,代码来源:ViZDoomGameJava.cpp

示例3: main

int main() {

    std::cout << "\n\nBASIC EXAMPLE\n\n";


    // Create DoomGame instance. It will run the game and communicate with you.
    DoomGame *game = new DoomGame();

    // Sets path to vizdoom engine executive which will be spawned as a separate process. Default is "./vizdoom".
    game->setViZDoomPath("../../bin/vizdoom");

    // Sets path to doom2 iwad resource file which contains the actual doom game-> Default is "./doom2.wad".
    game->setDoomGamePath("../../scenarios/freedoom2.wad");
    // game->setDoomGamePath("../../scenarios/doom2.wad");   # Not provided with environment due to licences.

    // Sets path to additional resources iwad file which is basically your scenario iwad.
    // If not specified default doom2 maps will be used and it's pretty much useles... unless you want to play doom.
    game->setDoomScenarioPath("../../scenarios/basic.wad");

    // Set map to start (scenario .wad files can contain many maps).
    game->setDoomMap("map01");

    // Sets resolution. Default is 320X240
    game->setScreenResolution(RES_640X480);

    // Sets the screen buffer format. Not used here but now you can change it. Defalut is CRCGCB.
    game->setScreenFormat(RGB24);

    // Sets other rendering options
    game->setRenderHud(false);
    game->setRenderCrosshair(false);
    game->setRenderWeapon(true);
    game->setRenderDecals(false);
    game->setRenderParticles(false);

    // Adds buttons that will be allowed.
    game->addAvailableButton(MOVE_LEFT);
    game->addAvailableButton(MOVE_RIGHT);
    game->addAvailableButton(ATTACK);

    // Adds game variables that will be included in state.
    game->addAvailableGameVariable(AMMO2);

    // Causes episodes to finish after 200 tics (actions)
    game->setEpisodeTimeout(200);

    // Makes episodes start after 10 tics (~after raising the weapon)
    game->setEpisodeStartTime(10);

    // Makes the window appear (turned on by default)
    game->setWindowVisible(true);

    // Turns on the sound. (turned off by default)
    game->setSoundEnabled(true);

    // Sets ViZDoom mode (PLAYER, ASYNC_PLAYER, SPECTATOR, ASYNC_SPECTATOR, PLAYER mode is default)
    game->setMode(PLAYER);

    // Initialize the game. Further configuration won't take any effect from now on.
    game->init();


    // Define some actions. Each list entry corresponds to declared buttons:
    // MOVE_LEFT, MOVE_RIGHT, ATTACK
    // more combinations are naturally possible but only 3 are included for transparency when watching.

    std::vector<int> actions[3];
    int action0[] = {1, 0, 0};
    actions[0] = std::vector<int>(action0, action0 + sizeof(action0) / sizeof(int));

    int action1[] = {0, 1, 0};
    actions[1] = std::vector<int>(action1, action1 + sizeof(action1) / sizeof(int));

    int action2[] = {0, 0, 1};
    actions[2] = std::vector<int>(action2, action2 + sizeof(action2) / sizeof(int));

    std::srand(time(0));

    // Run this many episodes
    int episodes = 10;

    for (int i = 0; i < episodes; ++i) {

        std::cout << "Episode #" << i + 1 << "\n";

        // Starts a new episode. It is not needed right after init() but it doesn't cost much and the loop is nicer.
        game->newEpisode();

        while (!game->isEpisodeFinished()) {

            // Get the state
            GameState s = game->getState();

            // Make random action and get reward
            double r = game->makeAction(actions[std::rand() % 3]);

            // You can also get last reward by using this function
            // double r = game->getLastReward();

            std::cout << "State #" << s.number << "\n";
//.........这里部分代码省略.........
开发者ID:DeanoC,项目名称:ViZDoom,代码行数:101,代码来源:Basic.cpp


注:本文中的DoomGame::setDoomGamePath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。