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 / tank-game.py
Created March 8, 2023 20:37
Text Based Another Tank Game In Python
import random
class Tank:
def __init__(self, name):
self.name = name
self.ammo = 10
self.health = 100
def fire_at(self, target):
if self.ammo > 0:
@R3DHULK
R3DHULK / tank-game.py
Created March 8, 2023 20:36
Text Based Tank Game In Python
import random
class Tank:
def __init__(self, name):
self.name = name
self.health = 100
self.ammo = 5
self.armor = 60
def shoot(self):
@R3DHULK
R3DHULK / tank-game.r
Created March 8, 2023 20:25
Text Based Tank Game Written In R
# Define the tank class
Tank <- function(health, armor, damage) {
list(
health = health,
armor = armor,
damage = damage
)
}
# Define the game function
@R3DHULK
R3DHULK / desert-survival-game.py
Created March 8, 2023 20:21
Text Based Desert Survival Game In Python
import random
import time
# Define player class
class Player:
def __init__(self):
self.health = 100
self.thirst = 0
@R3DHULK
R3DHULK / island-survival-game.py
Created March 8, 2023 20:15
Text Based Island Survival Game In Python
import random
import time
# Define player class
class Player:
def __init__(self):
self.health = 100
self.hunger = 0
@R3DHULK
R3DHULK / forest-survival-game.py
Created March 8, 2023 20:12
Text Based Forest Survival Game In Python
import random
import time
# Define player class
class Player:
def __init__(self):
self.health = 100
self.hunger = 0
self.thirst = 0
self.shelter = False
@R3DHULK
R3DHULK / rock-paper-scissor.py
Created March 8, 2023 20:04
Simple Text Based Rock Paper Scissor Game In Python
import random
# Define the options
options = ["rock", "paper", "scissors"]
# Initialize the score
player_score = 0
computer_score = 0
# Play the game
@R3DHULK
R3DHULK / cowboy.py
Created March 8, 2023 19:52
Text Based Cowboy Game In Python
import random
print("Welcome To Cowboy Game.\nYou are a cowboy.")
class Cowboy:
def __init__(self, name):
self.name = name
self.health = 100
self.ammo = 6
@R3DHULK
R3DHULK / football-game.py
Created March 8, 2023 19:45
Simple Text Based Football Game In Python
import random
class Team:
def __init__(self, name, offense, defense):
self.name = name
self.offense = offense
self.defense = defense
self.score = 0
@R3DHULK
R3DHULK / towerofhanoi.py
Created March 8, 2023 19:42
Text Based Tower Of Hanoi In Python
def hanoi(n, source, auxiliary, target):
if n > 0:
# Move n-1 discs from source to auxiliary
hanoi(n-1, source, target, auxiliary)
# Move the nth disc from source to target
print(f"Move disk {n} from {source} to {target}")
# Move the n-1 discs from auxiliary to target
hanoi(n-1, auxiliary, source, target)