add stuff

This commit is contained in:
Adam 2024-01-12 08:49:33 -05:00
parent af77aec3c7
commit 8115ffc3d0
5 changed files with 145 additions and 0 deletions

1
rps-rs/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

75
rps-rs/Cargo.lock generated Normal file
View file

@ -0,0 +1,75 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "getrandom"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4"
dependencies = [
"cfg-if",
"libc",
"wasi",
]
[[package]]
name = "libc"
version = "0.2.144"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1"
[[package]]
name = "ppv-lite86"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "rand"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"libc",
"rand_chacha",
"rand_core",
]
[[package]]
name = "rand_chacha"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
"getrandom",
]
[[package]]
name = "rps-rs"
version = "0.1.0"
dependencies = [
"rand",
]
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"

9
rps-rs/Cargo.toml Normal file
View file

@ -0,0 +1,9 @@
[package]
name = "rps-rs"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rand = "0.8.5"

9
rps-rs/src/main.rs Normal file
View file

@ -0,0 +1,9 @@
use rand::seq::SliceRandom;
fn main() {
let moves = vec!["Rock!", "Paper!", "Scissors!"];
println!("{:?}", moves.choose(&mut rand::thread_rng()));
}
// can't finish anything

51
rps.py Normal file
View file

@ -0,0 +1,51 @@
import random
print('Rock Paper Scissors\n------------------------')
moves = ['Rock!', 'Paper!', 'Scissors!']
player_input = input('Your move, sir?\n')
computer_move = random.choice(moves)
match (player_input[0].lower()):
case 'r':
player_move = moves[0]
case 'p':
player_move = moves[1]
case 's':
player_move = moves[2]
case _:
player_move = 'Invalid'
print('You threw:', player_move)
print('Computer threw:', computer_move)
if player_move == computer_move:
print('Tie!')
elif player_move == moves[0] and computer_move == moves[1]:
print('Paper covers rock, Computer wins!')
elif player_move == moves[1] and computer_move == moves[0]:
print('Paper covers rock, You win!')
elif player_move == moves[0] and computer_move == moves[2]:
print('Rock smashes scissors, You win!')
elif player_move == moves[2] and computer_move == moves[0]:
print('Rock smashes scissors, Computer wins!')
elif player_move == moves[1] and computer_move == moves[2]:
print('Scissors cut paper, Computer wins!')
elif player_move == moves[2] and computer_move == moves[1]:
print('Scissors cut paper, You win!')
else:
print('Error')