Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[Monty Hall Paradox Test]-- By: Cody Hardink
- --[Variables]--
- local testSampleNum = 200 --Change this to what you like.
- local curTestSampleNum = 0 --Counts how many tests have been run.
- local switchWins = 0
- local stickWins = 0
- local winLocation = 0
- local selLocation = 0
- local sTime = 0.05
- --[Functions]--
- local function randomSel()
- local gNum = math.random(1,3)
- return gNum
- end
- local function runTest()
- winLocation = randomSel()
- selLocation = randomSel()
- if selLocation == winLocation then
- stickWins = stickWins + 1
- else
- switchWins = switchWins + 1
- end
- end
- local function main()
- while curTestSampleNum < testSampleNum do
- runTest()
- curTestSampleNum = curTestSampleNum + 1
- term.clear()
- term.setCursorPos(1,1)
- print("---------------------------------------------------")
- print(" ")
- print("Stick Wins Percentage:"..stickWins/testSampleNum * (100).."%")
- print(" ")
- print("Switch Wins Percentage:"..switchWins/testSampleNum * (100).."%")
- print(" ")
- print("Total Progress:"..curTestSampleNum/testSampleNum * (100).."%")
- print(" ")
- print("Total Samples Run:"..curTestSampleNum.."/"..testSampleNum)
- print(" ")
- print("ETA:"..(math.ceil((sTime * testSampleNum) - (sTime * curTestSampleNum))).." Seconds")
- sleep(sTime)
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment