This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Text-based volleyball simulator game | |
# Define function to check if the ball is in bounds | |
is_in_bounds <- function(position) { | |
return(position >= 0 && position <= 10) | |
} | |
# Define function to simulate a serve | |
serve <- function() { | |
cat("Server is serving...\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Basic text-based flight simulator game in R | |
# Define starting variables | |
altitude <- 0 | |
fuel <- 100 | |
distance <- 0 | |
speed <- 0 | |
game_over <- FALSE | |
# Define functions for game actions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the teams | |
teams <- list( | |
c("Manchester United", "Red Devils", "4-4-2", 87), | |
c("Real Madrid", "Los Blancos", "4-3-3", 91), | |
c("FC Barcelona", "Blaugrana", "4-3-3", 89), | |
c("Bayern Munich", "FC Hollywood", "4-2-3-1", 88) | |
) | |
# Define a function to simulate a match | |
simulate_match <- function(home_team, away_team) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Welcome message | |
cat("Welcome to the Computer Programming Simulator Game!\n") | |
cat("In this game, you'll be writing code to complete various programming challenges.\n") | |
cat("You'll earn points for each completed challenge, and you'll progress through different levels as you earn more points.\n") | |
cat("Let's get started!\n\n") | |
# Set up initial game state | |
points <- 0 | |
level <- 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Function to generate a random programming language | |
generate_language <- function() { | |
languages <- c("Python", "JavaScript", "Java", "C++", "Ruby", "PHP", "Swift", "Go", "R") | |
return(sample(languages, 1)) | |
} | |
# Function to generate a random programming problem | |
generate_problem <- function() { | |
problems <- c("FizzBuzz", "Reverse a string", "Count the vowels", "Check if a number is prime", "Find the largest element in an array", "Sort an array of numbers", "Implement a stack", "Implement a queue") | |
return(sample(problems, 1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the programming challenges | |
challenges <- list( | |
list( | |
description = "Create a function that takes two arguments and returns their sum.", | |
test_cases = list( | |
list(args = list(1, 2), expected_output = 3), | |
list(args = list(3, 5), expected_output = 8), | |
list(args = list(-2, 7), expected_output = 5) | |
) | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define yoga poses | |
yoga_poses <- c("Downward Dog", "Warrior I", "Warrior II", "Tree Pose", "Child's Pose", "Cobra Pose", "Triangle Pose", "Eagle Pose", "Plank Pose", "Savasana") | |
# Define player attributes | |
player_name <- readline(prompt = "What is your name? ") | |
player_level <- 1 | |
player_experience <- 0 | |
player_energy <- 100 | |
# Define game functions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define variables for player and enemy health | |
player_health <- 100 | |
enemy_health <- 100 | |
# Define function for shooting action | |
shoot <- function() { | |
# Generate a random hit probability between 0 and 1 | |
hit_prob <- runif(1, 0, 1) | |
# Determine if the player hit or missed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Function to play the dance game | |
play_dance_game <- function() { | |
cat("Welcome to the dance simulator game!\n") | |
cat("Follow the dance moves by entering the corresponding numbers on your keyboard.\n") | |
cat("Press ENTER to start the game.\n") | |
readline() | |
# Set up dance moves and their corresponding numbers | |
dance_moves <- list("Jump", "Turn left", "Turn right", "Spin", "Kick", "Squat") | |
dance_numbers <- c(1, 2, 3, 4, 5, 6) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define gym parameters | |
max_members <- 50 | |
gym_capacity <- 30 | |
equipment <- c("Treadmill", "Stationary bike", "Elliptical machine", "Weightlifting bench") | |
equipment_count <- length(equipment) | |
cost_per_month <- 50 | |
revenue_per_member <- 30 | |
# Initialize gym state | |
members <- 0 |