Skip to content

Latest commit

 

History

History
219 lines (205 loc) · 11.9 KB

reference.md

File metadata and controls

219 lines (205 loc) · 11.9 KB

This is somewhat of an outline of objects and or data structures and methods needed to go forward with general cube puzzle solver!

  • voxel

    newpieces.fs

    • construct ( voxel -- )
      • construct voxel with 0 0 0 as voxel coordinates
    • voxel! ( ux uy uz voxel -- )
      • store the voxel coordinates
    • voxel@ ( voxel -- ux uy uz )
      • retrieve voxel coordinates
    • intersect? ( uvoxel voxel -- nflag )
      • nflag is true if uvoxel is intersecting with voxel nflag is false if not intersecting
  • piece

    newpieces.fs

    • construct ( piece -- )
      • construct piece object
    • destruct ( piece -- )
      • destruct and free data in object
    • add-voxel ( ux uy uz piece -- )
      • add a voxel to this piece with ux uy uz address
    • get-voxel-object ( uindex piece -- uvoxel )
      • return a voxel object at uindex
    • get-voxel ( uindex piece -- ux uy uz )
      • retrieve voxel data from uindex voxel in this piece
    • voxel-quantity@ ( piece -- usize )
      • return voxel quantity
    • intersect? ( upiece piece -- nflag )
      • test for intersection of upiece with this piece on any voxel
    • same? ( upiece piece -- nflag )
      • test upiece agains this piece for exact voxels match forward or backward
    • copy ( upiece piece -- )
      • exact copy upiece to this piece
    • serialize-data@ ( piece -- nstrings )
      • to save this piece data
    • serialize-data! ( nstrings piece -- )
      • to restore previously saved data
  • pieces

    newpieces.fs

    • construct ( pieces -- )
      • construct pieces object
    • destruct ( pieces -- )
      • destruct pieces object
    • add-a-piece ( upiece pieces -- )
      • copies contents of upiece object and puts the copied piece object in a-pieces-lis
    • get-a-piece ( uindex pieces -- upiece )
      • retrieve uindex piece from a-pieces-list
    • pieces-quantity@ ( pieces -- usize )
      • return the quantity of pieces in this piece list
    • serialize-data@ ( pieces -- nstrings )
      • to save this list of pieces
    • serialize-data! ( nstrings pieces -- )
      • to restore previously saved list of pieces
  • save-instance-data

    serialize-obj.fs

    • construct ( save-instance-data -- )
    • destruct ( save-instance-data -- )
    • serialize-data@ ( save-instance-data -- nstrings )
      • method that is empty and is the suggested name of method for making serialized data
    • serialize-data! ( nstrings save-instance-data -- )
      • method that is empty and is the suggested name of the method for retrieving the serialized data in nstrings

    private inst-value

    • save$
      • this is the strings object handle containing the serialized data

    private methods that are not normally used directly by inherited class but can be used if understood how they work.

    • #sto$ ( ns save-instance-data -- caddr u )
      • convert ns to string
    • $>xt ( nclass caddr u save-instance-data -- xt )
      • caddr u string is an instance data name and returns its xt. nclass is also needed
    • xt>$ ( nxt save-instance-data -- caddr u )
      • from the xt of an instance data name return the caddr u string of that named instance data
    • #$>value ( unumber nclass caddr u save-instance-data -- )
      • put unumber into the inst-value named in string caddr u ... note nclass is needed!
    • #$>var ( unumber nclass caddr u save-instance-data -- )
      • put unumber into the inst-var named in string caddr u ... note nclass is needed!
    • $->method ( nclass caddr u save-instance-data -- )
      • caddr u is a method to be executed ... note nclass is needed!

    private methods that are normally used directly by inherited class to save and restore data into save$ strings object

    • do-save-name ( xt save-instance-data -- )
      • saves the name string of xt by getting the nt first name to save$
    • do-save-inst-value ( xt save-instance-data -- )
      • saves the instance value referenced by xt to save$
    • do-save-inst-var ( xt save-instance-data -- )
      • saves the instance var referenced by xt to save$
    • do-save-nnumber ( nnumber save-instance-data -- )
      • saves nnumber to save$ - note this is a cell wide number
    • do-retrieve-dnumber ( save-instance-data -- dnumber nflag )
      • retrieve string number from save$
    • do-retrieve-data ( save-instance-data -- caddr u dnumber nflag )
      • retrieve string name and string number from save$
    • do-retrieve-inst-var ( nclass save-instance-data -- )
      • restores instance var from save$
    • do-retrieve-inst-value ( nclass save-instance-data -- )
      • restores instance value from save$
  • piece-array

    piece-array.fs

    • construct ( upieces piece-array -- )
      • construct the array from the contents of upieces! Note the size is fixed at construct time!
      • construct the intersect array of reference pieces.
    • destruct ( piece-array -- )
    • upiece@ ( uindex piece-array -- upiece)
      • retrieve upiece from array at uindex location
    • fast-intersect? ( uindex0 uindex1 piece-array -- nflag )
      • return nflag from intersect-array to get fast intersect detection for uindex0 and uindex1 pieces
      • nflag is true if an intersection between uindex0 and uindex1 is found
      • nflag is false if no intersection is found
    • quantity@ ( piece-array -- nquantity )
      • return the array size
    • serialize-data@ ( piece-array -- nstrings )
      • return the serialized data of this object in nstrings
    • serialize-data! ( nstrings piece-array -- )
      • nstrings contains the serialized data to restore this object
  • make-all-pieces

    allpieces.fs

    • construct ( uindex upieces make-all-pieces -- upieces2 )
      • constructor
      • uindex is the reference to the pieces object piece defined in newpuzzle.def file
      • upieces2 is the returned pieces object that contains the total list of pieces that can be in board as defined by upieces and puzzle-board
      • note newpuzzle.def contains the dimensions of the board used here in three constants
    • destruct ( make-all-pieces -- )
  • fast-puzzle-board

    fast-puzzle-board.fs

    • construct ( uref-piece-array fast-puzzle-board -- )
      • constructor
      • uref-piece-array is a piece array that contains all the pieces as a reference
      • note newpuzzle.def contains the dimensions of the board used here in three constants
    • destruct ( fast-puzzle-board -- )
      • destructor
      • release all memory allocated
    • max-board-index@ ( fast-puzzle-board -- uindex )
      • return the max board index address or simply the total voxel count xyz
    • nvoxel@ ( uvoxelindex fast-puzzle-board -- uref-piece )
      • given uvoxelindex return the uref-piece that is located on this board
      • note uref-piece could return as true indicating that there is no ref-piece on the board at uvoxelindex
      • uref-piece returned is true or a uref-piece value from 0 to max reference pieces
    • output-board ( fast-puzzle-board -- )
      • terminal display
    • board-pieces@ ( fast-puzzle-board -- uquantity )
      • return current board piece quantity
    • max-board-pieces@ ( fast-puzzle-board -- uquantity )
      • return quantity of pieces to solve this board puzzle
    • board-dims@ ( fast-puzzle-board -- ux uy uz )
      • return the board dimensions
    • board-piece? ( uref-piece fast-puzzle-board -- nflag )
      • test if uref-piece can be placed in current board
      • nflag is true if uref-piece can be placed on the current board
      • nflag is false if uref-piece can not be placed on current board
    • board-piece! ( uref-piece fast-puzzle-board -- nflag )
      • test if uref-piece can be placed in current board
      • nflag is true if uref-piece can be placed on the current board
      • nflag is false if uref-piece can not be placed on current board
    • nboard-piece@ ( uindex fast-puzzle-board -- uref-piece )
      • get uref-piece from board piece list at uindex location
    • remove-last-piece ( uref-piece fast-puzzle-board -- )
      • remove last piece put on this board
    • clear-board ( fast-puzzle-board -- )
      • empty board of its pieces but keep the internal references to pieces so construct does not need to be used
    • serialize-data@ ( fast-puzzle-board -- nstrings )
      • return nstrings that contain data to serialize this object
    • serialize-data! ( nstrings fast-puzzle-board -- )
      • nstrings contains serialized data to restore this object
    • print ( fast-puzzle-board -- )
      • print stuff for testing
  • chain-ref

    chain-ref.fs

    • construct ( upieces chain-ref -- )
      • constructor
    • destruct ( chain-ref -- )
      • destructor
    • next-chain@ ( uref chain-ref -- unext-chain nflag )
      • retrieve next chain reference for given uref piece
      • unext-chain is a piece that can chain to uref piece
      • nflag is true when the list of possible chains for uref is at the end and will reset for next retrieval to be at beginning of list
    • chain-quantity@ ( uref chain-ref -- uchain-quantity )
      • return chain quantity for given uref piece
    • serialize-data@ ( chain-ref -- nstrings )
      • return nstrings that contain data to serialize this object
    • serialize-data! ( nstrings chain-ref -- )
      • nstrings contains serialized data to restore this object
  • hole-array-piece-list

    voxel-ref-list.fs

    • construct ( upiece-array hole-array-piece-list -- )
      • takes upiece-array that should contain the reference pieces and organizes them for hole indexing or voxel indexing
      • newpuzzle.def contains the size of the current puzzle being solved for as three constants and are used here to get that size
    • destruct ( hole-array-piece-list -- )
    • next-ref-piece-in-hole@ ( uholex uholey uholez hole-array-piece-list -- uref-piece nflag )
      • uholex uholey uholez is the hole address identified from puzzle-board
      • uref-piece is the next reference piece in the list that fits in that hole address
      • nflag is false normaly after upiece retrieval
      • nflag is true when for given hole address the piece list is at the end
      • note when nflag is true the piece list at that hole address will reset to begining of list
    • hole-list-quantity@ ( uholex uholey uholez hole-array-piece-list -- uhole-list-quantity )
      • returns the quantity of pieces in a given hole
    • hole-max-address@ ( hole-array-piece-list -- uholex uholey uholez )
      • returns the total hole addresses for this reference puzzle passed to construct
    • index>xyz ( uindex hole-array-piece-list -- uholex uholey uholez )
      • return the xyz hole address for the given uindex value
    • hole-max-index@ ( hole-array-piece-list -- uindex )
      • return the max index size of the holes in this object
    • xyz>index ( uholex uholey uholez hole-array-piece-list -- uindex )
      • return the uindex for the given xyz hole address
    • index-next-ref-piece@ ( uindex hole-array-piece-list -- uref-piece nflag )
      • uindex is the hole index that will return the next uref-piece. Like next-ref-piece-in-hole@ above but uses uindex!
    • serialize-data@ ( hole-array-piece-list -- nstrings )
      • return nstrings that contain data to serialize this object
    • serialize-data! ( nstrings hole-array-piece-list -- )
      • nstrings contains serialized data to restore this object