Texas Hold 'Em
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Texas Hold 'Em

Started by CrazyGuy, 31 January, 2007, 22:56:10

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

CrazyGuy

Okay, here we go: Texas Hold 'Em
The complete game except for betting (will be added in a later version)
I assume people know the rules of texas hold 'em, if not click this link --> http://boardgames.about.com/cs/poker/a/texas_rules.htm

Here's a quick summary of the order of winning hands (from highest to lowest)


  • Royal Flush
  • Straight Flush
  • 4 Of a Kind
  • Full House
  • Flush
  • Straight
  • 3 Of a Kind
  • 2 Pairs
  • 1 Pair
  • High Card

The way this game is played

  • All players receive 2 cards in PM (If there's only 1 player, a computer player is added who always Calls)
  • All players are asked if they want to Call or Fold (if you fold, you're out. Last man in, wins)
  • Dealer removes 1 card from the deck, then deals 3 on the table called the flop
  • All players are asked to Call of Fold again
  • Dealer again burns a card and deals 1 on the table called the turn
  • All players are asked to Call of Fold again
  • Dealer again burns a card and deals 1 on the table called the river
  • All players are asked to Call of Fold for the last time
  • A Winner is determined

If more than 1 player has the highest hand, card height determines the winner.
If all cards are equally high, both players win and split the pot

Note: Suits have an equal value in Texas Hold 'Em, so hearts do not beat spades or anything like that

For more rules on which hand wins, check:


The scoring engine seems to work correct in the script, but IF the script determines a wrong winner, do not hesitate to ask. Please show the cards all players have, so I can find when/where it might go wrong.

This script also creates an error log called texasError.log when it runs into a script error, or when it's unable to determine a winner.
Please do upload that log here :)

Well, I think that's about it for now..Attached is the script


(edited on Feb 3rd to remove original rar file. for updated version check further down in this post)

Daywalker?

Amazing script or to say in dutch language.. petje af ;D

CrazyGuy

thank you, come join the play in my hub :D

??']['??l?

Finally it`s ready, i`m so happy...thanks.... :) :) :)
Also my last new components came today, so i can start to build my new pc...
Then i can start  run my hub with new pc and i can open casino for my users... ;D ;D

lito

very nice script CG :D

Lito            Lino-hub

BrotherBear

Great Script CrazyGuy :)

Is it possible to play in PM ?

Thanks for this wonderful script
Regards,

BrotherBear

CrazyGuy

Quote from: BrotherBear on 03 February, 2007, 18:05:19
Great Script CrazyGuy :)

Is it possible to play in PM ?

Thanks for this wonderful script


Thank you all ;D

No this 1 won't be able to play in PM (neither does the Blackjack script), but the idea is to make both scripts part of a bigger 'Casino' script.
Then they will run as chatrooms, but I havent started on that yet.
NOTE !!

Quote
updated to version 1.1
Last updated on Feb 3rd 2007
Fixed bug: Not recognizing straight when user also has pair (Thnx Nillan for report)

Attached is the new file  8)

CHILLCODE?

Hey I also think its a cool script, and I like the coding too, just one part I found think could use maybe some update
the random function,
I uncommecnted the randomseed, since after each random call the seed gets set newly anyways,
you can check this by doing math.randomseed( 6 ) print( math.random( 6 ) ) it will always be that same
where as only math.random( 6 ) will change if called a few times.
Well and here if you load this script into the LUA.exe you will see that the frist few cards will likely be of category c
mostly Ac - 5c, what okey might not bother you since you take the cards fromt he back but well
it does lower the chances to have a c card, so I would acutally kinda know that once the cards are there
and anybody would need a c card I can sorta assume the chances are quite low.
So maybe check out the second random thing I posted beneath, here you also see that
if you do a math.randomseed() before, it will likely be the same each second or so.
but if you leave it out, the cards get mixed quite good, just a exsample, maybe you find a better way anyways,
till then good script.
I also thaught if one could optimise the liones where you check who has won, but it seems there is no other way around
except doing a lot of if's, but would be a challange to see if its possible, weel maybe someone else can come up with something.
Code: lua
Shuffle = function()
	local tDeck = { "Ac", "2c", "3c", "4c", "5c", "6c", "7c", "8c", "9c", "10c", "Jc", "Qc", "Kc", "Ad", "2d", "3d", "4d", "5d", "6d", "7d", "8d", "9d", "10d", "Jd", "Qd", "Kd", "Ah", "2h", "3h", "4h", "5h", "6h", "7h", "8h", "9h", "10h", "Jh", "Qh", "Kh", "As", "2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s", "10s", "Js", "Qs", "Ks" }
	print("1", table.concat( tDeck ) )
	--math.randomseed(os.time())
	for k = 1,52 do
		local pos = math.random(52)
		local card = tDeck[pos]
		table.remove(tDeck, pos)
		table.insert(tDeck, card)
	end
	print("1", table.concat( tDeck ) )
	--SendToAll(sBotName, "Shuffeling deck...")
end
Shuffle()

Shuffle2 = function()
	local tDeck = { "Ac", "2c", "3c", "4c", "5c", "6c", "7c", "8c", "9c", "10c", "Jc", "Qc", "Kc", "Ad", "2d", "3d", "4d", "5d", "6d", "7d", "8d", "9d", "10d", "Jd", "Qd", "Kd", "Ah", "2h", "3h", "4h", "5h", "6h", "7h", "8h", "9h", "10h", "Jh", "Qh", "Kh", "As", "2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s", "10s", "Js", "Qs", "Ks" }
	print("2", table.concat( tDeck ) )
	--math.randomseed(os.time())
	local newDeck = {}
	for i = 52,1,-1 do
		local pos = math.random(i)
		local card = tDeck[pos]
		table.remove(tDeck, pos)
		table.insert(newDeck, card)
	end
	print("2", table.concat( newDeck ) )
	--SendToAll(sBotName, "Shuffeling deck...")
end
Shuffle2()

2 more shuffles, I can't really tell if either one is better, or how to check for a good mix
Code: lua
Shuffle3 = function()
	local tDeck = { "Ac", "2c", "3c", "4c", "5c", "6c", "7c", "8c", "9c", "10c", "Jc", "Qc", "Kc", "Ad", "2d", "3d", "4d", "5d", "6d", "7d", "8d", "9d", "10d", "Jd", "Qd", "Kd", "Ah", "2h", "3h", "4h", "5h", "6h", "7h", "8h", "9h", "10h", "Jh", "Qh", "Kh", "As", "2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s", "10s", "Js", "Qs", "Ks" }
	print("3", table.concat( tDeck ) )
	--math.randomseed(os.time())
	local newDeck = {}
	for i = 52,1,-1 do
		local pos = math.random(i)
		local card = tDeck[pos]
		tDeck[pos] = tDeck[i]
		table.insert(newDeck, card)
	end
	print("3", table.concat( newDeck ) )
	--SendToAll(sBotName, "Shuffeling deck...")
end
Shuffle3()

Shuffle4 = function()
	local tDeck = { "Ac", "2c", "3c", "4c", "5c", "6c", "7c", "8c", "9c", "10c", "Jc", "Qc", "Kc", "Ad", "2d", "3d", "4d", "5d", "6d", "7d", "8d", "9d", "10d", "Jd", "Qd", "Kd", "Ah", "2h", "3h", "4h", "5h", "6h", "7h", "8h", "9h", "10h", "Jh", "Qh", "Kh", "As", "2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s", "10s", "Js", "Qs", "Ks" }
	print("4", table.concat( tDeck ) )
	--math.randomseed(os.time())
	local newDeck = {}
	for i = 52,1,-1 do
		local pos = math.random(i)
		local card = tDeck[pos]
		tDeck[pos] = tDeck[i]
		table.insert(newDeck, math.random(53-i), card)
	end
	print("4", table.concat( newDeck ) )
	--SendToAll(sBotName, "Shuffeling deck...")
end
Shuffle4()

BrotherBear

Quote from: CrazyGuy on 03 February, 2007, 21:09:46
Thank you all ;D

No this 1 won't be able to play in PM (neither does the Blackjack script), but the idea is to make both scripts part of a bigger 'Casino' script.
Then they will run as chatrooms, but I havent started on that yet.

Thank YOU CrazyGuy, looking forward to this :)

Regards,

BrotherBear

CrazyGuy

ChillCode,

I know the score checking code doesn't look optimal, but yea, it was the best I could come up with, and I've spend some time trying a few ways.
I seed the randomizer with os.time as math.random only gives a pseudorandom number. If you finish the script quickly, you might see a pattern occur.
As os.time() changes constantly, it should create a more random effect, and I havent noticed (but not monitored) exactly who get which cards. Seeding the randomizer with os.time() is actually something I took from a C++ game designing book.
But I'll look into if it is random enough.
I played 10 hands to see if a pattern occurs.
The only thing noticeable (if at all) is the 3 times Jh as second card
So I'd call it random enough.
Unless some1 disagrees, I will keep it the way it is

Quote
[14:56:01] <?Poker?> Your cards : 7s  Jh   <Table>  Kc   8h  Js     7d     4h
[14:56:51] <?Poker?> Your cards : 6c  Jh   <Table>  Ac   8s  5c     5h  10c
[14:57:34] <?Poker?> Your cards : 10s  4d   <Table>  3s   2d  As   10h     Jc
[14:58:19] <?Poker?> Your cards : 3c  Js   <Table>  2h   5s  7s     7d     Ks
[14:59:01] <?Poker?> Your cards : 8s  8c   <Table>  Ac   Kc  2s    5d     5h
[15:00:02] <?Poker?> Your cards : Ac  Qh   <Table>  7d   5d   Kd   9c     2s
[15:00:54] <?Poker?> Your cards : 4d  6d   <Table> 10s  8h   4c   Ad     Ah
[15:01:46] <?Poker?> Your cards : 7d  Jh   <Table>  9s   6d   5s    Jd      4s
[15:02:30] <?Poker?> Your cards : As  3c   <Table>  Qd  3s   9c  10d     Jd
[15:03:23] <?Poker?> Your cards : Jc  10d   <Table>  3d   5c  6d    2c    Qd

CHILLCODE?

sure it was just suggestion since when I run the shuffle codes i get this
> dofile( "shuffle.lua" )
1       Ac2c3c4c5c6c7c8c9c10cJcQcKcAd2d3d4d5d6d7d8d9d10dJdQdKdAh2h3h4h5h6h7h8h9h10hJhQhKhAs2s3s4s5s6s7s8s9s10sJsQsKs
1       3c6c8c9c10cJc3d6d10dQdKd5h6hQh2s4s6s8sJsQsKs7cKh9sAc2dAh9h5d4d7d7s4h10s2c10h9d4c8h5s3sJhJdKcAd5c7hAs3h2hQc8d

2       Ac2c3c4c5c6c7c8c9c10cJcQcKcAd2d3d4d5d6d7d8d9d10dJdQdKdAh2h3h4h5h6h7h8h9h10hJhQhKhAs2s3s4s5s6s7s8s9s10sJsQsKs
2       10dAc7s8c2d4dJh5hQs7h3s9d4sQh7cAh2c3cAs6d9sQd2s5c6h4c9hKsKd10hKc6s3h2hQc8s7dKhAd6c8d4h5d3d9cJd5sJsJc10s10c8h

3       Ac2c3c4c5c6c7c8c9c10cJcQcKcAd2d3d4d5d6d7d8d9d10dJdQdKdAh2h3h4h5h6h7h8h9h10hJhQhKhAs2s3s4s5s6s7s8s9s10sJsQsKs
3       AcJs5s9d8h3d2h10dQd2c8s10cQh9sJh6s10s3cAdJc3s9hAh9c10hKd6h6c7cKc7dQsJdKh4h4c4d7sAs8cKs7hQc8d5h4s2s2d5c6d3h5d

4       Ac2c3c4c5c6c7c8c9c10cJcQcKcAd2d3d4d5d6d7d8d9d10dJdQdKdAh2h3h4h5h6h7h8h9h10hJhQhKhAs2s3s4s5s6s7s8s9s10sJsQsKs
4       10s3cKc3d4s7dQd2c9cAcQc4d3s8sAh4hAd6dQs9s2s7s5s10h10dJs6s7c5c7hJhAs5d6cJc10c3h8c6h2h2d8hJdQhKs9h4cKhKd9d5h8d
> dofile( "shuffle.lua" )
1       Ac2c3c4c5c6c7c8c9c10cJcQcKcAd2d3d4d5d6d7d8d9d10dJdQdKdAh2h3h4h5h6h7h8h9h10hJhQhKhAs2s3s4s5s6s7s8s9s10sJsQsKs
1       Ac6c8cQc2d3d9d10dJdQd2h6h8h9h10hJhAs5sQs7h9cKc6d7s4dKdAh3cKhKs4hJs4c5d4s10s6sAdQh2c5c2s7c5h10c3h8sJc9s7d8d3s

2       Ac2c3c4c5c6c7c8c9c10cJcQcKcAd2d3d4d5d6d7d8d9d10dJdQdKdAh2h3h4h5h6h7h8h9h10hJhQhKhAs2s3s4s5s6s7s8s9s10sJsQsKs
2       Kc3d3cKs10c5c2d7d3s9h6c5d9c4d7hQcJh7c3h5sJd2c10d2s9s8h8s8c6sQs6h5h4h10hAdJs6dAc9dQdAh4s8d10s2hAsJc4cKhQhKd7s

3       Ac2c3c4c5c6c7c8c9c10cJcQcKcAd2d3d4d5d6d7d8d9d10dJdQdKdAh2h3h4h5h6h7h8h9h10hJhQhKhAs2s3s4s5s6s7s8s9s10sJsQsKs
3       QsQc6s5d7s6h10cKc3d10dJs9s4c5cAh8sQd3hAc4d7d9h9c10s8dJdQh2h2d8c5hAsJcAd4s7h2c7c8h4h10h5s3cJhKd6c6d2s9dKhKs3s

4       Ac2c3c4c5c6c7c8c9c10cJcQcKcAd2d3d4d5d6d7d8d9d10dJdQdKdAh2h3h4h5h6h7h8h9h10hJhQhKhAs2s3s4s5s6s7s8s9s10sJsQsKs
4       6s8s9cJhAd2h10dQc8h9d2cAh3d6h9h5c4c3h10s7sKdQh10h9sQdAs2d3sJc5dJd8d4h2sAc4s5hKh8cJs3cKs6cQs5s7cKc7h7d6d4d10c


so he first 2 are your shuffel function, and it shows a lot of c's I think, and then you use this code
Code: lua
DealCard = function(iPlayer)
	local icard = table.getn(tHands[tPlayers[iPlayer]]) + 1
	local card = table.remove(tDeck)
	tHands[tPlayers[iPlayer]][icard] = card
end

to deal a card what always takes the last card, and with that I would have thaught the possibility is a bit lower seeing that most of the c cards are at the beginning of the table, just a thaught

SMF spam blocked by CleanTalk