Skip to content

Instantly share code, notes, and snippets.

/*
* Deep Q-Learning (DQN) for FrozenLake-v1 (8x8)
* A Deep Q-Learning implementation matching
* the OpenAI Gym "FrozenLake-v1" configuration. Features a custom
* Multi-Layer Perceptron (MLP), Target Network synchronization, and
* Experience Replay. Mathematical optimizations are used for the input
* layer to simulate one-hot encoding without matrix multiplication.
*
* Gym Dynamics:
* - Action 0 (Left): 1/3 Left, 1/3 Down, 1/3 Up
@dask-58
dask-58 / frozen_lake_ql.cpp
Last active February 27, 2026 10:27
A Q-Learning implementation matching OpenAI Gym "FrozenLake-v1"
/*
* Q-Learning for FrozenLake-v1 (8x8)
* Object-oriented C++ implementation of tabular
* Q-Learning matching the OpenAI Gym "FrozenLake-v1" configuration.
* The environment features a slippery surface where intended actions only
* execute 33.3% of the time, with the remaining 66.6% split between
* perpendicular directions.
*
* Gym Dynamics:
* - Action 0 (Left): 1/3 Left, 1/3 Down, 1/3 Up
#!/bin/bash
echo "Compiling Sol.cpp ..."
g++ -Wall -Wl,-stack_size,20000000 -O2 -o Sol Sol.cpp
if [ $? -eq 0 ]; then
echo "Compilation done!"
else
echo "Compilation failed!"
exit 1