POKER

Vragen en suggesties over het programmeren van spelletjes, sprites en dergelijke in Liberty BASIC

Moderator: anthonio

POKER

Berichtdoor bluatigro » vr sep 26, 2014 11:14 am

probeersel : poker

ik heb de hand evaluatie nu goed [ denk ik ]

Code: Selecteer alles
dim k(51) , h( 9 , 4 ) , hd( 4 )
global color$ , number$
color$ = "klover diamonds hearts spades"
number$ = "2 3 4 5 6 7 8 9 10 jack queen king ace"

for k = 0 to 51
  k( k ) = k
next k
for k = 0 to 51
  dice = int( rnd(0) * 52 )
  h = k( k )
  k( k ) = k( dice )
  k( dice ) = h
next k
for h = 0 to 5
  print "hand " ; h
  for k = 0 to 4
    h( h , k ) = k( k + h * 5 )
    print card$( h( h , k ) ) ; " " ;
  next k
  print
  print hand$( h )
next h
end
function hand$( no )
  for i = 0 to 4
    hd( i ) = h( no , i )
  next i
''sort hand on number
  for h = 1 to 4
    for l = 0 to h
      if nr(hd(h)) < nr(hd(h)) then
        help = hd( h )
        hd(h) = hd(l)
        hd(l) = help
      end if
    next l
  next h
''this is a sorted hand : easyer handeling for getting points
''  hand$ = card$(hd(0)) _
''  ; " " ; card$(hd(1)) _
''  ; " " ; card$(hd(2)) _
''  ; " " ; card$(hd(3)) _
''  ; " " ; card$(hd(4))
  points = nr(hd(0))+nr(hd(1))+nr(hd(2))+nr(hd(3))+nr(hd(4))
  uit$ = "high card | " ; points
  ''check one pair
  if nr(hd(0))=nr(hd(1)) _
  or nr(hd(1))=nr(hd(2)) _
  or nr(hd(2))=nr(hd(3)) _
  or nr(hd(3))=nr(hd(4)) then
    uit$ = "one pair | " ; points
  end if
  ''check two pair
  if ( nr(hd(0))=nr(hd(1)) _
    and nr(hd(2))=nr(hd(3)) ) _
  or ( nr(hd(0))=nr(hd(1)) _
    and nr(hd(3))=nr(hd(4)) ) _
  or ( nr(hd(1))=nr(hd(2)) _
    and nr(hd(3))=nr(hd(4)) ) then
     uit$ = "two pair | " ; points
  end if
  ''check tree of a kind
  if ( nr(hd(0))=nr(hd(1)) _
    and nr(hd(1))=nr(hd(2)) ) _
  or ( nr(hd(1))=nr(hd(2)) _
    and nr(hd(2))=nr(hd(3)) ) _
  or ( nr(hd(2))=nr(hd(3)) _
    and nr(hd(3))=nr(hd(4)) ) then
      uit$ = "tree of a kind | " ; points
  end if
  ''check strait
  if nr(hd(0))=nr(hd(1))-1 _
  and nr(hd(1))=nr(hd(2))-1 _
  and nr(hd(2))=nr(hd(3))-1 _
  and nr(hd(3))=nr(hd(4))-1 then
    uit$ = "strait | " ; points
  end if
  ''check full house
  if nr(hd(0))=nr(hd(1)) _
  and nr(hd(3))=nr(hd(4)) _
  and ( nr(hd(2))=nr(hd(1)) _
    or nr(hd(2))=nr(hd(3)) ) then
      uit$ = "full house | " ; points
  end if
  ''check 4 of a kind
  if ( nr(hd(0))=nr(hd(1)) _
    and nr(hd(1))=nr(hd(2)) _
    and nr(hd(2))=nr(hd(3)) ) _
  or ( nr(hd(1))=nr(hd(2)) _
    and nr(hd(2))=nr(hd(3)) _
    and nr(hd(3))=nr(hd(4)) ) then
    uit$ = "for of a kind | " ; points
  end if
  ''check strait flush
  if kl(hd(0))=kl(hd(1)) _
  and kl(hd(1))=kl(hd(2)) _
  and kl(hd(2))=kl(hd(3)) _
  and kl(hd(3))=kl(hd(4)) then
    if nr(hd(0))=nr(hd(1))-1 _
    and nr(hd(1))=nr(hd(2))-1 _
    and nr(hd(2))=nr(hd(3))-1 _
    and nr(hd(3))=nr(hd(4))-1 then
      uit$ = "strait flush | " ; points
    else
      uit$ = "flush | " ; points
    end if
  end if
  hand$ = uit$
end function
function card$( no )
  kl$ = word$( color$ , kl( no ) )
  nr$ = word$( number$ , nr( no ) )
  card$ = kl$ + " " + nr$
end function
function kl( no )
  kl = int( no / 13 ) + 1
end function
function nr( no )
  nr = no mod 13 + 1
end function
bluatigro
 
Berichten: 306
Geregistreerd: za sep 27, 2008 6:01 pm

Keer terug naar Games

Wie is er online

Gebruikers op dit forum: Geen geregistreerde gebruikers. en 1 gast

cron