Skip to content

Commit

Permalink
fix(pu): fix emplace_back
Browse files Browse the repository at this point in the history
  • Loading branch information
puyuan1996 committed Nov 13, 2023
1 parent 86e5c72 commit ba2fd6e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
12 changes: 6 additions & 6 deletions lzero/mcts/ctree/ctree_sampled_efficientzero/lib/cnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,12 @@ namespace tree
// After sorting, the first vector is the index, and the second vector is the probability value after perturbation sorted from large to small.
for (size_t iter = 0; iter < disturbed_probs.size(); iter++)
{
// #ifdef __APPLE__
// disc_action_with_probs.__emplace_back(std::make_pair(iter, disturbed_probs[iter]));
// #else
// disc_action_with_probs.emplace_back(std::make_pair(iter, disturbed_probs[iter]));
// #endif
disc_action_with_probs.emplace_back(std::make_pair(iter, disturbed_probs[iter]));
#ifdef __APPLE__
disc_action_with_probs.__emplace_back(std::make_pair(iter, disturbed_probs[iter]));
#else
disc_action_with_probs.emplace_back(std::make_pair(iter, disturbed_probs[iter]));
#endif
// disc_action_with_probs.emplace_back(std::make_pair(iter, disturbed_probs[iter]));
}

std::sort(disc_action_with_probs.begin(), disc_action_with_probs.end(), cmp);
Expand Down
13 changes: 3 additions & 10 deletions zoo/board_games/gomoku/envs/gomoku_env.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,25 @@
import copy
import itertools
import os
import random
import sys
from functools import lru_cache
from typing import List, Any

import gym
import imageio
import matplotlib.patches as patches
import matplotlib.pyplot as plt
import numpy as np
import pygame
from ding.envs import BaseEnv, BaseEnvTimestep
from ding.utils import ENV_REGISTRY
from ditk import logging
from easydict import EasyDict
from matplotlib import pyplot as plt
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from zoo.board_games.gomoku.envs.legal_actions_cython import legal_actions_cython
from zoo.board_games.gomoku.envs.get_done_winner_cython import get_done_winner_cython
from zoo.board_games.gomoku.envs.legal_actions_cython import legal_actions_cython

from zoo.board_games.alphabeta_pruning_bot import AlphaBetaPruningBot
from zoo.board_games.connect4.envs.connect4_env import Connect4Env
from zoo.board_games.gomoku.envs.gomoku_rule_bot_v0 import GomokuRuleBotV0
from zoo.board_games.gomoku.envs.gomoku_rule_bot_v1 import GomokuRuleBotV1
from zoo.board_games.gomoku.envs.utils import check_action_to_special_connect4_case1, \
check_action_to_special_connect4_case2, \
check_action_to_connect4


@lru_cache(maxsize=512)
Expand Down
2 changes: 1 addition & 1 deletion zoo/board_games/gomoku/envs/gomoku_rule_bot_v0.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class GomokuRuleBotV0:
forming a sequence of 4, forming a sequence of 3, forming a sequence of 2, and a random move.
"""

def __init__(self, env: Any, player: int, search_only_in_neighbor: bool = True) -> None:
def __init__(self, env: Any, player: int, search_only_in_neighbor: bool = False) -> None:
"""
Overview:
Initializes the bot with the game environment and the player it represents.
Expand Down
4 changes: 2 additions & 2 deletions zoo/board_games/gomoku/envs/test_gomoku_rule_bot_v0.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_naive(self):
print('action index of player 1 is:', action)
print('player 1: ' + env.action_to_string(action))
obs, reward, done, info = env.step(action)
env.render('image_realtime_mode')
# env.render('image_realtime_mode')
if done:
print('=' * 20)
if reward > 0:
Expand All @@ -52,7 +52,7 @@ def test_naive(self):
print('action index of player 2 is:', action)
print('player 2: ' + env.action_to_string(action))
obs, reward, done, info = env.step(action)
env.render('image_realtime_mode')
# env.render('image_realtime_mode')
if done:
print('=' * 20)
if reward > 0:
Expand Down

0 comments on commit ba2fd6e

Please sign in to comment.