ADRIFT Forum


The place to discuss the ADRIFT Interactive Fiction toolkit

Card Games and Dice Games

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.

Card Games and Dice Games

Postby Aguadiablo2 » Tue Mar 31, 2020 6:26 pm

Are there any simple solutions to creating card minigames and dice mini-games in a bigger game?

I have the idea of having a room where players could make or lose money in a games room. Games such as blackjack, poker, Yahtzee and more like that.

It has been suggested to me that I could just have an array of results and roll randomly on that.

However, that doesn't involve a lot of play or interactivity.

So is there a way of having interactivity in a simply designed without having to create loads of objects with tasks?
Aguadiablo2
 
Posts: 11
Joined: Tue Dec 31, 2019 12:42 pm

Re: Card Games and Dice Games

Postby The0didactus » Tue Mar 31, 2020 8:50 pm

So I was the one who suggested an array-based method to aguadiablo on the discord. this method is a "cheat" which gives the appearance of a card game without actually simulating the card game. The way to do it is to create a very large text array (100+ items) of individual hands like "the jack of hearts, the jack of spades, the nine of clubs, the three of diamonds, and the two of diamonds" or even simpler "three jacks and two threes". If you arrange this array by value (lowest value hand to highest value hand) you can "simulate" a card game behind the scenes with the generation of a single number: You are holding %Handflavor[%Handvalue%]% and just have the game call a hand a "win" or a "loss" depending on whether %handvalue% exceeds a certain number (even another hand).

I used this cheat in Six Silver Bullets for a poker-like minigame.

It's a relatively low-effort way to convincingly simulate a card game. To actually simulate a card game, I think would require some real effort, but maybe someone here knows a relatively easy way to do it.
The0didactus
 
Posts: 288
Joined: Sun Mar 30, 2014 8:20 pm
Points: 150

Re: Card Games and Dice Games

Postby saabie » Wed Apr 01, 2020 12:39 am

For a dice game you just need to have a variable for each die and use the rand(1,6) function to set each one for each turn.
Then you just need to call a series of tasks that determine what the outcome of the roll is.

A full simulation of a card game is much more complex but can be done.
You would need arrays for the deck, discard pile and each hand. The deck needs to be initialized with a representation of each card and then shuffled using a loop that randomly selects 2 cards and swaps them at least 52 times. Each array need a pointer so you know which cards have been removed or added, and then you need to deal cards and let the player decide whether to keep or discard it.
The non-player characters would also need to be simulated so that they make sensible moves.
saabie
 
Posts: 1024
Joined: Fri Aug 12, 2011 2:07 am
Location: Adelaide, South Australia
Points: 50

Re: Card Games and Dice Games

Postby Aguadiablo2 » Wed Apr 01, 2020 9:47 am

Well, that was my problem. Trying to figure out how to determine different "hands" even in dice. For example, Yahtzee has a full house, and well so does poker. It's easy to determine a pair, any matching dice variable when comparing two. Three of a kind, four of a kind, five of a kind, and a straight are also easy. However, having a full house is more difficult. As well as two pairs. You can't just combine three of a kind and a pair. As 55512 would be detected as a full house.

That, of course, is only the first challenge to it. The other challenge is trying to simulate an NPC player's actions.
Aguadiablo2
 
Posts: 11
Joined: Tue Dec 31, 2019 12:42 pm

Re: Card Games and Dice Games

Postby saabie » Wed Apr 01, 2020 11:13 am

You will need at least one task for each of the possible outcomes, then execute them from the actions of the main task.
The Yahtzee would be tested first, setting a flag variable when a task passes so that the lower-scoring tasks can be aborted by a restriction to prevent multiple results. Failing restrictions need to have completely blank text boxes so you only get the message for the scoring hand.
For the full house you could have the three-of-a-kind task execute another task to check if the remaining 2 dice are a pair.
This is really "expert" level ADRIFT, so don't expect it to be quick or easy.
saabie
 
Posts: 1024
Joined: Fri Aug 12, 2011 2:07 am
Location: Adelaide, South Australia
Points: 50

Re: Card Games and Dice Games

Postby Aguadiablo2 » Wed Apr 01, 2020 5:10 pm

Maybe, I'll just stick with Theo's short cut since as this just a minigame room. I'd rather have more games available that can be played with the rest of the game better developed. Than one minigame taking up just as much time.
Aguadiablo2
 
Posts: 11
Joined: Tue Dec 31, 2019 12:42 pm

Re: Card Games and Dice Games

Postby ralphmerridew » Thu Apr 02, 2020 1:28 am

If you want to handle Yahtzee, something like this would work (I don't know the exact syntax offhand):

num1s = if(%die1% == 1, 1, 0) + if(%die2% == 1, 1, 0) + if(%die3% == 1, 1, 0) + if(%die4% == 1, 1, 0) + if(%die5% == 1, 1, 0)
num2s = if(%die1% == 2, 1, 0) + if(%die2% == 2, 1, 0) + if(%die3% == 2, 1, 0) + if(%die4% == 2, 1, 0) + if(%die5% == 2, 1, 0)
(define num3s, num4s, num5s, nums6 similarly)

num_pents = if(%num1s% == 5, 1, 0) + if(%num2s%==5, 1, 0) + if(%num3s%==5,1,0) + if(%num4s% == 5, 1, 0) + if(%num5s% == 5, 1, 0) + if(%num6s%==5, 1, 0)
(define num_pairs, num_trips, num_quads similarly)

To detect a yahtzee, check if num_pents == 1.
To detect a full house, check if num_pairs == 1 and num_trips == 1
To detect a straight, check that num2s, num3s, num4s, and num5s are all 1.
Bloodhounds can make you laugh and cuss in the same breath. They are endearing, faithful, and can sling drool ten feet in any direction. -- Virginia Lanier
User avatar
ralphmerridew
 
Posts: 2587
Joined: Fri Dec 13, 2002 11:56 pm
Location: Missouri
Points: 10


Return to ADRIFT 5.0

Who is online

Users browsing this forum: No registered users and 15 guests

cron