Rock-paper-scissors: Difference between revisions
→{{header|Batch File}}: corrected the probabilistic choice
Simple9371 (talk | contribs) m (→{{header|uBasic/4tH}}: Changed 'C' to 'uBasic/4tH') |
Simple9371 (talk | contribs) (→{{header|Batch File}}: corrected the probabilistic choice) |
||
Line 608:
=={{header|Batch File}}==
<lang dos>@echo off
setlocal enabledelayedexpansion
Line 624 ⟶ 623:
:start
cls
echo Games - %games% : Won - %won% : Lost - %lost% : Ties - %tie%
choice /c RPS /n /m "[R]ock, [P]aper or [S]cissors? "
set choice=%errorlevel%
rem used [1,1000] as interval for random
set /a rocklimit=100 / %choicequant% * %freq3%▼
if %games% equ 0 (
set /a scissorslimit=100 - (100 / %choicequant% * %freq2%)▼
rem at the beginning, there's no bias for each choice
set /a randchoice=%random% %% 100 + 1▼
set /a "rocklimit=1000 / 3"
set /a "scissorslimit=1000 * 2 / 3"
) else (
)
set compchoice=2
if %randchoice% geq %scissorslimit% set compchoice=3
Line 642 ⟶ 646:
goto %compchoice%
:1
if %choice%==1 goto tie
if %choice%==2 goto win
Line 649 ⟶ 652:
:2
if %choice%==1 goto loss
if %choice%==2 goto tie
if %choice%==3 goto win
:3
if %choice%==1 goto win
if %choice%==2 goto loss
Line 661 ⟶ 662:
:win
set /a "won+=1"
echo Player wins^!
goto end
:loss
set /a "lost+=1"
echo Computer Wins^!
goto end
:tie
set /a "tie+=1"
echo Tie^!
goto end
:end
set /a "games+=1"
set /a "freq%choice%+=1"
pause
goto start</lang>
=={{header|BBC BASIC}}==
|