Skip to content

Commit

Permalink
Merge pull request #14 from datvodinh10/main
Browse files Browse the repository at this point in the history
fix bug
  • Loading branch information
ngoxuanphong authored May 11, 2023
2 parents 3100332 + 762c485 commit b02b53f
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Base/Imploding_Kitten/_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def getAgentState(env, draw_pile, discard_pile):
card = np.zeros(19)
card[int(getCardType(env[91 + i]))] = 1
state[
37 + 19 * i : 56 + 19 * i
38 + 19 * i : 57 + 19 * i
] = card # three card if use see the future
state[100] = np.maximum(env[90], 0) # number of card player have to draw

Expand Down Expand Up @@ -779,9 +779,7 @@ def stepEnv(env, draw_pile, discard_pile, action):
index_future = np.where(draw_pile != -1)[0]
if index_future.shape[0] >= 3:
if act>0:
draw_pile_2 = draw_pile.copy()
for i in range(3):
draw_pile[index_future[i]] = draw_pile_2[index_future[0:3]][list_change[act][i]]
draw_pile[index_future[0:3]] = env[91:94]
elif index_future.shape[0] == 2:
if act == 2:
draw_pile[index_future] = draw_pile[index_future][np.array([1, 0])]
Expand Down
97 changes: 97 additions & 0 deletions main.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from setup import make\n",
"env = make(\"Imploding_Kitten\")"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e44feb732034491eba43d57c2e098ff9",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(Output(), HBox(children=(Dropdown(layout=Layout(width='20%'), options=('Take an action', 2, 3, …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"env.render(Agent=\"human\", per_data=[0], level=0, max_temp_frame=100)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"a = np.array([1,1,1,0,0,1,1])"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"5"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.where(a==1)[0][3]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "pytorchenv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit b02b53f

Please sign in to comment.