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 / bike-racing-game.py
Created March 8, 2023 19:38
Text Based Bike Racing Game In Python
import random
class Bike:
def __init__(self, name, speed):
self.name = name
self.speed = speed
self.distance = 0
def move(self):
self.distance += self.speed * random.randint(1, 5)
@R3DHULK
R3DHULK / bike-racing-game.r
Created March 8, 2023 19:36
Text Based Bike Racing Game In R
bike1 <- list(name = "Bike 1", speed = 20, distance = 0)
bike2 <- list(name = "Bike 2", speed = 25, distance = 0)
bike3 <- list(name = "Bike 3", speed = 18, distance = 0)
move_bike <- function(bike) {
bike$distance <- bike$distance + bike$speed * sample(1:5, 1)
}
print_position <- function(bike) {
cat(paste(bike$name, "is at position", bike$distance, ".\n"))
@R3DHULK
R3DHULK / car-racing-game.py
Created March 8, 2023 19:34
Text Based Car Racing Game In Python
import random
class Car:
def __init__(self, name, speed):
self.name = name
self.speed = speed
self.distance = 0
def move(self):
@R3DHULK
R3DHULK / monster-battle.py
Created March 8, 2023 19:31
Text Based Monster Battle Game In Python
import random
# Monster class
class Monster:
def __init__(self, name, health, attack):
self.name = name
self.health = health
self.attack = attack
@R3DHULK
R3DHULK / battleship.py
Created March 8, 2023 19:27
Text Based Battleship Game Written In Python
from random import randint
board = []
# Create the board
for x in range(5):
board.append(["O"] * 5)
# Function to print the board
@R3DHULK
R3DHULK / virtual-pet-game.py
Created March 8, 2023 19:22
Text Based Virtual Pet Game In Python
import random
import time
# Virtual Pet Class
class VirtualPet:
def __init__(self, name):
self.name = name
self.hunger = 50
@R3DHULK
R3DHULK / hangman.py
Created March 8, 2023 19:10
Text Based Hangman In Python
# Python Program to illustrate
# Hangman Game
import random
from collections import Counter
print(" Hangman")
print("======================================\n")
someWords = '''apple banana mango strawberry orange grape pineapple apricot lemon coconut watermelon cherry papaya berry peach lychee muskmelon'''
someWords = someWords.split(' ')
# randomly choose a secret word from our "someWords" LIST.
@R3DHULK
R3DHULK / snake.py
Created March 8, 2023 18:58
Text Based Snake Game Written In Python
import random
import os
import time
# Define the game constants
BOARD_WIDTH = 20
BOARD_HEIGHT = 10
SNAKE_INITIAL_LENGTH = 3
SNAKE_INITIAL_X = BOARD_WIDTH // 2
SNAKE_INITIAL_Y = BOARD_HEIGHT // 2
@R3DHULK
R3DHULK / minesweeper.py
Created March 8, 2023 18:52
Text Based Minesweeper Game In Python
import random
# Define the game board
board_size = 5
num_mines = 5
board = [[0 for x in range(board_size)] for y in range(board_size)]
# Place the mines
for i in range(num_mines):
x = random.randint(0, board_size - 1)
@R3DHULK
R3DHULK / trivia.py
Created March 8, 2023 18:45
Text Based Trivia Game In Python
import random
# Define the questions
questions = {
"What is the capital of France?": "Paris",
"What is the largest planet in our solar system?": "Jupiter",
"Who wrote the Harry Potter book series?": "J.K. Rowling",
"What is the largest country in the world?": "Russia",
"What is the highest mountain in the world?": "Mount Everest"
}