Author Topic: TI-nspire Hold 'em - Basic and Lua  (Read 28308 times)

0 Members and 1 Guest are viewing this topic.

Offline Rhombicuboctahedron

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 437
  • Rating: +41/-6
    • View Profile
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #15 on: October 13, 2012, 07:07:52 pm »
I stole (borrowed) some of Jim’s Klondike code, and made what I thought a general template might be. The code is very inefficient, but it gets the job done.

I also looked at your plan
1. Determine what type of hand a player has.
Well, if you understand the code that the BASIC version used, you should just be able to transcribe this. Otherwise, just compare the seven cards, and return the rank of the hand (1 for straight flush, 2 for four of a kind, ect) and the highest card of that set (1 for ace, 2 for king) and compare the ranks, and if the same, the highest card

I made a general template that shows two random (and I believe never the same) cards, and then the five cards one at a time. If I remember how to play the game.


Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #16 on: October 14, 2012, 08:16:36 am »
My Klondike game is one of the first things I made, my code isn't that good. But if it helps you, go ahead and dig through it :)


Offline Rhombicuboctahedron

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 437
  • Rating: +41/-6
    • View Profile
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #17 on: October 14, 2012, 08:22:58 am »
Maybe, but I’m not very good at thinking of different ways of programming or making a program more efficient. All the lua programs that I have ever made have all had only one paint section , and I would just program it with if this screen, then paint this, if this screen, then paint this, ect.

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #18 on: October 15, 2012, 08:52:03 pm »
Oh wow in total that's a lot of changes I need to look through. If I continue forward with this, I'll make sure to credit you and Jimbauwens as well.
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #19 on: October 16, 2012, 09:41:34 pm »
Okay, I changed it a little to get it to work, but a big problem was that you were trying to compare a number and a string.
However, I noticed that if you multiply the string of a number by one, it makes it that number.
Also, I moved the congrats and correcting strings into the function on.paint(gc) section
My changes are probably w=quite ugly and inefficient, but it gets all the way to the “lets get rolling” string

Code: [Select]
--[[TI-nspire Hold 'em - A Lua Remake
History:
v0.01 Created 2012/09/23 really started working 2012/10/07
Buggy can hardly do anything, currently can change Chips, Big Blind, Small Blind]]--

function init_variables()
  cc=0
  bb=0
  sb=0
  gopt=1
  scrn=1
  message=""
end

init_variables()
 
 function on.paint(gc)
    gc:setFont("sansserif","r",10)
    gc:setColorRGB(0,0,0)
  -- gc:setPen("thin","smooth")  Is this necessary?
  if scrn==1 then
   gc:drawString("[c] Chips        " .. cc,10,10,"top")
   gc:drawString("[b] Big Blind    " .. bb,10,25,"top")
   gc:drawString("[s] Small Blind  " .. sb,10,40,"top")
   gc:drawRect(10,70,20,20)
   if message=="wrong" then
       gc:drawString("Check these conditions",10,70,"top")
    gc:drawString("Chips between 100 and 10 million",10,85,"top")
    gc:drawString("Big blind between 0.001 and 0.1 Chips",10,100,"top")
    gc:drawString("Small blind between 0.01 and 0.5 Big Blind",10,115,"top")
    end
  elseif scrn==3 then
   gc:drawString("Right let's get rolling!",10,10,"top")
  end
  if scrn==2 then
   if message=="congrats" then
    gc:drawString("Congrats! Settings set up correctly",10,70,"top")
   end
   end
 end

function on.charIn(ch)
  if ch >= "0" and ch <= "9" then    -- checking for digit inputs
   if scrn==1 then
    if gopt==1 then
     if string.len(cc) <= 7 then   -- limit string length
      cc = cc .. ch            -- concatenate
      platform.window:invalidate()   -- screen refresh
     end
    elseif gopt==2 then
     if string.len(bb) <= 6 then -- and sb <= 0.1bb then   -- limit string length and bb to <= 0.1cc (now moved)
      bb = bb .. ch            -- concatenate
      platform.window:invalidate()   -- screen refresh
     end
    elseif gopt==3 then
     if string.len(sb) <= 6 then -- and sb <= 0.1bb then   -- limit string length and sb to <= 0.1bb (now moved)
      sb = sb .. ch            -- concatenate
      platform.window:invalidate()   -- screen refresh
     end
    end
   end
  end
--Game settings keys
  if scrn==1 then
   if ch=="c" then     --Ok there must be a way to optimise this block
    gopt = 1   
  elseif ch=="b" then
    gopt = 2
   elseif ch=="s" then
    gopt = 3
   end
   platform.window:invalidate()
  end
end

function on.enterKey()
cc=1*cc
bb=1*bb
sb=1*sb
  if scrn==2 then
   scrn=3
  end
  if scrn==1 and cc >= 100 and cc <= 10000000 and bb >= 0.001*cc and bb <= 0.1*cc and sb >= 0.01*bb and sb <= 0.5*bb then
    message="congrats"
    scrn=2
    gopt=0
   else
    message="wrong"
   end
   
end

function on.backspaceKey()
  if gopt==1 then     --Ok there must be a way to optimise this block. Again.
   cc = string.usub(cc,0,-2)  -- deleting last char
    elseif gopt==2 then
   bb = string.usub(bb,0,-2)  -- deleting last char
 elseif gopt==3 then
   sb = string.usub(sb,0,-2)  -- deleting last char
 end
    platform.window:invalidate() 
end

platform.window:invalidate()

OMG Thank you. I didn't realise before all the work you did into fixing it (how do you do it so quickly and efficiently?) but yes I detected the problem comparing the number with the string but I didn't know how to fix that.
I'll probably remove the congrats setup messages as I move on. That was just a visual indication to test if it worked (which it obviously didn't). Also will change the c b s keys to just moving up and down with arrow keys or something.

My Klondike game is one of the first things I made, my code isn't that good. But if it helps you, go ahead and dig through it :)


That would help, thanks.
« Last Edit: October 16, 2012, 09:42:13 pm by Jonius7 »
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Offline Rhombicuboctahedron

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 437
  • Rating: +41/-6
    • View Profile
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #20 on: October 16, 2012, 10:58:29 pm »
Thanks.
Since (I think) you programmed the basic hold em, all you need to do is transcribe the winner detection process, and then make an ai.
Also, maybe an idea would be to check the blinds ever time they are updated, by making a separate class, and displaying the number in red if does not suit the criteria.

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #21 on: October 16, 2012, 11:40:25 pm »
Yep. I programmed the original TI-nspire Hold 'em Basic, and started working on this Lua version. The winner detection process and increasing blinds haven't been implemented in the Basic version yet however.
« Last Edit: October 16, 2012, 11:40:38 pm by Jonius7 »
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Offline Rhombicuboctahedron

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 437
  • Rating: +41/-6
    • View Profile
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #22 on: October 17, 2012, 11:04:27 am »
I think this might be a better way to access all the different things.
Instead of a call key, a raise key, a bet key, a done key, or whatever you need, you might want to incorporate a menu, so you just press menu to access the different options.
Some example code would be from a lua painter project a worked several months ago.

Code: [Select]
function black()
rcurrent=0
gcurrent=0
bcurrent=0
end
function red()
rcurrent=255
gcurrent=0
bcurrent=0
end
function orange()
rcurrent=255
gcurrent=128
bcurrent=0
end
function yellow()
rcurrent=255
gcurrent=255
bcurrent=0
end
function green()
rcurrent=0
gcurrent=255
bcurrent=0
end
function blue()
rcurrent=0
gcurrent=0
bcurrent=255
end
function violet()
rcurrent=255
gcurrent=0
bcurrent=255
end
function other()
drawcolor=1
drawwindow=0
platform.window:invalidane()
end
function thin()
linecurrent="thin"
end
function medium()
linecurrent="medium"
end
function thick()
linecurrent="thick"
end
function eraser()
linecurrent="thick"
rcurrent=255
gcurrent=255
bcurrent=255
end
menu={}
menu[1]={}
menu[1][1]="color"
menu[1][2]={"black",black}
menu[1][3]={"red",red}
menu[1][4]={"orange",orange}
menu[1][5]={"yellow",yellow}
menu[1][6]={"green",green}
menu[1][7]={"blue",blue}
menu[1][8]={"violet",violet}
menu[1][9]={"other",other}
menu[2]={}
menu[2][1]="thickness"
menu[2][2]={"thin",thin}
menu[2][3]={"medium",medium}
menu[2][4]={"thick",thick}
menu[3]={"eraser",{"eraser",eraser}}
toolpalette.register(menu)

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #23 on: October 17, 2012, 06:44:37 pm »
Yes that's a good idea, I'll see what I can do with that, though programming arrow keys to move up and down the menu would still be useful.

EDIT: 1700 posts!
« Last Edit: October 17, 2012, 06:48:56 pm by Jonius7 »
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Offline Rhombicuboctahedron

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 437
  • Rating: +41/-6
    • View Profile
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #24 on: October 17, 2012, 07:51:44 pm »
Oh, no. The toolpalette.register(menu) makes the menu the type of menu you see when you press menu on a document, except instead of 1: Actions 2: Number, you see call, bet, restart, ect.

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #25 on: January 28, 2013, 11:04:12 pm »
I am going to try continuing this... AGAIN.
Still that piece of code up there took close to over 7 hours?
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Offline Rhombicuboctahedron

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 437
  • Rating: +41/-6
    • View Profile
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #26 on: January 28, 2013, 11:12:58 pm »
I am going to try continuing this... AGAIN.
Still that piece of code up there took close to over 7 hours?
Which code? (I posted three things, and don't remember specifying te length)
And good luck!

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #27 on: January 29, 2013, 02:39:42 am »
Sorry I meant my own code, vaguely, it took me many hours just to get to that stage. And it's not even 10% complete.
« Last Edit: January 29, 2013, 02:40:04 am by Jonius7 »
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Offline Rhombicuboctahedron

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 437
  • Rating: +41/-6
    • View Profile
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #28 on: January 29, 2013, 07:31:26 am »
Oh, that question mark confused me

Well luckily (:)) for you it seems like the hardest code for you is setting up the template.
You might find it easier once you just start programming the general gameplay and ai, because you’ll just be transcribing you menu game.

If you need any help, just post anything here.

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #29 on: June 30, 2013, 01:41:38 am »
Hope to get back into this soon. And Lua Programming in general.
Also I didn't realise my v1.2.4 didn't release on ticalc.org or on here either.
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)