{ "cells": [ { "cell_type": "markdown", "id": "8f064d69", "metadata": {}, "source": [ "# Gymnasium sampling\n", "For the Frozenlake, Cliffwalking, and Taxi models, we were able to access the internal state of the gym environments to convert it to an accurate stormvogel model. However, this is not the case for arbitrary gym environments, hence we can use sampling to get an approximation of the gym envrironment in stormvogel. In this notebook we give some example usages of gymnasium sampling from `stormvogel.extensions`. Note that sampling is actually quite fast, but the visualization gets slow quickly when the amount of states increases.\n", "\n", "* `sample_gym` samples a gym environment and gives the result as 5 defaultdicts and an integer.\n", "* `sample_to_stormvogel` converts such a sample to a stormvogel model.\n", "* `sample_gym_to_stormvogel` combines the two for convenience." ] }, { "cell_type": "markdown", "id": "87010f68", "metadata": {}, "source": [ "## FrozenLake\n", "Since FrozenLake does not have too many states, and it is fully observable, we are actually very likely to get the correct model if we use enough samples. If you lower the sample rate, you will observe that at some point, transitions and states will disappear. You can also enable is_slippery. You will then get an approximation of the FrozenLake with slipping ice." ] }, { "cell_type": "code", "execution_count": 1, "id": "2c57e59e", "metadata": { "execution": { "iopub.execute_input": "2026-03-26T10:48:24.041461Z", "iopub.status.busy": "2026-03-26T10:48:24.041262Z", "iopub.status.idle": "2026-03-26T10:48:24.460945Z", "shell.execute_reply": "2026-03-26T10:48:24.460383Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ModelType.MDP model with 16 states, 5 actions, and 18 distinct labels.\n" ] }, { "data": { "text/html": [ "\n", "\n", "\n", "
\n", "