In the last part of this series, I walked through examining Cracker Barrel’s version of peg solitaire as a graph, and determined that the graph is easily small enough to process by computer.

In this part, we’re going to look at how to implement the basic parts of the game in Rust. Get your snacks! This is a long one!

Trouble with Triangles

The first problem with implementing the game is deciding how to store the triangular game board in memory.

For games with rectangular boards, like chess or checkers, representing the board is straightforward with a 2-dimensional array or list. But, a triangular board is slightly more involved to store and process.

To make the board easier to reason about, let’s realign it so that it’s drawn as a right triangle instead of an equilateral one…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help