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

0 Members and 1 Guest are viewing this topic.

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
TI-nspire Hold 'em - Basic and Lua
« on: April 11, 2012, 08:27:02 am »
Hi,

When I got the TI-nspire Clickpad in 2010, there was one game that I started developing in May, before anything else...
This game has 2400+ downloads on ticalc.org... is my most completed TI-nspire Basic game... certainly my most well known (expect for possibly Health Bar :P)...
Considering I had topics for my other (incomplete and possibly stalled) projects, I did not have a topic for my best game:

(Jason's) TI-nspire Holdem! (click for ticalc.org link!)

I have decided to create this long overdue topic to post on past and current progresses in this game!
This project has a bright future, where I have (mostly) finished with the Basic version, it has great potential for a great graphical Lua game!


I must also say that this program was originally based on Matt Oslan's poker dealer game (which is was the most downloaded TI-nspire Basic Game O.O)
However it has evolved and is now completely different, possibly using 90% now using 98% of my own code.

In my latest version yet to be released I have made huge optimisations in cuttting down some programs from 157 lines of code to just 3 315 lines to 5 and 472 lines to 7 by adding a list somewhere in another program linked to it.

My focus now is shifting development to adding detection of poker hands (determining whether you have a royal flush or a pair for eg) and AI. With Lua I can also develop a graphical interface too!

This topic will have it all. (well maybe not). I need to make another announcement about my (new) website too. http://www.tistadium.co.cc (which is currently down and gone :O)

Latest BASIC version: v1.2.4

« Last Edit: November 21, 2012, 07:05:06 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 ElementCoder

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 611
  • Rating: +42/-2
    • View Profile
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #1 on: April 11, 2012, 10:56:07 am »
Lua sounds great! I'll definitely want to see that happen.  :D
Seeing how you improved your code, let's say it sounds very familiar XD Especially with my current project :P

P.S. Your list of programs in your stadium seems interesting. Is there a possibility I could have a look at the source/get all of em?

Some people need a high five in the face... with a chair.
~EC

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 #2 on: April 11, 2012, 11:52:22 am »
Lua sounds great! I'll definitely want to see that happen.  :D
Seeing how you improved your code, let's say it sounds very familiar XD Especially with my current project :P

P.S. Your list of programs in your stadium seems interesting. Is there a possibility I could have a look at the source/get all of em?

It sounds very familiar? To what? I did create this game waaaay back in May 2010

Yes ElementCoder I have thought about releasing the source code and stuff. I have already released a whole rar file with most of my project in there in my General Projects Topic
http://ourl.ca/15462
« Last Edit: April 11, 2012, 11:53:28 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 ElementCoder

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 611
  • Rating: +42/-2
    • View Profile
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #3 on: April 11, 2012, 02:04:36 pm »
It sounds very familiar? To what?
I mean reducing many lines of code into just a few lines. (say 300 to 20 becuase loops are more useful :P)

Some people need a high five in the face... with a chair.
~EC

Offline AzNg0d1030

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 522
  • Rating: +45/-4
  • Hardcore anime watcher.
    • View Profile
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #4 on: April 12, 2012, 04:49:29 am »
Jonius7, would you mind posting a screenie?
You just lost the game.



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 #5 on: April 13, 2012, 02:33:10 am »
Oh sorry I attached that quickly. All info is on the ticalc.org upload with some nice screenies!
http://www.ticalc.org/archives/files/fileinfo/430/43059.html
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 #6 on: September 10, 2012, 01:27:12 am »
Jason's TI-nspire Hold 'em has reached 3000 downloads!
http://www.ticalc.org/archives/files/fileinfo/430/43059.html

I shall soon be uploading a 'master' plan for my intentions of taking this game to a whole new level.
« Last Edit: September 10, 2012, 01:29:08 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 AzNg0d1030

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 522
  • Rating: +45/-4
  • Hardcore anime watcher.
    • View Profile
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #7 on: September 10, 2012, 04:42:06 pm »
Jason's TI-nspire Hold 'em has reached 3000 downloads!
http://www.ticalc.org/archives/files/fileinfo/430/43059.html

I shall soon be uploading a 'master' plan for my intentions of taking this game to a whole new level.
Congrats and good job! (from customer)
You just lost the game.



Offline blfngl

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 121
  • Rating: +3/-4
  • No worry, I'll surpass Calc84 in greatness...never
    • View Profile
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #8 on: September 10, 2012, 06:01:17 pm »
Ooooh I was gonna make that >:( but nice job! :thumbsup:
« Last Edit: September 10, 2012, 06:01:28 pm by blfngl »
GAMEGAMEGAMEGAMEGAMEGAMEGAMEGAMEGAMEGAME
My blog:

TiLibs
My Projects:
Minecraft Library

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 #9 on: September 19, 2012, 11:53:01 pm »
As I said there is a poker dealer game out there already from Matt Oslan (it is the most downloaded TI-nspire Game on ticalc.org O.O) but I decided that it just wasn't good enough. Over time I have recoded pretty much every part of the program so it is my program now pretty much.

I need to get more familiar with Lua first, but here is a general progression plan (not restricted to language)

1. Determine what type of hand a player has.
This is quite an essential step in figuring out the poker hand rankings and where it stands. I have partially tried to do this and I have an idea (convert cards to number values in a matrix or list and compare values directly) More details later

2. Able to compare hands and determine the winner of a player
Previous point must be completed.

3. Begin a simple Computer AI that can compare hands and (possibly?) play for itself
After the program can determine poker hands, an AI can then be programmed in.

4. Add in more than 2 players
This will increase the complexity and I will have to reprogram some 2 player specific elements for this to work.

5. More complex AI
Details include better detection and prediction at whether others have good hands, when to fold (eg: fold if too many players are completing), when to bluff. Generally I have to know a lot about how to play the game myself in order to be able to have AN IDEA how to program it.

EDIT: I shall put this in the first post eventually...
« Last Edit: October 09, 2012, 12:48:09 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 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 #10 on: October 09, 2012, 12:55:15 am »
A few days (maybe a week) ago I went through TI-nspire Hold 'em and optimised and added some things. I was nearly going to call it v1.3 but currently it's v1.2.4. Most importantly, I fixed up the all-in bug where no matter what happens, one player loses all his/her chips and the game ends. Just deleting two lines of code where I had put 0 -> [variable] fixed it all up!

Putting this up on ticalc.org as soon as is reasonable for me to set this time aside.
http://www.ticalc.org/archives/files/fileinfo/430/43059.html

I've been thinking about a Lua version all the time, and I am still trying to think on how to progress on this. It will be slow progress but I also have limited time to keep to big picture of what I want the program to look like (clearly a much higher standard than the Basic version right now, [maybe I'm setting standards too high]), in order to stay focused.
« Last Edit: October 11, 2012, 09:19:25 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 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 #11 on: October 11, 2012, 07:36:10 am »
Ok I have an extremely incomplete, buggy and almost not working start to my Lua version of TI-nspire Hold 'em. I have used the How to have a nice "input" function in Lua on inspired-lua.org for input into changing number values. After fiddling around and running it heaps of times correcting nightmarish easy and both more challenging bugs, I find one that looks like I have to rewrite 25-30% of what I have currently again. The input function creates strings, I tried to compare these strings to a number, resulting an error on line 67. So for the "input" function, looks like I'll actually have to make it somehow a number that can be user-changed, displayed and compared to other numbers.

I also need to know how you can do algebra in Lua. Oh wait, in TI-nspire Basic if you typed 0.5x (x being a variable) it would automatically put in the multiply symbol in. Looks like I have to do that in Lua also (* symbol), any other handy ways?

I hope some of this made sense, I'll come back later with some clarification if necessary.
Here is the code so far:

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
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)
elseif scrn==2 then
gc:drawString("Right let's get rolling!",10,10,"top")
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()
if scrn==1 then
if 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
platform.gc():drawString("Congrats! Settings set up correctly",10,70,"top")
scrn=2
gopt=0
else
platform.gc():drawString("Check these conditions",10,70,"top")
platform.gc():drawString("Chips between 100 and 10 million",10,85,"top")
platform.gc():drawString("Big blind between 0.001 and 0.1 Chips",10,100,"top")
platform.gc():drawString("Small blind between 0.01 and 0.5 Big Blind",10,115,"top")
end
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()

It's a first and slow step. I could also do well to learn from my other Lua project, Numstrat.

PS: This took at least 1.5 hours, maybe 2. OMG how can it take so long!!!
« Last Edit: October 11, 2012, 07:37:14 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 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 #12 on: October 13, 2012, 05:26:06 am »
No one? Maybe this'd be better suited in the Lua Language section.
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 #13 on: October 13, 2012, 11:37:26 am »
Well, when I ran it with the script editor, pressing c, b and s works fine, as well as backspace and typing numbers, and not typing letters.
However, when I press enter, it just goes blank, instead of displaying congrats or the other four strings. I tried using some functions, such as var.recall or var.recallStr, that I thought should convert strings to values, like “0” to 0. That did not work.

In the end, I found the problem

plat form . gc ( )
Returns a dummy graphics context. It is typically used to measure pixel lengths and
heights of strings when a normal graphics context is not available. This may be the case
when creating new text elements when the script app is initialized. A graphics context
is available only during paint events, and that may be too late to create and size the
containers for text _elds.
This graphics context should not be used to draw graphics because it is not guaranteed to
be associated with a window.
Introduced in platform.apiLevel = "1.0"
Removed in platform.apiLevel = "2.0"

So, I was using level 2.0, and it also says not to use it for drawing graphics such as strings.
It may still work on OS 3.1, but if I’m not mistaken, I believe you changed to OS 3.2 in the OS compatibility post.
« Last Edit: October 13, 2012, 11:37:54 am by Rhombicuboctahedron »

Offline Rhombicuboctahedron

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 437
  • Rating: +41/-6
    • View Profile
Re: TI-nspire Hold 'em - Basic and Lua
« Reply #14 on: October 13, 2012, 12:52:08 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()