Strategalo
2022 A card game, made digital
A digital version of the card game Strategalo, a mix of noughts and crosses and War, made in Unity for a programming exam at HTX.
The game
Four players each get a suit and take turns laying the top card of their pile on a grid. Like in noughts and crosses you want three in a row, and like in War a higher card can take over the spot of a lower one. Each player also has one joker, which clears a whole stack on the grid.
The tricky part is the board. It always ends up 4 × 4, but where its edges are depends on where the players put their cards, so the grid has to grow and shrink while the game is running.
My part
I wrote the algorithm that builds the grid: it clears the old tiles, creates a new grid of any width and height, and works out the size and position of every card so the board always fits on the screen. In the report I also went through its running time - two nested loops, so O(n²) - and why the loop that clears the old grid does not change that.