Ideas for puzzle simulator API

mrgabor7

Member
Joined
Aug 13, 2017
Messages
1
I'm writing (attempting to write) a general purpose JavaScript library that will simulate twisty puzzles in a highly-configurable way.

I'm currently trying to design an easy-to-use API, but what I find is that configurability and ease-of-use are not simple to combine. (This is as much of a learning exercise as a genuine project.)

Here is an example of what I'm thinking about currently:

Code:
let cube = new Library.puzzles.Cuboid({ size: [3,3,3] })

// Sets the top and bottom faces of the cube to have colored cubies instead of stickers
cube.getFacelets({
    filter: cube.filters.union([
        cube.filters.topFace,
        cube.filters.bottomFace
    ])
}).each((facelet) => {
    facelet.setColor(facelet.getSticker().getColor())
    facelet.showSticker(false)
})

This "filter" seems overly complicated for what I'm trying to achieve. Perhaps adding a simpler option would help:

Code:
cube.getFacelets('face:U,face:D').each((facelet) => {
    facelet.setColor(facelet.getSticker().getColor())
    facelet.showSticker(false)
})

(This is much cleaner)

This is just one of probably many more design choices. (I'm anxious about trying to implement animation such as animating sticker color changes, oh boy...)

I would appreciate any and all suggestions regarding anything to do with the API.
 
Back
Top