Move a piece
A move takes a piece from one square to an adjacent diagonal square. This
step adds a move mutation whose query contains the rules of a move. Add this
mutation to definitions/checkers/boards.dust, before the export form.
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 000 | 54 52 4F 4E | magic TRON |
| 004 | 6C 236C6F63616C | txt "#local" |
| 00B | 4C 6D6F7665 | txt "move" |
| 010 | 0F 0A 04000000 0B00 0000 | map leaf, size 10: @4 → @B |
| 01A | 6C 236C6F63616C | txt "#local" |
| 021 | 4C 66726F6D | txt "from" |
| 026 | 0F 0A 1A000000 2100 0000 | map leaf, size 10: @1A → @21 |
| 030 | 6C 236C6F63616C | txt "#local" |
| 037 | 2C 746F | txt "to" |
| 03A | 0F 0A 30000000 3700 0000 | map leaf, size 10: @30 → @37 |
| 044 | 0E 11 00 0300 020000 00 26000000 3A0000 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @26 → @3A |
| 055 | 6C 236C6F63616C | txt "#local" |
| 05C | 4C 696E743F | txt "int?" |
| 061 | 0F 0A 55000000 5C00 0000 | map leaf, size 10: @55 → @5C |
| 06B | 6C 236C6F63616C | txt "#local" |
| 072 | 4C 696E743F | txt "int?" |
| 077 | 0F 0A 6B000000 7200 0000 | map leaf, size 10: @6B → @72 |
| 081 | 6C 236C6F63616C | txt "#local" |
| 088 | 2C 3D3E | txt "=>" |
| 08B | 0F 0A 81000000 8800 0000 | map leaf, size 10: @81 → @88 |
| 095 | 6C 236C6F63616C | txt "#local" |
| 09C | 4C 6D61703F | txt "map?" |
| 0A1 | 0F 0A 95000000 9C00 0000 | map leaf, size 10: @95 → @9C |
| 0AB | 0E 19 00 0F00 040000 00 61000000 770000 00 8B000000 A10000 00 | array leaf, size 25, shift 0, bitmap 000F, count 4 (root): @61 → @77 → @8B → @A1 |
| 0C4 | 6C 236C6F63616C | txt "#local" |
| 0CB | 5C 3F67616D65 | txt "?game" |
| 0D1 | 0F 0A C4000000 CB00 0000 | map leaf, size 10: @C4 → @CB |
| 0DB | 6C 236C6F63616C | txt "#local" |
| 0E2 | 6C 3F7069656365 | txt "?piece" |
| 0E9 | 0F 0A DB000000 E200 0000 | map leaf, size 10: @DB → @E2 |
| 0F3 | 6C 236C6F63616C | txt "#local" |
| 0FA | 5C 3F66726F6D | txt "?from" |
Show all 295 nodes
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 100 | 0F 0A F3000000 FA00 0000 | map leaf, size 10: @F3 → @FA |
| 10A | 6C 236C6F63616C | txt "#local" |
| 111 | 3C 3F746F | txt "?to" |
| 115 | 0F 0A 0A010000 1101 0000 | map leaf, size 10: @10A → @111 |
| 11F | 6C 236C6F63616C | txt "#local" |
| 126 | 6C 3F636F6C6F72 | txt "?color" |
| 12D | 0F 0A 1F010000 2601 0000 | map leaf, size 10: @11F → @126 |
| 137 | 6C 236C6F63616C | txt "#local" |
| 13E | 5C 3F6E657874 | txt "?next" |
| 144 | 0F 0A 37010000 3E01 0000 | map leaf, size 10: @137 → @13E |
| 14E | 0E 21 00 3F00 060000 00 D1000000 E90000 00 00010000 150100 00 2D010000 440100 00 | array leaf, size 33, shift 0, bitmap 003F, count 6 (root): @D1 → @E9 → @100 → @115 → @12D → @144 |
| 16F | 6C 236C6F63616C | txt "#local" |
| 176 | 5C 3F67616D65 | txt "?game" |
| 17C | 0F 0A 6F010000 7601 0000 | map leaf, size 10: @16F → @176 |
| 186 | 4C 67616D65 | txt "game" |
| 18B | 09 | bit true |
| 18C | 0F 0A 86010000 8B01 0000 | map leaf, size 10: @186 → @18B |
| 196 | 0E 11 00 0300 020000 00 7C010000 8C0100 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @17C → @18C |
| 1A7 | 6C 236C6F63616C | txt "#local" |
| 1AE | 5C 3F67616D65 | txt "?game" |
| 1B4 | 0F 0A A7010000 AE01 0000 | map leaf, size 10: @1A7 → @1AE |
| 1BE | 6C 236C6F63616C | txt "#local" |
| 1C5 | 4C 7475726E | txt "turn" |
| 1CA | 0F 0A BE010000 C501 0000 | map leaf, size 10: @1BE → @1C5 |
| 1D4 | 6C 236C6F63616C | txt "#local" |
| 1DB | 6C 3F636F6C6F72 | txt "?color" |
| 1E2 | 0F 0A D4010000 DB01 0000 | map leaf, size 10: @1D4 → @1DB |
| 1EC | 0E 15 00 0700 030000 00 B4010000 CA0100 00 E2010000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @1B4 → @1CA → @1E2 |
| 201 | 6C 236C6F63616C | txt "#local" |
| 208 | 5C 3F67616D65 | txt "?game" |
| 20E | 0F 0A 01020000 0802 0000 | map leaf, size 10: @201 → @208 |
| 218 | 6C 236C6F63616C | txt "#local" |
| 21F | 4C 6E657874 | txt "next" |
| 224 | 0F 0A 18020000 1F02 0000 | map leaf, size 10: @218 → @21F |
| 22E | 6C 236C6F63616C | txt "#local" |
| 235 | 5C 3F6E657874 | txt "?next" |
| 23B | 0F 0A 2E020000 3502 0000 | map leaf, size 10: @22E → @235 |
| 245 | 0E 15 00 0700 030000 00 0E020000 240200 00 3B020000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @20E → @224 → @23B |
| 25A | 6C 236C6F63616C | txt "#local" |
| 261 | 5C 3F66726F6D | txt "?from" |
| 267 | 0F 0A 5A020000 6102 0000 | map leaf, size 10: @25A → @261 |
| 271 | 6C 236C6F63616C | txt "#local" |
| 278 | 6C 6E756D626572 | txt "number" |
| 27F | 0F 0A 71020000 7802 0000 | map leaf, size 10: @271 → @278 |
| 289 | 6C 236C6F63616C | txt "#local" |
| 290 | 4C 66726F6D | txt "from" |
| 295 | 0F 0A 89020000 9002 0000 | map leaf, size 10: @289 → @290 |
| 29F | 0E 15 00 0700 030000 00 67020000 7F0200 00 95020000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @267 → @27F → @295 |
| 2B4 | 6C 236C6F63616C | txt "#local" |
| 2BB | 5C 3F66726F6D | txt "?from" |
| 2C1 | 0F 0A B4020000 BB02 0000 | map leaf, size 10: @2B4 → @2BB |
| 2CB | 6C 236C6F63616C | txt "#local" |
| 2D2 | 3C 726F77 | txt "row" |
| 2D6 | 0F 0A CB020000 D202 0000 | map leaf, size 10: @2CB → @2D2 |
| 2E0 | 6C 236C6F63616C | txt "#local" |
| 2E7 | 4C 3F726F77 | txt "?row" |
| 2EC | 0F 0A E0020000 E702 0000 | map leaf, size 10: @2E0 → @2E7 |
| 2F6 | 0E 15 00 0700 030000 00 C1020000 D60200 00 EC020000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @2C1 → @2D6 → @2EC |
| 30B | 6C 236C6F63616C | txt "#local" |
| 312 | 5C 3F66726F6D | txt "?from" |
| 318 | 0F 0A 0B030000 1203 0000 | map leaf, size 10: @30B → @312 |
| 322 | 6C 236C6F63616C | txt "#local" |
| 329 | 3C 636F6C | txt "col" |
| 32D | 0F 0A 22030000 2903 0000 | map leaf, size 10: @322 → @329 |
| 337 | 6C 236C6F63616C | txt "#local" |
| 33E | 4C 3F636F6C | txt "?col" |
| 343 | 0F 0A 37030000 3E03 0000 | map leaf, size 10: @337 → @33E |
| 34D | 0E 15 00 0700 030000 00 18030000 2D0300 00 43030000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @318 → @32D → @343 |
| 362 | 6C 236C6F63616C | txt "#local" |
| 369 | 6C 3F7069656365 | txt "?piece" |
| 370 | 0F 0A 62030000 6903 0000 | map leaf, size 10: @362 → @369 |
| 37A | 6C 236C6F63616C | txt "#local" |
| 381 | 6C 737175617265 | txt "square" |
| 388 | 0F 0A 7A030000 8103 0000 | map leaf, size 10: @37A → @381 |
| 392 | 6C 236C6F63616C | txt "#local" |
| 399 | 5C 3F66726F6D | txt "?from" |
| 39F | 0F 0A 92030000 9903 0000 | map leaf, size 10: @392 → @399 |
| 3A9 | 0E 15 00 0700 030000 00 70030000 880300 00 9F030000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @370 → @388 → @39F |
| 3BE | 6C 236C6F63616C | txt "#local" |
| 3C5 | 6C 3F7069656365 | txt "?piece" |
| 3CC | 0F 0A BE030000 C503 0000 | map leaf, size 10: @3BE → @3C5 |
| 3D6 | 6C 236C6F63616C | txt "#local" |
| 3DD | 5C 636F6C6F72 | txt "color" |
| 3E3 | 0F 0A D6030000 DD03 0000 | map leaf, size 10: @3D6 → @3DD |
| 3ED | 6C 236C6F63616C | txt "#local" |
| 3F4 | 6C 3F636F6C6F72 | txt "?color" |
| 3FB | 0F 0A ED030000 F403 0000 | map leaf, size 10: @3ED → @3F4 |
| 405 | 0E 15 00 0700 030000 00 CC030000 E30300 00 FB030000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @3CC → @3E3 → @3FB |
| 41A | 6C 236C6F63616C | txt "#local" |
| 421 | 6C 3F7069656365 | txt "?piece" |
| 428 | 0F 0A 1A040000 2104 0000 | map leaf, size 10: @41A → @421 |
| 432 | 6C 236C6F63616C | txt "#local" |
| 439 | 4C 72616E6B | txt "rank" |
| 43E | 0F 0A 32040000 3904 0000 | map leaf, size 10: @432 → @439 |
| 448 | 6C 236C6F63616C | txt "#local" |
| 44F | 5C 3F72616E6B | txt "?rank" |
| 455 | 0F 0A 48040000 4F04 0000 | map leaf, size 10: @448 → @44F |
| 45F | 0E 15 00 0700 030000 00 28040000 3E0400 00 55040000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @428 → @43E → @455 |
| 474 | 6C 236C6F63616C | txt "#local" |
| 47B | 6C 3F7069656365 | txt "?piece" |
| 482 | 0F 0A 74040000 7B04 0000 | map leaf, size 10: @474 → @47B |
| 48C | 6C 236C6F63616C | txt "#local" |
| 493 | 7C 666F7277617264 | txt "forward" |
| 49B | 0F 0A 8C040000 9304 0000 | map leaf, size 10: @48C → @493 |
| 4A5 | 6C 236C6F63616C | txt "#local" |
| 4AC | 8C 3F666F72776172 64 | txt "?forward" |
| 4B5 | 0F 0A A5040000 AC04 0000 | map leaf, size 10: @4A5 → @4AC |
| 4BF | 0E 15 00 0700 030000 00 82040000 9B0400 00 B5040000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @482 → @49B → @4B5 |
| 4D4 | 6C 236C6F63616C | txt "#local" |
| 4DB | 3C 3F746F | txt "?to" |
| 4DF | 0F 0A D4040000 DB04 0000 | map leaf, size 10: @4D4 → @4DB |
| 4E9 | 6C 236C6F63616C | txt "#local" |
| 4F0 | 6C 6E756D626572 | txt "number" |
| 4F7 | 0F 0A E9040000 F004 0000 | map leaf, size 10: @4E9 → @4F0 |
| 501 | 6C 236C6F63616C | txt "#local" |
| 508 | 2C 746F | txt "to" |
| 50B | 0F 0A 01050000 0805 0000 | map leaf, size 10: @501 → @508 |
| 515 | 0E 15 00 0700 030000 00 DF040000 F70400 00 0B050000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @4DF → @4F7 → @50B |
| 52A | 6C 236C6F63616C | txt "#local" |
| 531 | 3C 3F746F | txt "?to" |
| 535 | 0F 0A 2A050000 3105 0000 | map leaf, size 10: @52A → @531 |
| 53F | 5C 656D707479 | txt "empty" |
| 545 | 09 | bit true |
| 546 | 0F 0A 3F050000 4505 0000 | map leaf, size 10: @53F → @545 |
| 550 | 0E 11 00 0300 020000 00 35050000 460500 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @535 → @546 |
| 561 | 6C 236C6F63616C | txt "#local" |
| 568 | 3C 3F746F | txt "?to" |
| 56C | 0F 0A 61050000 6805 0000 | map leaf, size 10: @561 → @568 |
| 576 | 6C 236C6F63616C | txt "#local" |
| 57D | 3C 726F77 | txt "row" |
| 581 | 0F 0A 76050000 7D05 0000 | map leaf, size 10: @576 → @57D |
| 58B | 6C 236C6F63616C | txt "#local" |
| 592 | 7C 3F746F2D726F77 | txt "?to-row" |
| 59A | 0F 0A 8B050000 9205 0000 | map leaf, size 10: @58B → @592 |
| 5A4 | 0E 15 00 0700 030000 00 6C050000 810500 00 9A050000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @56C → @581 → @59A |
| 5B9 | 6C 236C6F63616C | txt "#local" |
| 5C0 | 3C 3F746F | txt "?to" |
| 5C4 | 0F 0A B9050000 C005 0000 | map leaf, size 10: @5B9 → @5C0 |
| 5CE | 6C 236C6F63616C | txt "#local" |
| 5D5 | 3C 636F6C | txt "col" |
| 5D9 | 0F 0A CE050000 D505 0000 | map leaf, size 10: @5CE → @5D5 |
| 5E3 | 6C 236C6F63616C | txt "#local" |
| 5EA | 7C 3F746F2D636F6C | txt "?to-col" |
| 5F2 | 0F 0A E3050000 EA05 0000 | map leaf, size 10: @5E3 → @5EA |
| 5FC | 0E 15 00 0700 030000 00 C4050000 D90500 00 F2050000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @5C4 → @5D9 → @5F2 |
| 611 | 6C 236C6F63616C | txt "#local" |
| 618 | 7C 3F746F2D636F6C | txt "?to-col" |
| 620 | 0F 0A 11060000 1806 0000 | map leaf, size 10: @611 → @618 |
| 62A | 6C 236C6F63616C | txt "#local" |
| 631 | 4C 3F636F6C | txt "?col" |
| 636 | 0F 0A 2A060000 3106 0000 | map leaf, size 10: @62A → @631 |
| 640 | 1C 2D | txt "-" |
| 642 | 0E 15 00 0700 030000 00 40060000 200600 00 36060000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @640 → @620 → @636 |
| 657 | 7C 23696E766F6B65 | txt "#invoke" |
| 65F | 0F 0A 57060000 4206 0000 | map leaf, size 10: @657 → @642 |
| 669 | 8C 6D6174682F6162 73 | txt "math/abs" |
| 672 | 0E 11 00 0300 020000 00 69060000 5F0600 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @669 → @65F |
| 683 | 7C 23696E766F6B65 | txt "#invoke" |
| 68B | 0F 0A 83060000 7206 0000 | map leaf, size 10: @683 → @672 |
| 695 | 1C 3D | txt "=" |
| 697 | 02 01000000000000 00 | i64 1 |
| 6A0 | 0E 15 00 0700 030000 00 95060000 8B0600 00 97060000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @695 → @68B → @697 |
| 6B5 | 7C 23696E766F6B65 | txt "#invoke" |
| 6BD | 0F 0A B5060000 A006 0000 | map leaf, size 10: @6B5 → @6A0 |
| 6C7 | 6C 236C6F63616C | txt "#local" |
| 6CE | 7C 3F746F2D726F77 | txt "?to-row" |
| 6D6 | 0F 0A C7060000 CE06 0000 | map leaf, size 10: @6C7 → @6CE |
| 6E0 | 6C 236C6F63616C | txt "#local" |
| 6E7 | 4C 3F726F77 | txt "?row" |
| 6EC | 0F 0A E0060000 E706 0000 | map leaf, size 10: @6E0 → @6E7 |
| 6F6 | 1C 2D | txt "-" |
| 6F8 | 0E 15 00 0700 030000 00 F6060000 D60600 00 EC060000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @6F6 → @6D6 → @6EC |
| 70D | 7C 23696E766F6B65 | txt "#invoke" |
| 715 | 0F 0A 0D070000 F806 0000 | map leaf, size 10: @70D → @6F8 |
| 71F | 8C 6D6174682F6162 73 | txt "math/abs" |
| 728 | 0E 11 00 0300 020000 00 1F070000 150700 00 | array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @71F → @715 |
| 739 | 7C 23696E766F6B65 | txt "#invoke" |
| 741 | 0F 0A 39070000 2807 0000 | map leaf, size 10: @739 → @728 |
| 74B | 1C 3D | txt "=" |
| 74D | 02 01000000000000 00 | i64 1 |
| 756 | 0E 15 00 0700 030000 00 4B070000 410700 00 4D070000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @74B → @741 → @74D |
| 76B | 7C 23696E766F6B65 | txt "#invoke" |
| 773 | 0F 0A 6B070000 5607 0000 | map leaf, size 10: @76B → @756 |
| 77D | 6C 236C6F63616C | txt "#local" |
| 784 | 5C 3F72616E6B | txt "?rank" |
| 78A | 0F 0A 7D070000 8407 0000 | map leaf, size 10: @77D → @784 |
| 794 | 1C 3D | txt "=" |
| 796 | 4C 6B696E67 | txt "king" |
| 79B | 0E 15 00 0700 030000 00 94070000 8A0700 00 96070000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @794 → @78A → @796 |
| 7B0 | 7C 23696E766F6B65 | txt "#invoke" |
| 7B8 | 0F 0A B0070000 9B07 0000 | map leaf, size 10: @7B0 → @79B |
| 7C2 | 6C 236C6F63616C | txt "#local" |
| 7C9 | 7C 3F746F2D726F77 | txt "?to-row" |
| 7D1 | 0F 0A C2070000 C907 0000 | map leaf, size 10: @7C2 → @7C9 |
| 7DB | 6C 236C6F63616C | txt "#local" |
| 7E2 | 4C 3F726F77 | txt "?row" |
| 7E7 | 0F 0A DB070000 E207 0000 | map leaf, size 10: @7DB → @7E2 |
| 7F1 | 1C 2D | txt "-" |
| 7F3 | 0E 15 00 0700 030000 00 F1070000 D10700 00 E7070000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @7F1 → @7D1 → @7E7 |
| 808 | 7C 23696E766F6B65 | txt "#invoke" |
| 810 | 0F 0A 08080000 F307 0000 | map leaf, size 10: @808 → @7F3 |
| 81A | 6C 236C6F63616C | txt "#local" |
| 821 | 8C 3F666F72776172 64 | txt "?forward" |
| 82A | 0F 0A 1A080000 2108 0000 | map leaf, size 10: @81A → @821 |
| 834 | 1C 3D | txt "=" |
| 836 | 0E 15 00 0700 030000 00 34080000 100800 00 2A080000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @834 → @810 → @82A |
| 84B | 7C 23696E766F6B65 | txt "#invoke" |
| 853 | 0F 0A 4B080000 3608 0000 | map leaf, size 10: @84B → @836 |
| 85D | 2C 6F72 | txt "or" |
| 860 | 0E 15 00 0700 030000 00 5D080000 B80700 00 53080000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @85D → @7B8 → @853 |
| 875 | 7C 23696E766F6B65 | txt "#invoke" |
| 87D | 0F 0A 75080000 6008 0000 | map leaf, size 10: @875 → @860 |
| 887 | 4E 45 00 FFFF 960100 00 EC010000 450200 00 9F020000 F60200 00 4D030000 A90300 00 05040000 5F0400 00 BF040000 150500 00 50050000 A40500 00 FC050000 BD0600 00 73070000 | array leaf, size 69, shift 0, bitmap FFFF: @196 → @1EC → @245 → @29F → @2F6 → @34D → @3A9 → @405 → @45F → @4BF → @515 → @550 → @5A4 → @5FC → @6BD → @773 |
| 8CC | 4E 09 00 0100 7D0800 00 | array leaf, size 9, shift 0, bitmap 0001: @87D |
| 8D5 | 06 11 04 0300 110000 00 87080000 CC0800 00 | array branch, size 17, shift 4, bitmap 0003, count 17 (root): @887 → @8CC |
| 8E6 | 5C 7768657265 | txt "where" |
| 8EC | 0F 0A E6080000 D508 0000 | map leaf, size 10: @8E6 → @8D5 |
| 8F6 | 4C 66696E64 | txt "find" |
| 8FB | 0F 0A F6080000 4E01 0000 | map leaf, size 10: @8F6 → @14E |
| 905 | 07 0E 0A000000 EC08 0000 FB080000 | map branch, size 14, depth 0 (root), slots 1, 3: @8EC → @8FB |
| 913 | 6C 236C6F63616C | txt "#local" |
| 91A | 3C 3F746F | txt "?to" |
| 91E | 0F 0A 13090000 1A09 0000 | map leaf, size 10: @913 → @91A |
| 928 | 5C 236C696E6B | txt "#link" |
| 92E | 0F 0A 28090000 1E09 0000 | map leaf, size 10: @928 → @91E |
| 938 | 6C 737175617265 | txt "square" |
| 93F | 0F 0A 38090000 2E09 0000 | map leaf, size 10: @938 → @92E |
| 949 | 5C 656D707479 | txt "empty" |
| 94F | 09 | bit true |
| 950 | 0F 0A 49090000 4F09 0000 | map leaf, size 10: @949 → @94F |
| 95A | 5C 656D707479 | txt "empty" |
| 960 | 01 | bit false |
| 961 | 0F 0A 5A090000 6009 0000 | map leaf, size 10: @95A → @960 |
| 96B | 6C 236C6F63616C | txt "#local" |
| 972 | 5C 3F6E657874 | txt "?next" |
| 978 | 0F 0A 6B090000 7209 0000 | map leaf, size 10: @96B → @972 |
| 982 | 6C 236C6F63616C | txt "#local" |
| 989 | 6C 3F636F6C6F72 | txt "?color" |
| 990 | 0F 0A 82090000 8909 0000 | map leaf, size 10: @982 → @989 |
| 99A | 4C 6E657874 | txt "next" |
| 99F | 0F 0A 9A090000 9009 0000 | map leaf, size 10: @99A → @990 |
| 9A9 | 4C 7475726E | txt "turn" |
| 9AE | 0F 0A A9090000 7809 0000 | map leaf, size 10: @9A9 → @978 |
| 9B8 | 07 0E 00880000 9F09 0000 AE090000 | map branch, size 14, depth 0 (root), slots 11, 15: @99F → @9AE |
| 9C6 | 5C 3F66726F6D | txt "?from" |
| 9CC | 0F 0A C6090000 5009 0000 | map leaf, size 10: @9C6 → @950 |
| 9D6 | 6C 3F7069656365 | txt "?piece" |
| 9DD | 0F 0A D6090000 3F09 0000 | map leaf, size 10: @9D6 → @93F |
| 9E7 | 5C 3F67616D65 | txt "?game" |
| 9ED | 0F 0A E7090000 B809 0000 | map leaf, size 10: @9E7 → @9B8 |
| 9F7 | 3C 3F746F | txt "?to" |
| 9FB | 0F 0A F7090000 6109 0000 | map leaf, size 10: @9F7 → @961 |
| A05 | 07 16 14050000 CC09 0000 DD090000 ED09 0000 FB090000 | map branch, size 22, depth 0 (root), slots 2, 4, 8, 10: @9CC → @9DD → @9ED → @9FB |
| A1B | 5C 7175657279 | txt "query" |
| A21 | 0F 0A 1B0A0000 0509 0000 | map leaf, size 10: @A1B → @905 |
| A2B | 5C 7061746368 | txt "patch" |
| A31 | 0F 0A 2B0A0000 050A 0000 | map leaf, size 10: @A2B → @A05 |
| A3B | 07 0E 40020000 210A 0000 310A0000 | map branch, size 14, depth 2, slots 6, 9: @A21 → @A31 |
| A49 | 07 0A 01000000 3B0A 0000 | map branch, size 10, depth 1, slots 0: @A3B |
| A53 | 07 0A 80000000 490A 0000 | map branch, size 10, depth 0 (root), slots 7: @A49 |
| A5D | BC 6465666D757461 74696F6E | txt "defmutation" |
| A69 | 0E 1D 00 1F00 050000 00 5D0A0000 100000 00 44000000 AB0000 00 530A0000 | array leaf, size 29, shift 0, bitmap 001F, count 5 (root): @A5D → @10 → @44 → @AB → @A53 |
| A86 | 7C 23696E766F6B65 | txt "#invoke" |
| A8E | 0F 0A 860A0000 690A 0000 | map leaf, size 10: @A86 → @A69 |
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| A98 | 8E0A0000 00000000 | root → @A8E; previous: none |
The parameters and the contract
[from to] is the parameter vector, and [int? int? => map?] is the
contract. The two parameters are the numbers of the source and destination
squares, and the result is a map. The SDK reads the contract, so the generated
Move method takes two int64 values.
The rules in the query
Each clause of where must match, or the query selects no row. The first
three clauses read the turn and next colors of the game. The next clauses
find the square with the number from, the piece on that square, and the
piece's color, rank and forward step. The clause [?piece color ?color]
uses the same ?color as the turn clause, so the piece must have the color
that has the turn.
The clause [?to <empty>] requires the destination square to have the
<empty> tag. The three predicates at the end compare numbers. The column and
the row must each change by 1. The row must change by the forward step of
the piece, or the piece must be a king.
The patch
The patch writes four entities for the selected row. square #link ?to links
the piece to the destination square. Without #link, the field would store
the entity ID of the square as an integer. ?from {<empty>} adds the tag to
the source square, and ?to {<!empty>} removes it from the destination. A
tag that starts with ! retracts the tag. ?game {turn ?next next ?color}
interchanges the two colors, so the other player has the turn.
A move that does not obey the rules selects no row, so the patch writes
nothing. The mutation then publishes no transaction, and the Transaction
field of the Go result is nil.
Make the move
Replace the export form with this form, so that the SDK can call move:
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 6C 236C6F63616C | txt "#local" |
| 0B | 5C 7365747570 | txt "setup" |
| 11 | 0F 0A 04000000 0B00 0000 | map leaf, size 10: @4 → @B |
| 1B | 6C 236C6F63616C | txt "#local" |
| 22 | 5C 626F617264 | txt "board" |
| 28 | 0F 0A 1B000000 2200 0000 | map leaf, size 10: @1B → @22 |
| 32 | 6C 236C6F63616C | txt "#local" |
| 39 | 4C 6D6F7665 | txt "move" |
| 3E | 0F 0A 32000000 3900 0000 | map leaf, size 10: @32 → @39 |
| 48 | 6C 6578706F7274 | txt "export" |
| 4F | 0E 19 00 0F00 040000 00 48000000 110000 00 28000000 3E0000 00 | array leaf, size 25, shift 0, bitmap 000F, count 4 (root): @48 → @11 → @28 → @3E |
| 68 | 7C 23696E766F6B65 | txt "#invoke" |
| 70 | 0F 0A 68000000 4F00 0000 | map leaf, size 10: @68 → @4F |
| 7A | 70000000 00000000 | root → @70; previous: none |
Run go run ./seed again. It saves the changed namespace and generates the SDK
again with the Move method.
Create move/main.go with this program. Red moves from 11 to 15. Then Red
tries to move from 15 to 19 before Black moves. The program prints the result
of each move and then the board.
package main
import (
"fmt"
"log"
"example.com/checkers/sdk"
)
func main() {
db, err := sdk.Open(sdk.Config{Plugins: &sdk.Plugins{
Stdlib: true,
Database: &sdk.DatabaseSettings{Path: "checkers.db"},
}})
if err != nil {
log.Fatal(err)
}
defer func() {
if err := db.Close(); err != nil {
log.Print(err)
}
}()
// Red moves from 11 to 15, then tries to move again before Black.
moves := [][2]int64{{11, 15}, {15, 19}}
for i := range moves {
move := moves[i]
result, err := db.CheckersBoards.Move(move[0], move[1])
if err != nil {
log.Fatal(err)
}
if result.Transaction == nil {
fmt.Printf("%d-%d: rejected\n", move[0], move[1])
continue
}
fmt.Printf("%d-%d: moved\n", move[0], move[1])
}
pieces, err := db.CheckersBoards.Board()
if err != nil {
log.Fatal(err)
}
for i := range pieces {
fmt.Printf("%d: %s %s\n", pieces[i].Number, pieces[i].Color, pieces[i].Rank)
}
}Run go run ./move. It prints:
11-15: moved 15-19: rejected 15: red uncrowned 18: red uncrowned 27: black uncrowned 32: black uncrowned
The second move did not obey the turn rule, so the database did not change. The board shows the Red piece on 15 and the other pieces on their start squares.