Created
September 27, 2011 10:23
-
-
Save shinka-cb/1244767 to your computer and use it in GitHub Desktop.
A random method for "LTG (Lambda: The Gathering)" held in ICFP Programming Contest 2011
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| opp() | |
| { | |
| read lr | |
| case $lr in | |
| 1) read card; read slot;; | |
| 2) read slot; read card;; | |
| esac | |
| } | |
| output() | |
| { | |
| if [ $1 = "1" ]; then | |
| echo $1 | |
| echo $3 | |
| echo $2 | |
| else | |
| echo $1 | |
| echo $2 | |
| echo $3 | |
| fi | |
| } | |
| random() | |
| { | |
| local target_app | |
| local target_slot | |
| local target_card | |
| local target_card_name | |
| target_app=$(($RANDOM%2+1)) | |
| target_slot=$(($RANDOM%256)) | |
| target_card=$(($RANDOM%15)) | |
| case $target_card in | |
| 0) target_card_name="I" | |
| ;; | |
| 1) target_card_name="zero" | |
| ;; | |
| 2) target_card_name="succ" | |
| ;; | |
| 3) target_card_name="dbl" | |
| ;; | |
| 4) target_card_name="get" | |
| ;; | |
| 5) target_card_name="put" | |
| ;; | |
| 6) target_card_name="S" | |
| ;; | |
| 7) target_card_name="K" | |
| ;; | |
| 8) target_card_name="inc" | |
| ;; | |
| 9) target_card_name="dec" | |
| ;; | |
| 10) target_card_name="attack" | |
| ;; | |
| 11) target_card_name="help" | |
| ;; | |
| 12) target_card_name="copy" | |
| ;; | |
| 13) target_card_name="revive" | |
| ;; | |
| 14) target_card_name="zombie" | |
| ;; | |
| esac | |
| output $target_app $target_slot $target_card_name | |
| } | |
| if [ $1 = "1" ]; then | |
| opp | |
| fi | |
| while [ true ]; do | |
| random | |
| opp | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment