Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit/AppGameKit Studio Showcase / [PC DEMO] CE Pocket Poker [NaGaCreMo] 2015

Author
Message
Conjured Entertainment
AGK Developer
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 12th Jan 2015 10:45 Edited at: 26th Mar 2015 04:41
CE Pocket Poker is a simple Video Poker game created with AppGameKit v1 tier 1.
This pc demo was made for the 2015 NaGaCreMo.



The download is attached...

Have Fun!

EDIT
Download Removed
I am no longer distributing this Demo for the PC, since I now have the full Android version built.
I am testing a new marketing strategy with this title, so I will have to let you guys know later how it turns out.


Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 12th Jan 2015 11:48
This is quite a fun little app! Might be nicer if you didn't have to choose the bet each time, just hit deal to carry on playing?


Using AppGameKit V2 Tier 1
Conjured Entertainment
AGK Developer
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 12th Jan 2015 12:14 Edited at: 12th Jan 2015 14:27
Thanks baxslash

I thought about doing that but decided against it. I think you are right about that though, so I do need to change it before the 31st.


EDIT
I put up a new download with a better betting system.
Now it defaults to your last bet rather than resetting to zero.
You do not have to select the wager amount with the coins again when keeping the same wager amount, but you do have to exit the payout schedule.
I wanted players to have a reminder of the last bet, so they won't forget to change it if they wanted to.

Anyway, give that a try and see if it is better.

bigc90210
9
Years of Service
User Offline
Joined: 12th Jan 2015
Location:
Posted: 12th Jan 2015 23:14
Hi There! I REALLY like this, great job! I'm making my own game which will use cards, dealing a selection to one player then another. I'm stuck at the point of choosing random numbers, but only ones that haven't already been chosen (ie so theres no duplicate cards being dealt).

Have you any suggestions on how to achieve this? I'd appreciate any pointers greatly.

Thanks

c
Conjured Entertainment
AGK Developer
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 14th Jan 2015 22:46 Edited at: 14th Jan 2015 23:13
1) I set up an array for the cards simulating a deck of 52, and I initialize the values with a 0
DIM deck[52]
for t = 1 to 52
deck[t] = 0
next t

2) Then I pick a random number between 1 and 52 using a label to loop back here if need be
pick_a_random_card:
pick_a_card = random(1,52)

3) Then I check the deck with a for loop to make sure that the random number is not already there in the deck

for r = 1 to 52
if pick_a_card = deck[r]
goto pick_a_random_card
endif
next r

if the random card matches one already in the deck then I am going back to pick a new random number

4)if the random card does not match any in the deck then we go on to find an empty slot for the random number

for s= 1 to 52
if deck[s] = 0
deck[s] = pick_a_card
goto pick_a_random_card
endif
next s

notice I am jumping out of that for loop with a goto so we only assign the value of the random card in the first open slot of the deck and not all of the slots that = 0

5) we end it off by checking to see if the deck is full, and we can stick that in several places to effectively leave this cycle

if deck[52] <> 0
goto deal_the_cards
endif

we only have to check the last slot for being empty since we fill the deck one card at a time
just remember to reset the values to zero at the beginning of the shuffle on reshuffles

for t = 1 to 52
deck[t] = 0
next t

In short, this fills the array deck[52] with values between 1 and 52 without duplicates
Now we can deal these cards by cycling through the deck array starting at the first slot and incrementing each time
Instead of assigning the face value and suits for all 52 cards in the deck, I opt to do that one card at a time as I deal them
So I keep a separate multidimensional array for the cards
That way the multidimensional one is smaller.

DIM cards[5,3]

whereas if we start at 1 being Ace of clubs, and 2 being 2 of clubs through 13 being King of clubs, then
a card value of 14 would be the Ace of diamonds, and 15 the 2 of diamonds, etc.

so if the card in the 32 slot of the deck was a 23 then that is the 10 of diamonds, because the 23 represents the 10 of diamonds
so if that 32 card was the first card in our hand, then the cards array for that slot would be...
cards[1,1] = 23
cards[1,2] = 10
cards[1,3] = 2

note I use all numbers for everything then convert it, because that makes it easier when doing comparisons on the cards
you only need to convert that when displaying the card to show that suit value of 2 to equal diamonds, or whatever suit you have as your second suit

Anyway, this is not the best way to do this I am sure, but it does work without a hitch as you can see in my game.
Filling that deck array with no duplicates is just like having a real deck sitting there, shuffled and ready to be dealt.

I just keep a card counter to keep my place in knowing which card I am choosing...

cards[1,1] = deck[current_card]
current_card = current_card + 1

...note that I increment the current_card every time I use it so I am ready for drawing the next card.
You will need to reset this variable to 1 when shuffling, so you will start dealing at the beginning of the fresh deck

You will also need to know when to shuffle.
I do this check on the deal...

if current_card > 42
goto shuffle
endif

...in my case it is 5 card draw, so I need at least 10 cards left in the deck to deal a new hand. (dealt 5 and draw 5)

That way we do not have to check the cards in the players hand for duplicates when shuffling, just the deck.
You could run up to the last card if you wanted to, just remember to assign the first cards in the deck array with the values of the cards' first elements after resetting the array to 0's and before picking a random card, and also set the current_card accordingly so you would start dealing in the slot after the cards the player is holding

Sorry about the goto statements, but I use them.
This program is linear with labels. (no functions, just labeled routines)

Hope this helps


Using AppGameKit V1 Tier 1
bigc90210
9
Years of Service
User Offline
Joined: 12th Jan 2015
Location:
Posted: 22nd Jan 2015 23:46
thank you SO much for this, its been a great help. I'm almost there using the method youve described. Is the code that youve listed above in the correct order? just i cant seem to create a unique deck that doesnt have duplicates using your method above, though the logic does make sense to me

Regards

C
Conjured Entertainment
AGK Developer
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 24th Jan 2015 23:15
that is more like pseudo code, so maybe not in exact order but close enough to get the idea

Let me see the chunk of code you are using for your shuffle and I will see if I can help.
You can send it to me in a forum message if you do not want others to see your code.
Speaking of which, I am going to edit my post now that you have copied it down.
It really should be put up as a snippet, so it can be copy paste ready for others, so maybe I will post something at a later date.
Doesn't seem to be much interest in this for now, other than yours.
I don't mind sharing this, but I am a bit secretive of my hand strength routine, because I do that in a unique way.
We can definitely get you a proper shuffle worked out though.


Using AppGameKit V1 Tier 1
David Gervais
Retired Moderator
18
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Montreal, Canada
Posted: 25th Jan 2015 01:53
Just to add another voice on the whole shuffling a deck thing, this is how I would do it..



Note: using this method, the Value in the Deck[c] needs to be scanned and converted as needed,.. a value of 1 to 13 = hearts, 14 to 26 = diamonds (subtract 13 to get the card face value), 27 to 39 = clubs (subtract 26 to get the face value), and 40 to 52 = spades (subtract 39 to get the face value). This was a popular way to handle playing cards way back in the good old days. it still works, but might not fit with the new common core math way of doing things.

I just thought this might be of interest for those working on card games.

Cheers!

Conjured Entertainment
AGK Developer
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 25th Jan 2015 08:52
Interesting snippet.
That is swapping cards from one spot in the stack to the other.
I hadn't thought of doing the shuffle that way, but the code looks a lot cleaner.
I guess this is more like a real shuffle also by swapping spots in the stack, rather than assembling a new stack from nothing.
However, both result in the same thing, a 52 element array of mixed numbers.

Thanks for sharing.


Using AppGameKit V1 Tier 1
David Gervais
Retired Moderator
18
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Montreal, Canada
Posted: 25th Jan 2015 16:49
The only problem I saw with your method is that when counting on a random generator to pick 52 unique numbers, is that it is possible for it to get caught in the loop looking for those final 'unused' numbers in the 52 to fill the last few slots. Of course with the speed of computers nowadays, it's probably a mute point, but the possibility is still there that it has trouble filling that last empty slot. Probably the worst that would happen is a pause in the game while shuffling.

I'm glad you think the code is allot cleaner, I cannot take full credit, it was from a code segment I found for QBasic 4.5 way back when somewhere in the 90's, and I think I also saw this type of code done back even further on the Commodore 64, Atari 800 and early IBM 8086 machines.

Cheers!

Conjured Entertainment
AGK Developer
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 25th Jan 2015 17:04 Edited at: 25th Jan 2015 17:34
Quote: "The only problem I saw with your method is that when counting on a random generator to pick 52 unique numbers, is that it is possible for it to get caught in the loop looking for those final 'unused' numbers in the 52 to fill the last few slots."

Yeah, none of them are perfect. Yours has a problem too if the random numbers are picked more than once because then it is switching the same card over and over just moving the last one down each time. Also, by setting them to a value first, then the 52nd card never gets a value of 52 and the first card would never be 1, which would happen in true randomness A simple fix for your method would be to run through the second part two times, so then each card has a chance of being set again, thus a chance to have a number 1 set to 1 and 52 set to 52 since the second run is not in order.

I have a fix for my method for the last 10 or 5 cards that fills them with whatever numbers are left, since they would be more than likely scattered at that point anyway. Then you have the problem of the last few numbers being sequential in strength (left over numbers would still be lowest to highest), but we can mix them like you do to avoid that. The processor handled this without that fix and delayed just enough that it created a nice pause for the shuffle without using a timer but it never halted in tests, so I left it like it is. The drag actually makes each shuffle slightly different in the time it takes which makes it seem more like a real shuffle. I do need to code this proper for mobiles though, good call.


Using AppGameKit V1 Tier 1
David Gervais
Retired Moderator
18
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Montreal, Canada
Posted: 27th Jan 2015 21:15
Quote: "then the 52nd card never gets a value of 52 and the first card would never be 1"


that would be true if the deck was reinitialized before each shuffle,.. but there is no need to reinitialize the deck. just reshuffle from it's current shuffled state and that problem is solved.

just like real shuffling, you don't sort the deck before shuffling, you just pick it up and shuffle. it adds an extra level of randomness too, so it's a win win situation.

and that is how it works.

Cheers!

Conjured Entertainment
AGK Developer
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 27th Jan 2015 21:41
Right, I thought about that later.
It still holds true for the first deal though.
Every other deal too really, just not a value of 1 or 52 but still it is prevented from holding the same value for those slots (or any) from one deal to the next.
That could be a good thing though for some situations, but arguably unrealistic.
My method is unrealistic at this point too, so yeah, this is one that could go on forever trying to make it better.
I think either way suggested suffices for general purposes like casual games.
Besides, I have slots on the brain more than poker at the moment.

On a side note: there is a fellow in need of an artists help in the Survive the Undead thread.


Coding things my way since 1981 -- Currently using AppGameKit V1 Tier 1

Login to post a reply

Server time is: 2024-04-26 11:03:43
Your offset time is: 2024-04-26 11:03:43