The Wiki for Tale 4 is in read-only mode and is available for archival and reference purposes only. Please visit the current Tale 11 Wiki in the meantime.

If you have any issues with this Wiki, please post in #wiki-editing on Discord or contact Brad in-game.

User:Inkoaten/Automated Gemcutting

From A Tale in the Desert
Jump to navigationJump to search

Automated Gemcutting

It should be possible to write software that, given a gem configuration, tells you all possible gems that can be cut from it.

  • Gems are a 7x7x7 cube of points. Each point is either present or absent.
  • Edges, triangles, and squares are generated to join adjacent (orthogonal or diagonal) points that are present. e.g. eyelet looks like this (X=present .=absent), as a series of slices through the gem:
 XXX  XXX
 X.X  X.X
 XXX  XXX

Or with edges added for clarity:

 X-X-X  X-X-X
 |/ \|  |/ \|
 X . X  X . X
 |\ /|  |\ /|
 X-X-X  X-X-X
  • The grinding discs then turn into a fairly simple set of rules for removing vertexes from the array of points. e.g. disc 1 will remove an entire plane from any one edge; disc 2 removes a triangular prism of points aligned with one axis.
  • For each potential gem, reduce its structure down to the minimum necessary set of present/absent points (by looking for applications of a disc that will only affect "absent" points - flag all those points as "don't care" points because either they are already absent, or they are present but can be safely grinded away). e.g. eyelet stays exactly as above (you can remove anything around it with disc 1, but you need the core structure exactly as above), and Dragyn's Eye looks like this: (?="don't care" i.e. can be removed safely without clobbering the important bits):
 ???X  ????  ????  ????
 ??XX  ???X  ????  ????
 ?XXX  ??..  ???X  ????
 XXXX  ?X.X  ??XX  ???X

This can be done by hand, once. More generally, represent the possible grinding planes and depths as (A,B,C,D) tuples where all points that satisfy Ax+By+Cz+D < 0 are ground away; then apply all planes where the plane would remove only absent points. (A,B,C is the plane normal vector). Done.

  • By eye, or via image processing of screenshots, construct the vertex map for a newly loaded gem. (This is a tedious process to do by eye, but it's do-able. Image processing is a better bet)
  • Rotate the vertex map through the 24 possible orientations (4 rotations around each of 6 faces)
  • For each orientation, scan the vertex map using the gem patterns prepared earlier. If you find a match, that gem type can be cut from this particular raw gem. (Alternatively, you can rotate the patterns and scan against the unrotated raw gem)

Now I just have to implement it. Done, but needs a decent UI to be usable