The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need a more efficient function
Author Message
ShiryuX
Journeyman
*

Posts: 249
Likes Given: 1
Likes Received: 19 in 14 posts
Joined: Mar 2010
Reputation: 4



Post: #2
RE: I need a more efficient function
Why don't use numbers for everything?
Let me analyze this:

You got 12 cards in every color. That gives you 12 ranks.
You got numbers from 2 to 9. So you don't have 2 digits.
You got A, K, Q, J as letters, but you can use them as numbers if you like (Spanish cards goes from 1 to 12).

So let's say you make a number using the Rank and Color of the card.
For the Ace of Spades you'll have 13-1 (Saying 13 is the highest rank and 1 is the color).
And for the 4 of Spades you'll have 4-1.

That gives you 131 against 41.
Now, that's fine if you have only ONE color, now you got 4 colors, so the result may change from 131 to 134.
I'll give you the solution: Card / 10. So, if the Card is 131 (Ace of Spades) against 134 (Ace of Hearts), you divide them by 10 and that should give you 13 against 13.
If you want to recover the color for the royal flush, you can use a strsub. This way you can analyze Pairs and Three of a Kind with no problem, same goes for Poker and Full.
The only "hard part" is the flush or royal flush, since Straigth is kinda easy (divide everything by 10 and it should give you a straigth). For the Royal you can save resources by only analyzing if you first have a Straigth. In the case of the Flush, you have to analyze if you have all different ranks in the hand.

After that you can create a defname or something like that to "rename" the cards numbers.
Did you get my idea? Tongue
(This post was last modified: 05-15-2012 04:16 PM by SystemMod.)
05-15-2012 04:13 PM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Messages In This Thread
RE: I need a more efficient function - ShiryuX - 05-15-2012 04:13 PM

Forum Jump:


User(s) browsing this thread: 2 Guest(s)