ADRIFT Forum


The place to discuss the ADRIFT Interactive Fiction toolkit

Simulating drawing from a deck of cards

This forum is the place to learn about and discuss ADRIFT 5. Feel free to mention any bugs you find here, but please also add these to the Bugs & Enhancements list.

Please also refer to the ADRIFT 5 Wiki for more information.

Simulating drawing from a deck of cards

Postby The0didactus » Fri Aug 02, 2019 9:18 pm

This is one of two problems I submitted on the same day.
Technically, I've solved this one, I just don't know a way to do it elegantly, and I'm sure someone here does.

When the player undertakes an action, I want one of a number of possible outcomes to trigger. Here's the catch:
* the outcomes must all have an equal chance of triggering, and their triggering must be random
* once an outcome has been selected, that outcome cannot happen again.

The easiest way to imagine this is a deck of cards. If you type "draw a card" you get the queen of spades or the ace of clubs, but you'll never get those cards again. Once the game "runs out of actions" you get a response like "you've run out of cards"


Tingalan and The Dead of Winter both feature a VERY complicated system for doing this, but I'm convinced there is a simple possibility I haven't considered.

Any ideas?
The0didactus
 
Posts: 234
Joined: Sun Mar 30, 2014 8:20 pm
Points: 80

Re: Simulating drawing from a deck of cards

Postby DazaKiwi » Sat Aug 03, 2019 3:58 am

I've done something like that in the past using objects and groups. I made a quick demo of the method that i hope meets the requirements of what you are after.

The deck in the demo has just 6 cards and the player has to manually deal each one, when deck is spent player has to shuffle to start over again.
Attachments
Deal Cards Demo_v1.taf
(16.17 KiB) Downloaded 11 times
User avatar
DazaKiwi
 
Posts: 631
Joined: Thu Oct 21, 2010 9:05 am
Location: New Zealand
Points: 21

Re: Simulating drawing from a deck of cards

Postby Denk » Sat Aug 03, 2019 6:46 am

This was the simplest method I could come up with:
deck.taf
(15.5 KiB) Downloaded 13 times


I can imagine that the method is not so far from DazaKiwi's method. DazaKiwi's method just has more features, in that it both shuffles the cards and draw cards at random.
----------------------------------------------------------------------
The Bash Saga:
1. The Dragon Diamond 2. The Way Home 3. Stone of Wisdom
----------------------------------------------------------------------
Denk
 
Posts: 258
Joined: Mon Feb 22, 2016 6:21 pm
Location: Hjørring, Denmark
Points: 56


Return to ADRIFT 5.0

Who is online

Users browsing this forum: Google [Bot] and 2 guests