From 762c4855471621732ca25bae6ccd2ab7d0348c12 Mon Sep 17 00:00:00 2001 From: IamVDD Date: Thu, 11 May 2023 11:32:54 +0700 Subject: [PATCH] fix bug --- Base/Imploding_Kitten/_env.py | 6 +-- main.ipynb | 97 +++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 main.ipynb diff --git a/Base/Imploding_Kitten/_env.py b/Base/Imploding_Kitten/_env.py index a6b4c7a..9746453 100644 --- a/Base/Imploding_Kitten/_env.py +++ b/Base/Imploding_Kitten/_env.py @@ -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 @@ -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])] diff --git a/main.ipynb b/main.ipynb new file mode 100644 index 0000000..1e71dd6 --- /dev/null +++ b/main.ipynb @@ -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 +}