Log In  

Cart #variations_vienna-4 | 2024-05-26 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

Variations: The Vienna


16 variations of the Vienna opening played as white. These lines are chosen to be fun, for their attacking chances and dynamic play. They include common mistakes by black and how to punish them as well as how to respond to good play from your opponent. Practicing with this cartridge will give any player a good start to creating big problems for black with the Vienna!


While none of white's moves are dubious, they are not necessarily the top engine recommendations. Because there is no 'right' move, a hint can be requested (see Controls). After completing a variation, the Stockfish evaluation is given. The player then has the options to either repeat the completed variation, move on to the next, or have the computer select a variation at random. The pause menu gives similar options but can be accessed at any time allowing the player to navigate to a specific variation or move to a new, random variation.


❎ select/de-select piece and move-to square
πŸ…ΎοΈ hold down during white's move to show a hint

P#148751 2024-05-21 02:25 ( Edited 2024-05-26 04:13)


Interesting, and educational too!

I ran into this error on the third variation after playing the first and second:

P#148791 2024-05-21 21:46

@Verb thanks for checking it out and letting me know. I can't duplicate the error on my end. But I'll try and will fix it if I can figure out when it happens.

I did fix a separate bug that possibly fixed them both... but not sure.

P#148794 2024-05-21 23:41

@camp39 really educational I enjoyed it! β­β™Ÿ

Ok so I've managed to reproduce the error shared by @Verb it's still there.
Repro steps:

  • simply keep pressed the hint button while you confirm the last move of the variation.

Cause of error:
the last element in each variation object in moves table does not provide any .x/.y properties, they're [nil], hence the error while attempting to render the hint.

(unsolicited) Suggestion 🀭:
instead of using moves[move_num].x or y, I'd create a handy function like get_move_pos() returning the two values, in case they're nil, provide something offscreen like -64,-64
At the top of functions where you'd need x and y do something like:
local x,y=get_move_pos()
Otherwise, quickest fix is -in show_hint()- drawing the rect only if x is not nil:

P#148824 2024-05-22 19:50 ( Edited 2024-05-22 21:34)

Fixed. I also noticed that pressing them together during any move caused the computer destination square to get the hint...which annoyed me so was also fixed.
I'm always interested in peoples' suggestions with regard to my code so thank you very much for looking at it and finding a fix. I will think about your function suggestion because I really ended up not liking the structure of my code and already trying to understand alternatives. For this one I went with the quickest fix possible though (lol!).
If you are a chess player stay tuned! Next month will be Smith-Morra Gambit.

P#148830 2024-05-22 23:12

@camp39 Great! Well, since you are interested in suggestions, I feel like the inhuman tokens usage to define moves data really needs a more sustainable approach.
I'm convinced using lots of tokens for game logic is good (and inevitable) but big data definition is a job for strings and characters, just a minimum of tokens for a dedicated function to parse the string and populate table objects (the moves table in your case).

So this is how I'd approach moves definition (tested, seems to work fine, using only variation 1 data as example):

function addvar(s)
    for ln in all(split(s,"\n")) do
        local v=split(ln)
        if v[1]==" var" then
            add(moves,{variation=v[2], name=v[3], eval=v[4], msg=v[5]})
            local mv={x=v[1], y=v[2], piece=v[3], spritex=v[4], spritey=v[5]}
            if v[6] then

moves = {}

 var,1,vienna gambit,0.0,black played well]]

This way the function and whole definition for moves takes only 106 tokens (vs the current ~5000 tokens) regardless of how many variations you will put in the big string (characters will be the only limit).
addvar accepts a single argument (the virtually humongous big string with all the variations) so you don't need to use the parentheses.
The big string instead of the regular "x,y,z\nx,y,x.." is using the multiline string delimiters [[...]] every new line in the code will be a "\n" in the string and the function uses the newline \n as separator to split every move line, then every value (comma-separated, so you just need split, comma is the default separator) will be put in a table, the format (a "move line" or a "variation definition") depending on the first value (we'll use " var" to tell which table kind and paramenter names to use).
Let me know if you find anything else not really clear πŸ‘

P#148881 2024-05-23 22:22 ( Edited 2024-05-24 07:58)

Awesome! +100!

"I feel like the inhuman tokens usage to define moves data really needs a more sustainable approach."
YESSS... I knew this intuitively but didn't know what to do.

Can't wait to go over your code carefully and play in a test file to really understand the magic of saving so many tokens.

This forum is really something special. Everyone here has been not just helpful, but thoughtful. Thank you for your time and input! and thank you, @zep for this place.

P#148887 2024-05-24 03:12 ( Edited 2024-05-24 03:32)

[Please log in to post a comment]