Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
|
|
@ -17,7 +17,7 @@ repeat
|
|||
else
|
||||
sleep 1
|
||||
if sum mod 4 = 1
|
||||
n = randint 3
|
||||
n = random 3
|
||||
else
|
||||
n = 4 - (sum + 3) mod 4
|
||||
.
|
||||
|
|
|
|||
|
|
@ -1,37 +1,32 @@
|
|||
g21=: summarize@play@setup ::('g21: error termination'"_)
|
||||
g21=: summarize@play@setup ::'g21: error termination'
|
||||
|
||||
NB. non-verb must be defined before use, otherwise are assumed verbs.
|
||||
Until=: 2 :'u^:(0-:v)^:_'
|
||||
Until=: {{u^:(0-:v)^:_}}
|
||||
|
||||
t=: 'score turn choice'
|
||||
(t)=: i. # ;: t
|
||||
empty erase't'
|
||||
|
||||
Fetch=: &{
|
||||
Alter=: }
|
||||
'score turn choice'=: 0 1 2
|
||||
|
||||
play=: move Until done
|
||||
done=: 21 <: score Fetch
|
||||
move=: [: update you`it@.(turn Fetch)
|
||||
move=: [: update you`it@.(turn&{)
|
||||
done=: 21 <: score&{
|
||||
|
||||
|
||||
update=: swap@display@add
|
||||
add=: score Alter~ (score Fetch + choice Fetch)
|
||||
display=: [ ([: echo 'sum: {}' format~ score Fetch)
|
||||
swap=: turn Alter~ ([: -. turn Fetch)
|
||||
add=: score}~ score&{ + choice&{
|
||||
display=: [ 'sum: {}' echo@format~ score&{
|
||||
swap=: turn}~ [: -. turn&{
|
||||
|
||||
it=: ([ [: echo 'It chose {}.' format~ choice Fetch)@(choice Alter~ cb)
|
||||
cb=: (1:`r`3:`2:)@.(4 | score Fetch) NB. computer brain
|
||||
r=: 3 :'>:?3'
|
||||
it=: ([ 'It chose {}.' echo@format~ choice&{)@(choice}~ cb)
|
||||
cb=: 1:`(>:@?@3)`3:`2:@.(4 | score&{) NB. computer brain
|
||||
|
||||
you=: qio1@check@acquire@prompt
|
||||
prompt=: [ ([: echo 'your choice?'"_)
|
||||
acquire=: choice Alter~ ('123' i. 0 { ' ' ,~ read)
|
||||
check=: (choice Alter~ (665 - score Fetch))@([ ([: echo 'g21: early termination'"_))^:(3 = choice Fetch)
|
||||
qio1=: choice Alter~ ([: >: choice Fetch)
|
||||
prompt=: [ echo@'your choice?'
|
||||
acquire=: choice}~'123'i.0{' ',~read
|
||||
check=: (choice}~ 665 - score&{)@([ echo@'g21: early termination')^:(3 = choice&{)
|
||||
qio1=: choice}~ ([: >: choice&{)
|
||||
|
||||
setup=: ([ [: echo 'On your turn enter 1 2 or 3, other entries exit'"_)@((3 :'?2') turn Alter ])@0 0 0"_ NB. choose first player randomly
|
||||
summarize=: ' won' ,~ (];._2 'it you ') {~ turn Fetch
|
||||
setup=: ([ echo@'On your turn enter 1 2 or 3, other entries exit')@(?@2 turn} ])@0 0 0 NB. choose first player randomly
|
||||
|
||||
read=: 1!:1@:1:
|
||||
write=: 1!:2 4: NB. unused
|
||||
format=: ''&$: :([: ; (a: , [: ":&.> [) ,. '{}' ([ (E. <@}.;._1 ]) ,) ])
|
||||
summarize=: ' won',~ ];._2@'it you '{~turn&{
|
||||
|
||||
read=: 1!:1@1
|
||||
write=: 1!:2&4 NB. unused
|
||||
format=: ''&$: : ([: ; (a: , [: ":&.> [) ,. '{}' ([ (E. <@}.;._1 ]) ,) ])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue