Skip to content

Instantly share code, notes, and snippets.

View R3DHULK's full-sized avatar
🏠
Working from home

Sumalya Chatterjee R3DHULK

🏠
Working from home
View GitHub Profile
@R3DHULK
R3DHULK / simon_says.py
Created March 8, 2023 18:40
Text Based Simon Says Written In Python
import random
import time
def simon_says():
# Define the colors
colors = ["red", "green", "blue", "yellow"]
# Keep track of the sequence
sequence = []
@R3DHULK
R3DHULK / tic-tac-toe-gui.py
Created March 8, 2023 18:34
Tic Tac Toe Game In Gui In Python
import tkinter as tk
class TicTacToe:
def __init__(self):
self.board = [" "] * 9
self.players = ["X", "O"]
self.current_player = 0
self.game_over = False
self.root = tk.Tk()
@R3DHULK
R3DHULK / tic-tac-toe.py
Created March 8, 2023 18:17
Cli Based Tic Tac Toe Game In Python
def print_board(board):
print(" " + board[0] + " | " + board[1] + " | " + board[2])
print("---|---|---")
print(" " + board[3] + " | " + board[4] + " | " + board[5])
print("---|---|---")
print(" " + board[6] + " | " + board[7] + " | " + board[8])
def check_win(board):
# Check rows
for i in range(0, 9, 3):
@R3DHULK
R3DHULK / roller-coaster-simulator.r
Created March 8, 2023 18:01
Text Based Roller Coaster Simulator In R
# Roller Coaster Simulator
# Define track
track <- c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
# Define cart position and speed
cart_pos <- 0
cart_speed <- 0
# Define game loop
@R3DHULK
R3DHULK / temple-run.r
Created March 8, 2023 17:36
Text Based Temple Run Game In R
# Set up initial game parameters
player_distance <- 0
obstacle_distance <- 20
game_over <- FALSE
# Define functions for game mechanics
move_player <- function(distance) {
player_distance <<- player_distance + distance
cat(sprintf("You ran %d meters.\n", distance))
}
@R3DHULK
R3DHULK / island-survival-game.r
Created March 8, 2023 17:31
Text Based Island Survival Game In R
# Set up initial island parameters
water_level <- 10
coconut_trees <- 20
coconuts <- sample(5:15, coconut_trees, replace = TRUE)
player_hunger <- 0
player_health <- 5
# Define functions for game mechanics
grow_coconuts <- function() {
coconuts <<- coconuts + rnorm(coconut_trees, mean = 0.5, sd = 0.2)
@R3DHULK
R3DHULK / desert-survival-game.r
Created March 8, 2023 17:20
Text Based Desert Survival Game In R
# Set up initial desert parameters
water_level <- 10
cactus_plants <- 20
cactus_heights <- sample(5:15, cactus_plants, replace = TRUE)
player_hunger <- 0
player_health <- 5
# Define functions for game mechanics
grow_cacti <- function() {
cactus_heights <<- cactus_heights + rnorm(cactus_plants, mean = 0.5, sd = 0.2)
@R3DHULK
R3DHULK / forest-survival-game.r
Created March 8, 2023 17:14
Text Based Forest Survival Game Written In R
# Set up initial forest parameters
num_trees <- 50
tree_heights <- sample(10:30, num_trees, replace = TRUE)
tree_health <- sample(1:5, num_trees, replace = TRUE)
player_hunger <- 0
player_health <- 5
# Define functions for game mechanics
grow_trees <- function() {
tree_heights <<- tree_heights + rnorm(num_trees, mean = 0.5, sd = 0.2)
@R3DHULK
R3DHULK / forest.r
Created March 8, 2023 17:11
Text Based Forest Simulator In R
# Set up initial forest parameters
num_trees <- 50
tree_heights <- sample(10:30, num_trees, replace = TRUE)
tree_health <- sample(1:5, num_trees, replace = TRUE)
# Define functions for game mechanics
grow_trees <- function() {
tree_heights <<- tree_heights + rnorm(num_trees, mean = 0.5, sd = 0.2)
tree_heights[tree_heights < 0] <<- 0 # make sure heights don't go below zero
}
@R3DHULK
R3DHULK / sumo-wrestling-game.r
Created March 8, 2023 17:02
Text Based Sumo Wrestling Game In R
# Define the wrestlers
wrestler1 <- list(name = "Yokozuna", strength = 8, agility = 5, stamina = 6)
wrestler2 <- list(name = "Mongolian Giant", strength = 9, agility = 4, stamina = 5)
# Define the match settings
rounds <- 3
winning_rounds <- ceiling(rounds / 2)
# Define the function to simulate a round of the match
simulate_round <- function(wrestler1, wrestler2) {