Skip to content

Instantly share code, notes, and snippets.

View harshkumarchourasia's full-sized avatar

Harsh Kumar Chourasia harshkumarchourasia

View GitHub Profile
@harshkumarchourasia
harshkumarchourasia / record_episode.py
Created October 25, 2024 12:37
This script simulates and records every 10th episode of the CartPole environment in OpenAI Gym, saving videos in the ./vid directory. Each episode runs until completion with random actions, then resets for the next.​⬤
import gym
# Initialize the CartPole environment with rendering mode set to 'rgb_array'
env = gym.make('CartPole-v0', render_mode="rgb_array")
# Wrap the environment with the RecordVideo wrapper to record videos
# The episode_trigger lambda function ensures that a video is recorded every 10 episodes
env = gym.wrappers.RecordVideo(env, "./vid", episode_trigger=lambda episode_id: episode_id % 10 == 0)
# Reset the environment to get the initial observation and additional info
# dependency inversion principle
##########################################
class FXConverter:
def convert(self, from_currency, to_currency, amount):
print(f'{amount} {from_currency} = {amount * 1.2} {to_currency}')
return amount * 1.2
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface OracleInterface{
function receiveRequest() external returns (uint256);
}
contract BaseContract{
uint public randomNumber = 0;
OracleInterface public obj;
mapping(uint256=>bool) myRequests;