Counting Dots on Domino Tiles


We will start with a computational thinking exercise. Assuming that we have the components for recognizing half-tiles available, how would you design and code a program integrating the answers to count points on possible multiple tiles that appear in an image? 

A simple version of our problem is shown in this coding example. A set of domino tile images is uploaded in the program. Given that we have the labels from the file names, we can come up with the total number of points by using a  for loop in a process very similar to the one we used to compute the decimal value corresponding to the array of bits as we do for the flippy-do app

Picture of dominos totaling 9 dots.  Made of (2,0) (2,2) and (3,0)We built an array of object labels that keep track of the points on the half tiles.  For example, the 2x0 tile was encoded as the object {x:2, y:0}. 

Coding exercise:  Make a copy of the starter code and add two more tiles to the set displayed in the image on the right. Count and display the total number of dots. Additional images of tiles are available in the "data" folder in the starter code. 

 
With the abstraction of the arrays and the for-loop, we mainly have to make sure to add the images and the corresponding labels in the correct position in the two arrays we are using. 

What if we do not have the labels for the tiles, and all we have is the image of the tiles? We can try to train a model that would predict the labels. 


As you consider answering the high-level modeling question, please note your ideas down and share them with us in the quiz at the end of this session. One of the challenges that will not be resolved in this session is to have an algorithm that will classify correctly domino tiles in images.  For now, we will focus on collecting data from drawings and saving it in a format that is easy to handle in the browser and the p5.js editor. We will also explore models available in the ml5.js library and extend slightly one tutorial model from Tensorflow.js.

The domino pieces:  rectangular tiles divided by a middle line with dots from 0 to 6 on each side of the divide. Pieces have no orientation, so the order in the pairing of point does not matter. A complete set of pieces consists of 28, given by the formula of combinations of 7 choose 2 (which gives 21 different unordered pairs) plus the seven doubles, for a total of 28. 

There are also versions of the tiles with dots going from 0 to 12, thus with 13 options on each side of the tile, with a total of 91 pieces.  We use the smaller version in this exploration.