How to make a chess game tutorial using two-dimensional arrays, array lists, maps and custom list views

PaulMeuris

Active Member
Licensed User
chess_001_01.png

In this tutorial you can learn how to make a chess game app.
The app uses B4A two-dimensional arrays, array lists and maps to store all the game information in.
It shows hints for every chess piece and the chess pieces can be "flipped" so the black player sees the pieces in a normal way (and not upside-down).
There is also a feature to set up a board with a chess puzzle to solve.
Games and puzzles can be saved and loaded at any time. This allows you to stop playing and save the game and at a later moment continue the game.
Are you up for the challenge?
You can find the tutorial via this link: B4A-chess
With this app on your smartphone or tablet you can play chess with a friend.
You can even exchange games using the save and load feature. You can copy the game folder with the 3 files anywhere you want. Only if you want to play the game then you need this app.
The app doesn't include a chess engine library. The code is native B4X coding for you to study and test.
This is also an example of how you can build a board game where the players move things around on a board like for instance checkers, monopoly, ...
Mmmm... maybe an idea for a next project...
Happy coding!
Paul
 

PaulMeuris

Active Member
Licensed User
There is a small issue when you load a game after the study board was used.
The is_study boolean variable was not reset.
Modify the load_game subroutine as follows:
load_game adjustment:
Private Sub load_game(foldername As String)
    ' reset board and info list
    is_study = False
Now you can load and play the game without an error.
I have edited the tutorial accordingly.
 
Top