Liberty BASIC Community Forum
« One Card Poker - Nov. 23, 2011 »

Welcome Guest. Please Login or Register.
Oct 23rd, 2017, 5:28pm


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: One Card Poker - Nov. 23, 2011  (Read 545 times)
Noble D. Bell
Moderator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 931
xx One Card Poker - Nov. 23, 2011
« Thread started on: Nov 23rd, 2011, 1:11pm »

For those of you in North America -- Happy Thanksgiving!!

This will be the final challenge of the year. I will restart in January 2012. I have to work on some new ones, you all are good at this!!

I promise this will keep you busy for a little while. smiley

The game of one-card poker has a three-card deck, an ace, deuce, and trey. The ace is lowest and the trey is highest. Each of two players ante $1 into the pot. Then, each player gets one card. The order of betting is predetermined, with player 1 to act first. Player 1 may either bet $1 or check. If player 1 bets, player 2 may either call or fold. If player 1 checks, player 2 may either bet $1 or check. If player 1 checks, and player 2 bets, then player 1 may either call or fold. If both players check, or one bets and one calls, then the higher card wins the pot. Assuming both players are perfect logicians, what is the optimal strategy for each player?

Write an LB program to simulate different outcomes to determine what the optimal strategy is for each player.

Enjoy and have a great and safe rest of 2011. See you in 2012.

User IP Logged

Thank you and God bless,
Noble D. Bell
http://www.noblebell.com
bluatigro
Guru
ImageImageImageImageImage


member is offline

Avatar

cxiu diversas el tio respondas cxiu samvaloras [ thats esperanto for : we are al different therefore we are al equal ]


PM

Gender: Male
Posts: 919
xx Re: One Card Poker - Nov. 23, 2011
« Reply #1 on: Apr 27th, 2012, 03:36am »

i tryed to create a truth table
i think i made a mistake somwere

i was thinking about using a Genetic Algoritm
but evalgame1 and evalgame2 wil give diferent
results i think
i m not even shure if a GA wil find a solution
i know how to write a fitnes-function
if there is only 1 outcome
but whit 2 ?
and los of player1 = win of player2
the only thing i can think of is
calculating the solutoins seperately

using brute force wil take to mutch time i think


some thinking :
if player1 has a 'perfect' solution then player2 knows it to
and vise versa
wil this not create a infinte think-loop ?
Code:
global tot1 , tot2 ''total cash player
global bet1 , bet2
global bet , check , cal , fold
bet = 1
check = 0
cal = 2
fold = 3
print "      |bet    |bet    |check  |check  |check"
print "      |call   |fold   |bet    |bet    |check"
print "cards |       |       |call   |fold   |"
  for card1 = 0 to 2
    for c = 1 to 2
      print card1 + 1 ; " + " ;
      card2 = ( card1 + c ) mod 3
      print card2 + 1 ; " |  " ;
      for play = 0 to 4
        tot1 = 3
        tot2 = 3
        call evalgame2 play , card1 , card2
        print tot1 ; " " ; tot2 ; "  |  " ;
      next play
      print
    next c
  next card1
end
sub evalgame2 no , carda , cardb
  select case no
    case 0 '' bet call
      bet1 = 2
      bet2 = 2
      call evalcards carda , cardb
    case 1 '' bet fold
      bet1 = 2
      bet2 = 1
      tot1 = tot1 + bet2
      tot2 = tot2 - bet2
      exit sub
    case 2 '' check bet call
      bet1 = 2
      bet2 = 2
      call evalcards carda , crarb
    case 3 '' check bet fold
      bet1 = 1
      bet2 = 2
      tot1 = tot1 - bet1
      tot2 = tot2 + bet1
    case else '' check check
      bet1 = 1
      bet2 = 1
      call evalcards carda , cradb
  end select
end sub
sub evalgame1 a , b , c , carda , cardb
  if a = bet then
    bet1 = bet1 + 1
    if b = cal then
      bet2 = bet2 + 1
      call evalcards carda , cardb
    else ''b = fold
      tot1 = tot1 + bet2
      tot2 = tot2 - bet2
    end if
  else ''a = check
    if b = bet then
      bet2 = bet2 + 1
      if c = cal then
        bet1 = bet1 + 1
        call evalcards carda , cardb
      else ''c = fold
        tot1 = tot1 - bet1
        tot2 = tot2 + bet2
      end if
    else ''b = check
      call evalcards carda , cardb
    end if
  end if
end sub
sub evalcards carda , cardb
  if carda < cardb then
    tot1 = tot1 - bet1
    tot2 = tot2 + bet1
  else
    if carda > cardb then
      tot1 = tot1 + bet2
      tot2 = tot2 - bet2
    end if
  end if
end sub
 
User IP Logged

basic's : C64 Simons C128 Amiga Amos quick4.5 Visual5 Visual6 Visual2005 Visual2008 just and last but not least liberty
bluatigro
Guru
ImageImageImageImageImage


member is offline

Avatar

cxiu diversas el tio respondas cxiu samvaloras [ thats esperanto for : we are al different therefore we are al equal ]


PM

Gender: Male
Posts: 919
xx Re: One Card Poker - Nov. 23, 2011
« Reply #2 on: Apr 27th, 2012, 03:48am »

found a typo

there is only 1 problem whit this :
- i stil dont know the best solution for eather

Code:
global tot1 , tot2 ''total cash player
global bet1 , bet2
global bet , check , cal , fold
global prog1$ , prog2$ , l1 , l2
bet = 1
check = 0
cal = 2
fold = 3
print "      |bet    |bet    |check  |check  |check"
print "      |call   |fold   |bet    |bet    |check"
print "cards |       |       |call   |fold   |"
  for card1 = 0 to 2
    for c = 1 to 2
      print card1 + 1 ; " + " ;
      card2 = ( card1 + c ) mod 3
      print card2 + 1 ; " |  " ;
      for play = 0 to 4
        tot1 = 3
        tot2 = 3
        call evalgame2 play , card1 , card2
        print tot1 ; " " ; tot2 ; "  |  " ;
      next play
      print
    next c
  next card1
end
sub evalgame2 no , a , b
  select case no
    case 0 '' bet call
      bet1 = 2
      bet2 = 2
      call evalcards a , b
    case 1 '' bet fold
      bet1 = 2
      bet2 = 1
      tot1 = tot1 + bet2
      tot2 = tot2 - bet2
      exit sub
    case 2 '' check bet call
      bet1 = 2
      bet2 = 2
      call evalcards a , b
    case 3 '' check bet fold
      bet1 = 1
      bet2 = 2
      tot1 = tot1 - bet1
      tot2 = tot2 + bet1
    case else '' check check
      bet1 = 1
      bet2 = 1
      call evalcards a , b
  end select
end sub
sub evalgame1 a , b , c , carda , cardb
  if a = bet then
    bet1 = bet1 + 1
    if b = cal then
      bet2 = bet2 + 1
      call evalcards carda , cardb
    else ''b = fold
      tot1 = tot1 + bet2
      tot2 = tot2 - bet2
    end if
  else ''a = check
    if b = bet then
      bet2 = bet2 + 1
      if c = cal then
        bet1 = bet1 + 1
        call evalcards carda , cardb
      else ''c = fold
        tot1 = tot1 - bet1
        tot2 = tot2 + bet2
      end if
    else ''b = check
      call evalcards carda , cardb
    end if
  end if
end sub
sub evalcards a , b
  if a < b then
    tot1 = tot1 - bet1
    tot2 = tot2 + bet1
  end if
  if a > b then
    tot1 = tot1 + bet2
    tot2 = tot2 - bet2
  end if
end sub
 
User IP Logged

basic's : C64 Simons C128 Amiga Amos quick4.5 Visual5 Visual6 Visual2005 Visual2008 just and last but not least liberty
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls