Hacker News new | ask | show | jobs
by RodgerTheGreat 693 days ago
I had a go at an implementation of my own in Lil, using an imperative style rather than OOP. I tried to loosely follow the organization as shown here, but opted for a very different board representation, and I included some niceties like displaying board legends to aid in choosing the proper coordinates.

https://github.com/JohnEarnest/Decker/blob/main/examples/lil...

I'm really not convinced that OOP simplifies or clarifies this type of program.

1 comments

I'd too probably write it in Ruby using classes basically just as modules and not much else. It's totally fine using simple arrays and hashes in Ruby for data structures. For example, unlike in many other languages, board could be just a hash of booleans addressed by "tuples", like @board = {[x1, y1] => true, [x2, y2] => true}, which makes neighbours check trivial, while board will be sufficiently compact.