Compare commits

...

7 Commits

Author SHA1 Message Date
7ef616df92 Laptop Test 2026-05-07 05:55:29 -07:00
41c53e86ec Experimentation 2026-05-05 21:57:20 -07:00
54666fd55c random number test in Lua - E and J helped 2026-05-05 10:16:00 -07:00
4c74a07eb6 random number test in bash 2026-05-05 08:12:46 -07:00
f34be20aa1 Placeholder scripts added 2026-05-05 07:29:06 -07:00
2333762f46 added bash script option 2026-05-05 07:19:20 -07:00
kaibeth
3ec015142d Update README.md 2026-05-05 10:43:04 +02:00
7 changed files with 90 additions and 4 deletions

View File

@@ -1,13 +1,16 @@
Game to have computer guess what number the user is thinking of. Game to have computer guess what number the user is thinking of.
### Goals Going to try Lua and bash scripts. See which one I get along better with.
## Goals
#### ABSOLUTELY NO AI!!!! #### ABSOLUTELY NO AI!!!!
Rules command Rules command
Interface to ask number Interface to ask number
'Higher or lower' interface 'Higher or lower' interface
Variable number. 'Between 1 and <user selected>' Variable number. 'Between 1 and a user selected number'
Percentage of Variable Number to be number of guesses Percentage of Variable Number to be number of guesses
maybe 30% ? maybe 30% ?
Play Again? dialog Play Again? dialog
## Outline

21
bash/randTest.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# set script restart
script=$(readlink -f "$0")
# Select number
echo "Pick a number:"
read num
# Output response
echo "The random number is $((1 + $RANDOM % $num))."
# Ask to run again
echo "Run script again (yes/no)?"
read answer
if [ "$answer" = yes ]
then exec "$script"
fi
echo "Exiting"
exit 0

0
delete.test Normal file
View File

BIN
lua/Notes/help1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

10
lua/randTest.lua Normal file
View File

@@ -0,0 +1,10 @@
io.write("Pick a number: ")
local number = io.read("*n")
local randnum = math.random(1, number)
print("The number is ", randnum)
-- ask to rerun script
print("Run again (y/n)?")
local cmd = io.read()
if cmd == "y" then
dofile("randTest.lua")
else end

View File

@@ -0,0 +1,26 @@
-- Assistance from a friend
-- Instantiate all the things
local run = true
local cmd, number, randnum
-- Start a loop
while run == true do
-- Get the users initial number
io.write("Pick a number: ")
number = io.read("*n")
-- Do some mathemagic
-- randnum = math.random(1, number)
print("The random number is ", math.random(1, number))
-- Ask to rerun script
io.read()
print("Run again (Y/n)?")
cmd = io.read("*l")
-- Exit if the user doesn't want to go again
if string.lower(cmd) ~= "y" then
run = false
end
end

26
lua/randTestHelped.lua Normal file
View File

@@ -0,0 +1,26 @@
-- Assistance from a friend
-- Instantiate all the things
local run = true
local cmd, number, randnum
-- Start a loop
while run == true do
-- Get the users initial number
io.write("Pick a number: ")
number = io.read("*n")
-- Do some mathemagic
randnum = math.random(1, number)
print("The random number is ", randnum)
-- Ask to rerun script
io.read()
print("Run again (Y/n)?")
cmd = io.read("*l")
-- Exit if the user doesn't want to go again
if string.lower(cmd) ~= "y" then
run = false
end
end