# Error while initiating alpha zero

**URL:** <https://discuss.ray.io/t/error-while-initiating-alpha-zero/11081>\
**Category:** RLlib\
**Created:** [June 19, 2023, 7:47am UTC](https://discuss.ray.io/t/error-while-initiating-alpha-zero/11081 "2023-06-19T07:47:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kotha\_Sri\_Harsha](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/kotha_sri_harsha/32/4577_2.png) [@Kotha\_Sri\_Harsha](https://discuss.ray.io/u/Kotha_Sri_Harsha)\
**Post date:** [June 19, 2023, 7:47am UTC](https://discuss.ray.io/t/error-while-initiating-alpha-zero/11081/1 "2023-06-19T07:47:28Z")

</div>

**How severe does this issue affect your experience of using Ray?**

- High: It blocks me to complete my task.

While trying to initiate alphazero on ray, it throws me error.

Code:  
from ray.rllib.algorithms.alpha\_zero import AlphaZeroConfig  
config = AlphaZeroConfig()  
config = config.training(sgd\_minibatch\_size=256)  
config = config.resources(num\_gpus=0)  
config = config.rollouts(num\_rollout\_workers=4)  
print(config.to\_dict())

algo = config.build(env=“CartPole-v1”)

The code throws the following error:

~/anaconda3/envs/amazonei\_pytorch\_latest\_p37/lib/python3.7/site-packages/ray/rllib/algorithms/alpha\_zero/ranked\_rewards.py in **init** ()  
41 self.r2\_buffer = RankedRewardsBuffer(max\_buffer\_length, percentile)  
42 if r2\_config[“initialize\_buffer”]:  
—\> 43 self.\_initialize\_buffer(r2\_config[“num\_init\_rewards”])  
44  
45 def \_initialize\_buffer(self, num\_init\_rewards=100):

~/anaconda3/envs/amazonei\_pytorch\_latest\_p37/lib/python3.7/site-packages/ray/rllib/algorithms/alpha\_zero/ranked\_rewards.py in \_initialize\_buffer()  
49 terminated = truncated = False  
50 while not terminated and not truncated:  
—\> 51 mask = obs[“action\_mask”]  
52 probs = mask / mask.sum()  
53 action = np.random.choice(np.arange(mask.shape[0]), p=probs)

## IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices.

Tried changing the environments and use samples mentioned in documentation:

> **[Algorithms — Ray 2.52.0](https://docs.ray.io/en/releases-2.5.0/rllib/rllib-algorithms.html#alphazero)**

but still experiencing above error.

Is this an internal issue? Is there any way to correct it?

Any leads will be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![arturn](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/arturn/32/2096_2.png) [@arturn](https://discuss.ray.io/u/arturn)\
**Post date:** [June 20, 2023, 6:42pm UTC](https://discuss.ray.io/t/error-while-initiating-alpha-zero/11081/2 "2023-06-20T18:42:22Z")

</div>

Sorry to heart that, can you please post a full reproduction script as described in [Mini forum guide/self-help guide](https://discuss.ray.io/t/mini-forum-guide-self-help-guide/10793)? Cheers 🙂
