1
0

Expand and improve examples

This commit is contained in:
Jeff 2023-10-25 14:41:23 -04:00
parent 8a38790f57
commit 745e56e4b5
2 changed files with 26 additions and 9 deletions

View File

@ -1,6 +1,6 @@
rooms = ['Library', 'Kitchen']
suspects = ['White', 'Green']
weapons = ['Rope', 'Lead_Pipe']
rooms = ['Library' 'Kitchen']
suspects = ['White' 'Green']
weapons = ['Rope' 'Lead_Pipe']
cards = [rooms suspects weapons]
take_turn = function <current_room opponent_card> {
@ -10,7 +10,7 @@ take_turn = function <current_room opponent_card> {
remove_card = function <opponent_card> {
for card_list in cards {
removed = remove card from card_list {
removed = remove card in card_list {
card == opponent_card
}
}
@ -20,10 +20,13 @@ remove_card = function <opponent_card> {
}
}
(remove_card 'Library')
(output cards)
make_guess = function <current_room> {
if (length suspects) == 1
&& (length rooms) == 1
&& (length weapons) == 1
if ((length suspects) == 1)
&& ((length rooms) == 1)
&& ((length weapons) == 1)
{
(output 'It was '
+ suspects.0
@ -31,8 +34,7 @@ make_guess = function <current_room> {
+ rooms.0
+ ' with the '
+ weapons.0
+ '!'
)
+ '!')
} else {
(output 'I accuse '
+ (random suspects)
@ -43,3 +45,5 @@ make_guess = function <current_room> {
+ '!')
}
}
(make_guess 'Library')

13
examples/random.ds Normal file
View File

@ -0,0 +1,13 @@
stuff = [
(random_integer)
(random_integer)
(random_integer)
(random_float)
(random_float)
(random_float)
"foobar_1"
"foobar_2"
"foobar_3"
]
(random [])