#!/bin/bash declare -A mapOfChoices=( [rock]=1 [paper]=2 [scissors]=3 [1]=rock [2]=paper [3]=scissors ) humanWins=0 machineWins=0 draws=0 read -p "Please select one from paper, scissors and rock (or exit) " humanChoice until [ "$humanChoice" = "exit" ] do machineChoice=${mapOfChoices[$(($RANDOM % 3 + 1))]} echo "Machine choice: $machineChoice" if [ "$machineChoice" = "$humanChoice" ]; then echo "Draw" ((draws++)) else if test $((${mapOfChoices["$humanChoice"]}-${mapOfChoices[$machineChoice]} % 3)) = 1; then echo "You won!" ((humanWins++)) else echo "Machine is the winner :(" ((machineWins++)) fi fi read -p "Please select one from paper, scissors and rock (or exit) " humanChoice done echo "Number of human wins: "$humanWins echo "Number of draws: "$draws echo "Number of machine wins: "$machineWins