( Here is my Rock Paper Scissors solution. I used MPV VFX Forth but ) ( it also worked on GForth on the Raspberry Pi 4. Also included are ) ( test definitions to exercise the code. ) ( David Henderson - kadetopirks@gmail.com ) ( SVFIG Programming Challenge ) ( ) ( The game of "Rock Paper Scissors". ) ( ) ( Level One: ) ( Program the game for manual inputs. ) ( ) 0 constant rock 1 constant paper 2 constant scissors ( rock crushes scissors ) ( paper covers rock ) ( scissors cut paper ) ( 0 1 -1 rock paper paper covers rock ) ( 0 2 1 rock scissors rock crushes scissors ) ( 1 2 -1 paper scissors scissors cut paper ) ( 0 0 0 rock tie - go again x ) ( 1 1 0 paper tie - go again x ) ( 2 2 0 scissors tie - go again x ) ( 1 0 1 paper rock paper covers rock ) ( 2 0 -1 scissors rock rock crushes scissors ) ( 2 1 1 scissors paper scissors cut paper ) ( hand --- ) : print_hand dup . ." - " dup 0= if ." rock " drop else 1 = if ." paper " else ." scissors" then then ; ( hand_a hand_b --- ) : print_outcome + dup 1 = if ." Paper covers rock." drop else 2 = if ." Rock crushes scissors." else ." Scissors cut paper." then then ; : compare_hands ( player opponent --- outcome ) ( 1 if player wins, -1 if opponent wins, 0 if tie ) 2dup <> if - dup 1 = swap -2 = or if 1 else -1 then else 2drop 0 then ; : print_round ( A_hand B_hand --- ) 2dup compare_hands dup 0= if ." Tied. Go again." drop 2drop else 1 = if ." A wins. " else ." B wins. " then print_outcome then ; ( *** TESTS *** ) : test_compare_defn ( --- ) cr 3 0 do 3 0 do j i 2dup swap ." A: " print_hand ." , B: " print_hand ." , outcome = " compare_hands . cr loop loop cr ; test_compare_defn : test_outcome ( --- ) cr 3 0 do 3 0 do j i 2dup swap ." A: " print_hand ." , B: " print_hand ." - " print_round cr loop loop ; ( A B delta sum A and B hands Winner Winning hand ) ( 0 0 0 0 0 rock rock Tie. go again ) ( 0 1 -1 1 -1 rock paper B wins. paper covers rock ) ( 0 2 -2 * 2 1 rock scissors A wins. rock crushes scissors ) ( 1 0 1 * 1 1 paper rock A wins. paper covers rock ) ( 1 1 0 2 0 paper paper Tie. go again ) ( 1 2 -1 3 -1 paper scissors B wins. scissors cut paper ) ( 2 0 2 2 -1 scissors rock B wins. rock crushes scissors ) ( 2 1 1 * 3 1 scissors paper A wins. scissors cut paper ) ( 2 2 0 4 0 scissors scissors Tie. go again ) test_outcome ( test manual inputs... ) ( player_A player_B print_round ) cr rock paper print_round cr paper scissors print_round cr cr ( Level Two: ) ( 1. Create a learning strategy for Betty. ) ( Allen picks Rock 50% of the time, Paper 25% and Scissors 25%. ) ( Betty picks them equally. ) ( Q: Will they have a significant difference in their outcomes? ) ( 2. Develop a learning strategy for Betty to win more often. ) ( random seed and constants from wikipedia ) variable seed 123456789 seed ! 1140671485 constant a_rand 16777215 constant c_rand 12820163 constant m_rand : poor_rand ( --- random_num ) seed @ a_rand * c_rand + m_rand mod dup seed ! abs ; ( seed = [a * seed + c] % m ) : allen_move poor_rand 4 mod ( number from 0 to 3 ) dup 3 = if drop 0 then ( 50% chance of rock ) ; : betty_move ( betty picks equally ) poor_rand 3 mod ( number from 0 to 2 ) ; variable betty_count variable allen_count ( --- Allen Betty ) : rps_game 0 betty_count ! 0 allen_count ! 100000 0 do allen_move betty_move ( 2dup swap . . ) compare_hands dup -1 = if 1 betty_count +! then 1 = if 1 allen_count +! then loop cr ." Wins out of 100000" cr cr ." allen : " allen_count @ . cr ." betty : " betty_count @ . cr ." ties : " 100000 allen_count @ - betty_count @ - . cr ; cr ." BETTY PICKING RANDOMLY ROCK, PAPER, SCISSORS:" cr rps_game ( allen picks rock 50% of the time ) ( so betty should pick paper 50% of the time to take ) ( advantage ) ( have betty always pick paper ) : betty_move_with_strategy 1 ; : rps_game_with_strategy 0 betty_count ! 0 allen_count ! 100000 0 do allen_move betty_move_with_strategy compare_hands dup -1 = if 1 betty_count +! then 1 = if 1 allen_count +! then loop cr ." Wins out of 100000" cr cr ." allen : " allen_count @ . cr ." betty : " betty_count @ . cr ." ties : " 100000 allen_count @ - betty_count @ - . cr ; cr ." BETTY WITH STRATEGY OF PICKING PAPER ALWAYS:" cr rps_game_with_strategy