What kind of neural network can be trained to recognise patterns?
The idea is simple, but it requires some time to develop.
Assumption: I am assuming in your problem the final model will have seen all possible shapes.
What your algorithm needs is a convolutional NN to understand each shape by extracting features, but you just need to be very careful with pooling.
Then what you need is a recurrent NN. In the example you showed (the image of shapes) we have bigrams (sequence of 2) which means we have the first shape as an input and the second shape is a target. In this case normal RNN should work.
But if you have sequence of many shapes, for example 10 shapes and let's say the final shape, 10th, is the target; And also if the sequence is in the way that 10th shape could be more depend on initial shapes (e.g. 1st or 2nd shape) then what you also need to consider beside RNN is long-short-term-memory (LSTM).
I cannot think of a simpler solution than this.