From 0c49ed5afc2ae9e4bc4aa1af9c655bbe1f3d14b8 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sun, 22 Oct 2023 14:48:42 +0200 Subject: Small change of plans, moved stuff around --- doc/CUBE_INTERNAL.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 doc/CUBE_INTERNAL.md (limited to 'doc/CUBE_INTERNAL.md') diff --git a/doc/CUBE_INTERNAL.md b/doc/CUBE_INTERNAL.md new file mode 100644 index 0000000..fd3148a --- /dev/null +++ b/doc/CUBE_INTERNAL.md @@ -0,0 +1,24 @@ +# Internal representation of the cube + +The plan (TODO) is to have multiple implementations: some that +take advantage of advanced CPU instructions (SIMD) and a fallback +"array" representation that works on any architecture. + +# Array representation (fallback) + +In this implementation of the cube.h interface, the cube is represented +by two arrays of 8-bit unsigned integers, one for centers and one for +corners. The 4 leas-significant digits of each bit determine the piece, +the other 4 are used for orientation or kept to 0. + +Edges: + xxxopppp (x = unused, o = orientation, p = piece) + +Corners: + xooxpppp (x = unused, o = orientation, p = piece) + +The two bits for CO are shifted to make it possible to perform mod 3 +operations (sum, inverse) using only addition and bitwise operators. +See below for details. + +The third bit is needed because x+y+1 can exceed 4. -- cgit v1.3