Home Tutorials Forums Articles Blogs Movies Library Employment Press

 ActionScript.org Forums every possible two-card combination
 Register FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

 11-28-2006, 09:15 PM #1 Seanx Flash Dilettante   Join Date: Jul 2006 Posts: 369 every possible two-card combination lets say I had: ActionScript Code: deckA = ["1", "2", "3", "4"...] deckB = ["1", "2", "3", "4"...] both arrays had the same 52 numbers, corresponding to playing cards in a regular deck, is it possible to loop through the first array, matching each element up with each element of the other array, and trace out every possible two-card combination? with this script I could rule the world.
 11-28-2006, 11:40 PM #2 FlashMech Flashmech.net     Join Date: Nov 2006 Location: Singapore Posts: 261 Hi Seanx, looping through 52 cards is not a good idea! It hung my computer! I had to shorten the deck to 5 cards. But hope it gives you some direction. Code: stop(); var deckA:Array = new Array(); var deckB:Array = new Array(); function populateDeck (ary:Array):Void { for ( var i:Number = 1; i <= 5; i++ ) { ary.push(i); } } function traceCombi(ary1:Array, ary2:Array):Void { for ( var i:Number = 0; i < ary1.length; i++ ) { for ( var j:Number = 0; j < ary2.length; j++ ) { trace("card"+ary1[i]+" of ary1 with card"+ary2[j]+" of ary2"); } } } populateDeck(deckA); populateDeck(deckB); traceCombi(deckA, deckB); Just put this on the first frame of a new document. __________________ Lionel Low Flash Platform Consultant | Trainer | Speaker http://www.flashmech.net/ http://www.linkedin.com/in/flashmech
11-29-2006, 02:01 AM   #3
Flash Gordon
rather be programming

Join Date: Feb 2005
Location: City of Angels
Posts: 10,140

Quote:
 Originally Posted by FlashMech Hi Seanx, looping through 52 cards is not a good idea!
I disagree. This runs just fine.

ActionScript Code:
// // var deckA:Array = new Array(); var deckB:Array = new Array(); for (var i:Number=0; ++i<53;) deckA.push(i); deckB = deckA; for (var i:Number=0; i<deckA.length; i++) {     for (var j:Number=0; j<deckB.length; j++) {         trace("possible combination = " + deckA[i] + "  " + deckB[j]);     } } // //
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");

11-29-2006, 02:12 AM   #4
FlashMech
Flashmech.net

Join Date: Nov 2006
Location: Singapore
Posts: 261

Quote:
 Originally Posted by Flash Gordon I disagree. This runs just fine.
Yup you're right. It does runs fine!

It's just weird when I was doing on my other computer. Now it seems to work fine!

Hooray!
__________________
Lionel Low
Flash Platform Consultant | Trainer | Speaker
http://www.flashmech.net/

 11-29-2006, 02:44 AM #5 Seanx Flash Dilettante   Join Date: Jul 2006 Posts: 369 that's beautiful. thank you flashGordon I did some research on combinatorial analysis, and was looking for ways to plug their convoluted equations into flash, but your method is quite a bit simpler and easier on the eye. |[
 11-29-2006, 02:51 AM #6 Seanx Flash Dilettante   Join Date: Jul 2006 Posts: 369 what if I wanted to do the same thing, but with five cards, and four players? in other words, despite there being some 2,000,000 possible combinations for a five-card hand of poker, I'm making a hold'em game, so three of the cards are common to all players - and, of course, once you pull a hole card from the deck it is no longer available as a hole card to others, and, of course again, the 2,000,000 combinations doesn't take into account suits/values of hands. so it's all pretty mind-numbing when you think of there only being 52 cards, and extremely complicated if you want to create a one-number variable for every possible 2*4+1+1+1+1+1 card-dealing scenario. impossible really, but it would be a nice way to analyze how well the decision-making algorithm works for various players - simulating a few hundred thousand hands, and then looking at betting patterns and such. so, maybe I should get in touch with someone at MIT or something - somebody who knows combinatorial math well enough to whip up my formula for every scenario [i]++ it's not necessary, but would be something fun in any case. later and thanks again
 11-29-2006, 03:24 AM #7 Flash Gordon rather be programming     Join Date: Feb 2005 Location: City of Angels Posts: 10,140 Dude, making a card game is a rather difficult task. You need to spend a lot of time planning. Don't take that stage very lightly, this isn't something you can just jump into like a contact forum. Not to mention the combinations, but you need to plan if this is multiplayer. And if so, you are going to need electroserver or some socket. Take a lot of time and diagram your plan. Good luck __________________ trace("Good bye Flash.") Log.i(TAG, "Hello Droid");
 11-29-2006, 03:24 AM #8 FlashMech Flashmech.net     Join Date: Nov 2006 Location: Singapore Posts: 261 I love your idea~ If you ever get it done in flash, please post it up so we can take a looK~ __________________ Lionel Low Flash Platform Consultant | Trainer | Speaker http://www.flashmech.net/ http://www.linkedin.com/in/flashmech
 11-29-2006, 04:29 AM #9 Seanx Flash Dilettante   Join Date: Jul 2006 Posts: 369 well, I'm well on my way guys. I have some 3,000 lines of code, mostly because I'm not familiar enough with actionscript to know how to condense statements and the way I store variables and such. as of right now I can: 1. deal the hole cards 2. tell flash (on behalf of the computer players) to analyze the hole cards 3. place bets/check according to hand/percentage and some randomness I build in ie - variables that move around according to hands won/money et cetera (simulate ai) 4. deal the flop 5. repeat step 3 6. deal turn 7. repeat step 3 8. deal river 9. repeat step 3 10. figure out who has the best hand 11. start the next hand.... flash autodeals if after the button moves, antes are placed, and blinds are in it sees that the dealer is not P1 there are some problems I'm still working out, mostly because of my inexperience with if/else stuff - like, I haven't figure out a way to tell if a player has a straight, straight flush, and royal flush. I have a feeling that's another marvelously short piece of code that will elude me for some time, or in the short-term a really long set of complicated if/else statements once I get that worked out, it's just a question of animating the card dealing instead of having them magically appear, putting in some bg sounds, adding chip noises, animating chip piles down the road I'll add keep adding to the nuances of the pseudo-AI, and add new characters. oh yeah - big thing, I still haven't figured out how to make a player go away after losing, so losers will have to just go negative for a while until I figure out what conditionals to add to my existing code to allow for fewer/more players than the default 4 Last edited by Seanx; 11-29-2006 at 04:33 AM.

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home ActionScript Forums Group     ActionScript 3.0     ActionScript 2.0     ActionScript 1.0 (and below)     Simple Stuff (Newbies) Flash General Questions     Flash 10 General Questions     Flash 9 General Questions     Flash 8 General Questions     Other Flash General Questions Flex     Flex 2, 3 & 4     Flex 1 Extensions and Plugins     Components     JSFL - Extending Flash Desktop, Mobile and non-browser Environments     AIR (Apollo)     FlashLite / Portable Devices Development     Projectors and CDs Supporting Technologies     HTML and JavaScript     haXe     Server-Side Scripting     Flash Remoting     Flash Media Server General     Best Practices     Gaming and Game Development     Animation and Effects     Flashants Support Forum Community Boards     General Chat     Just for Kicks Challenges     Detention Flash In Action     Site Check     Cool Sites     Widgets Decommissioned     Projects and Positions CMS Forums     Announcements Board     Content Postings / Updates     Product Review Requests     CMS Technical Questions     Process Questions     Collaboration & Suggested Articles

 Similar Threads Thread Thread Starter Forum Replies Last Post Kiandoshi Gaming and Game Development 1 10-17-2006 04:25 PM waarbs Gaming and Game Development 1 02-07-2006 01:54 PM blatex24 Gaming and Game Development 0 07-16-2004 12:48 AM pigpen Gaming and Game Development 1 11-26-2002 11:41 AM

All times are GMT. The time now is 06:45 AM.

///