Smart Game Board – Software and testing

Smart Game Board – Software and testing

Software

Having everything assembled and tested (all the connections), I started with writing libraries for the LEDs, sensors and handling overall game board state. Then came the game logic (Checkers). Nothing really surprising, and if you’re feeling comfortable with C++ this should be a fairly straight forward step.

I wanted to organize code efficiently, so I can continue adding support for new games (or replace existing with new ones, if the Arduino’s memory size proves to be an issue).

I ended up simplifying pieces of code before finishing the game: originally I thought of a way to handle animations without blocking the input (single-threaded platform), but then I reached conclusion that it seems a bit like an overkill – animations are fast and short lasting, and any change in game board is handled with no more than maybe 1 second delay in the worst case.

 

One thing to call out: since we’re using magnets and hall effect sensors, the game pieces are indistinguishable between one another – we either get a low or high signal from sensor on any given cell. Thus the completeย game logic is based on knowledge of initial state, and then tracking the state changes as players make their moves.

 

IDE

Arduino IDE is very lightweight and convenient for quick development of smaller programs. However, once you start working on anything more complex, and you’d like to be able to design your code more appropriately, it starts to feel very limited. I use, and highly recommend,ย the Visual Micro – Arduino IDE for Microsoft Visual Studio:

Arduino IDE for Microsoft Visual Studio
http://www.visualmicro.com/

 

High level look at the project

Here’s how I organized myย project files:

That should give an idea on what are the main classes, their responsibilities, and how is the game logic organized.

 

Manual and game rules (International Checkers)

I wanted to make it easier for anyone to have fun with the game board, so I prepared a short manual.

Also, in the process of testing it with my friends and colleagues, I discovered that the US Checkers rules are slightly different than International Checkers. Those subtleties should be explained to players before hand to avoid surprises (and being suspected of cheating! ๐Ÿ™‚ ).

Smart Game Board – Manual

International Checkers – Game Rules

Grid – the game board is larger than printer paper (letter format), thus I needed to print 2 copies, cut them and put under the top acrylic panel. This grid has every other cell filled with a pattern to give the classic feel of light and dark cells of a Chess board. The debug version has addresses of the cells for quick reference while writing/debugging the code.
Smart Game Board – Gridย + Smart Game Board – Debug Grid

 

 

Ideas and improvements for V2

Having the complete project in from of me, and played a number of games (some won, some lost…), here are some of the things I’d like to improve for next version:

  • Thicker base, for added sturdiness (3/8″ instead of 1/8″?)
  • Revisit dimensions for holes for tabsย as they’re a bit loose (looks like I added an offset for both width and height, while it’s only needed in one dimension as the other one is constant, not affected by laser kerf)
  • All made from acrylic, including the inner grid (use white acrylic instead of wood) – nicer looks, less susceptible to bending compared to wood drying over time
  • Use a “multiplexed” grid for reading the sensor states
    • Big improvement in number of I/O ports required (instead of 64, we could use 16: 8 for power, 8 for input), would clean up the overall look, decrease cost and complexity, allow for enclosing this side of the board with nice frame
    • This is an approach that is used i.e. in computer keyboards
  • Potentially use custom LED strip, instead of being limited by the pitch of available strips – but this adds a significant amount of work, and I didn’t feel limited by the pitch of LEDs on the strip I used
  • Instead of support beams around the electronics, use solid walls, with cutouts for ventilation
    • This would be sturdier, and prevent players from i.e. dropping the game pieces inside the electronics box
  • Print and cut the board face (with white and black cells) using some kind of white transparent foil, instead of printer paper, for a more finished look
  • Include place for the switches and buttons in the design – right now they look like an afterthought (which they actually wereโ€ฆ ๐Ÿ™‚ )
  • Maybe add a “tray” where users could store pieces removed from the board (in addition to existing boxes with lids, for when players know they will be playing another game and putting pieces in/out of the box is a hassle – my friends and I keep the pieces on top of the boxes between games)

And going even further:

  • Add a LCD screen (display current player, info/warning/error message [i.e. “must jump”, “incorrect move”, “pieces missing from the board”]
  • Add a chess timer – used by chess players to measure the time they needed to make a move, for more competitive players

 

Now let’s start playing!

Questions? Feedback?
Thoughts on the project?

Leave a comment and I’ll get back to you ๐Ÿ™‚

Comments

23 responses to “Smart Game Board – Software and testing”

  1. Raymond S. Avatar
    Raymond S.

    Is the code available to look at anywhere? I want to try a version of this that can track a game of chess an output a log in algebraic notation.

    1. Bogdan Avatar

      Hi Raymond, I’m not sure if my source will be a lot of help in your scenario (I’m not keeping a track of each move, to output the history or allow backtracking), but I’m going to send the sources to your e-mail. Hope you’ll find something helpful/interesting! ๐Ÿ™‚

  2. Aken Avatar
    Aken

    hi. is the code available? i want try build for fun.

    1. Bogdan Avatar

      Hey Aken!
      I e-mailed you the sources (I need to put some time aside and maybe put them on github, but there’s always a new and shiny project to work on instead! ๐Ÿ™‚ ).

      1. eric denis Avatar
        eric denis

        Hey there Bogdan!
        Super neat project! Was wondering if the code is available? I would like to try and build this for myself ๐Ÿ™‚

        1. Bogdan Avatar

          Hi Eric, I e-mailed you the sources. Hope you’ll find them useful! Let me know if you have any questions, and if you build a similar project, please share a photo with me ๐Ÿ™‚

  3. Zain Avatar
    Zain

    Hey!
    I am trying to make similar project.. Can you please guide how should I start and from where should I start.
    Plus I would request you to help me with software part too..
    Is code is available online ?

    Thank you!

    1. Bogdan Avatar

      Hi Zain,

      I like to work on projects like that by dissecting them into smaller pieces. In fact, such decomposition is common in software development as well. Makes things… manageable ๐Ÿ˜‰

      You can think of it as making a progress in clearly defined, iterative steps. For example, I first focused on making a single row of LEDs being controllable and reading the state of pieces on the game board. This allows for easier debugging if something goes wrong, and ensures everything works as expected early on, without the risk that we’ll get ourselves deep into a solution that may prove limiting later on.

      Check out some of my videos on YT from initial testing: https://www.youtube.com/watch?v=Ts9eacRvi6A and https://www.youtube.com/watch?v=tQgYRBa68rw.

      Regarding the software – I e-mailed you the source. Hope you’ll find it educational! Let me know if you have any questions.

  4. RJ Sklat Avatar
    RJ Sklat

    Hi Hi, i was wondering if I could get the code for this, Im doing the same idea for my school project and would like to use some code to help get it done

    1. RJ Sklat Avatar
      RJ Sklat

      please respond soon if you ever see this, i dont have much time to finish the project

      1. Bogdan Avatar

        Hi RJ, I just sent you the plans. Feel free to modify them as needed of course, to fit your creative vision (and school project requirements ๐Ÿ˜‰ ). Good luck!

  5. Aleksander Avatar
    Aleksander

    Hello :), I wanted to doing this project, and I was wondering wheter I could get access to the code that you have used for this. Have a good day/night. Thank you ๐Ÿ˜€

    1. Bogdan Avatar

      Hi Aleksander! Happy to share the sources, sending them to your email right now. Good luck with your project!

  6. Ivan Avatar
    Ivan

    Hi Bogdan, I was wondering if I could get the code for this, I’m doing the same idea for my school project and I think your project could help me.

  7. Maximiliรกn Loj Avatar
    Maximiliรกn Loj

    Hi, i have to do project for my graduation and its pretty similar to yours… Is there anyway that i could see the code?

    1. Bogdan Avatar

      Hi Maximiliรกn, I just sent the sources to your email. Please note that it’s very unlikely it would just work for you out of the box, considering the differences in circuit/wiring, but I hope it can help serve as a reference. Good luck!

  8. Tomรกs Avatar
    Tomรกs

    Hey! Really cool project! I am thinking of doing something similar to my embedded systems project in college. Do you mind sharing the code used? It would help a lot! PS: sorry for the english

    1. Bogdan Avatar

      Hi Tomรกs. Always happy to share the resources with creative community ๐Ÿ™‚ I sent you the sources just now. And don’t worry, you English is solid! I’m not a native speaker either, but everything gets better with practice ๐Ÿ˜‰ Good luck with the project!

  9. Passionate Arduino Student Avatar
    Passionate Arduino Student

    Hey, I’m looking to implement a similar game board for my school project. Would it be possible for you to share your source code with me? I will be giving proper credit everywhere. Thanks in advance!

    1. Bogdan Avatar

      Hi! Ahh I hope I’m not replying too late… ๐Ÿ˜‰ But I’ll send you the sources this second. Good luck with your project!

  10. Renato Avatar
    Renato

    Awesome!

    Could you please share your code? I am learning from other sensoring led tables to get mine working. I am struggling with it a little bit.

    I am trying to make a boardgame with more leds per square to get more light or effects. This requires extra work to group the leds and link them with each sensor.

    I would really appretiate if you could share it.

    Thanks a lot!

    Your code and structure could help

    1. Bogdan Avatar

      Hi Renato! I’ll email you the sources right now. Please keep in mind that it has no chance of working as-is, considering the pin-outs, and differences in our circuits. But as you say – I hope it could be a reference for how the code is organized, or maybe what cases I decided to handle, etc. I’d encourage you to use Visual Micro (a plugin for Visual Studio) for managing more complex project – please find a bit more information in the article itself. Good luck!

Leave a Reply

Your email address will not be published. Required fields are marked *