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.

TRON2.7 kB
Offset (hex)Bytes (hex)Meaning
00054 52 4F 4Emagic TRON
0046C 236C6F63616Ctxt "#local"
00B4C 6D6F7665txt "move"
0100F 0A 04000000 0B00 0000map leaf, size 10: @4 → @B
01A6C 236C6F63616Ctxt "#local"
0214C 66726F6Dtxt "from"
0260F 0A 1A000000 2100 0000map leaf, size 10: @1A → @21
0306C 236C6F63616Ctxt "#local"
0372C 746Ftxt "to"
03A0F 0A 30000000 3700 0000map leaf, size 10: @30 → @37
0440E 11 00 0300 020000 00 26000000 3A0000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @26 → @3A
0556C 236C6F63616Ctxt "#local"
05C4C 696E743Ftxt "int?"
0610F 0A 55000000 5C00 0000map leaf, size 10: @55 → @5C
06B6C 236C6F63616Ctxt "#local"
0724C 696E743Ftxt "int?"
0770F 0A 6B000000 7200 0000map leaf, size 10: @6B → @72
0816C 236C6F63616Ctxt "#local"
0882C 3D3Etxt "=>"
08B0F 0A 81000000 8800 0000map leaf, size 10: @81 → @88
0956C 236C6F63616Ctxt "#local"
09C4C 6D61703Ftxt "map?"
0A10F 0A 95000000 9C00 0000map leaf, size 10: @95 → @9C
0AB0E 19 00 0F00 040000 00 61000000 770000 00 8B000000 A10000 00array leaf, size 25, shift 0, bitmap 000F, count 4 (root): @61 → @77 → @8B → @A1
0C46C 236C6F63616Ctxt "#local"
0CB5C 3F67616D65txt "?game"
0D10F 0A C4000000 CB00 0000map leaf, size 10: @C4 → @CB
0DB6C 236C6F63616Ctxt "#local"
0E26C 3F7069656365txt "?piece"
0E90F 0A DB000000 E200 0000map leaf, size 10: @DB → @E2
0F36C 236C6F63616Ctxt "#local"
0FA5C 3F66726F6Dtxt "?from"
Show all 295 nodes
Offset (hex)Bytes (hex)Meaning
1000F 0A F3000000 FA00 0000map leaf, size 10: @F3 → @FA
10A6C 236C6F63616Ctxt "#local"
1113C 3F746Ftxt "?to"
1150F 0A 0A010000 1101 0000map leaf, size 10: @10A → @111
11F6C 236C6F63616Ctxt "#local"
1266C 3F636F6C6F72txt "?color"
12D0F 0A 1F010000 2601 0000map leaf, size 10: @11F → @126
1376C 236C6F63616Ctxt "#local"
13E5C 3F6E657874txt "?next"
1440F 0A 37010000 3E01 0000map leaf, size 10: @137 → @13E
14E0E 21 00 3F00 060000 00 D1000000 E90000 00 00010000 150100 00 2D010000 440100 00array leaf, size 33, shift 0, bitmap 003F, count 6 (root): @D1 → @E9 → @100 → @115 → @12D → @144
16F6C 236C6F63616Ctxt "#local"
1765C 3F67616D65txt "?game"
17C0F 0A 6F010000 7601 0000map leaf, size 10: @16F → @176
1864C 67616D65txt "game"
18B09bit true
18C0F 0A 86010000 8B01 0000map leaf, size 10: @186 → @18B
1960E 11 00 0300 020000 00 7C010000 8C0100 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @17C → @18C
1A76C 236C6F63616Ctxt "#local"
1AE5C 3F67616D65txt "?game"
1B40F 0A A7010000 AE01 0000map leaf, size 10: @1A7 → @1AE
1BE6C 236C6F63616Ctxt "#local"
1C54C 7475726Etxt "turn"
1CA0F 0A BE010000 C501 0000map leaf, size 10: @1BE → @1C5
1D46C 236C6F63616Ctxt "#local"
1DB6C 3F636F6C6F72txt "?color"
1E20F 0A D4010000 DB01 0000map leaf, size 10: @1D4 → @1DB
1EC0E 15 00 0700 030000 00 B4010000 CA0100 00 E2010000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @1B4 → @1CA → @1E2
2016C 236C6F63616Ctxt "#local"
2085C 3F67616D65txt "?game"
20E0F 0A 01020000 0802 0000map leaf, size 10: @201 → @208
2186C 236C6F63616Ctxt "#local"
21F4C 6E657874txt "next"
2240F 0A 18020000 1F02 0000map leaf, size 10: @218 → @21F
22E6C 236C6F63616Ctxt "#local"
2355C 3F6E657874txt "?next"
23B0F 0A 2E020000 3502 0000map leaf, size 10: @22E → @235
2450E 15 00 0700 030000 00 0E020000 240200 00 3B020000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @20E → @224 → @23B
25A6C 236C6F63616Ctxt "#local"
2615C 3F66726F6Dtxt "?from"
2670F 0A 5A020000 6102 0000map leaf, size 10: @25A → @261
2716C 236C6F63616Ctxt "#local"
2786C 6E756D626572txt "number"
27F0F 0A 71020000 7802 0000map leaf, size 10: @271 → @278
2896C 236C6F63616Ctxt "#local"
2904C 66726F6Dtxt "from"
2950F 0A 89020000 9002 0000map leaf, size 10: @289 → @290
29F0E 15 00 0700 030000 00 67020000 7F0200 00 95020000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @267 → @27F → @295
2B46C 236C6F63616Ctxt "#local"
2BB5C 3F66726F6Dtxt "?from"
2C10F 0A B4020000 BB02 0000map leaf, size 10: @2B4 → @2BB
2CB6C 236C6F63616Ctxt "#local"
2D23C 726F77txt "row"
2D60F 0A CB020000 D202 0000map leaf, size 10: @2CB → @2D2
2E06C 236C6F63616Ctxt "#local"
2E74C 3F726F77txt "?row"
2EC0F 0A E0020000 E702 0000map leaf, size 10: @2E0 → @2E7
2F60E 15 00 0700 030000 00 C1020000 D60200 00 EC020000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @2C1 → @2D6 → @2EC
30B6C 236C6F63616Ctxt "#local"
3125C 3F66726F6Dtxt "?from"
3180F 0A 0B030000 1203 0000map leaf, size 10: @30B → @312
3226C 236C6F63616Ctxt "#local"
3293C 636F6Ctxt "col"
32D0F 0A 22030000 2903 0000map leaf, size 10: @322 → @329
3376C 236C6F63616Ctxt "#local"
33E4C 3F636F6Ctxt "?col"
3430F 0A 37030000 3E03 0000map leaf, size 10: @337 → @33E
34D0E 15 00 0700 030000 00 18030000 2D0300 00 43030000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @318 → @32D → @343
3626C 236C6F63616Ctxt "#local"
3696C 3F7069656365txt "?piece"
3700F 0A 62030000 6903 0000map leaf, size 10: @362 → @369
37A6C 236C6F63616Ctxt "#local"
3816C 737175617265txt "square"
3880F 0A 7A030000 8103 0000map leaf, size 10: @37A → @381
3926C 236C6F63616Ctxt "#local"
3995C 3F66726F6Dtxt "?from"
39F0F 0A 92030000 9903 0000map leaf, size 10: @392 → @399
3A90E 15 00 0700 030000 00 70030000 880300 00 9F030000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @370 → @388 → @39F
3BE6C 236C6F63616Ctxt "#local"
3C56C 3F7069656365txt "?piece"
3CC0F 0A BE030000 C503 0000map leaf, size 10: @3BE → @3C5
3D66C 236C6F63616Ctxt "#local"
3DD5C 636F6C6F72txt "color"
3E30F 0A D6030000 DD03 0000map leaf, size 10: @3D6 → @3DD
3ED6C 236C6F63616Ctxt "#local"
3F46C 3F636F6C6F72txt "?color"
3FB0F 0A ED030000 F403 0000map leaf, size 10: @3ED → @3F4
4050E 15 00 0700 030000 00 CC030000 E30300 00 FB030000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @3CC → @3E3 → @3FB
41A6C 236C6F63616Ctxt "#local"
4216C 3F7069656365txt "?piece"
4280F 0A 1A040000 2104 0000map leaf, size 10: @41A → @421
4326C 236C6F63616Ctxt "#local"
4394C 72616E6Btxt "rank"
43E0F 0A 32040000 3904 0000map leaf, size 10: @432 → @439
4486C 236C6F63616Ctxt "#local"
44F5C 3F72616E6Btxt "?rank"
4550F 0A 48040000 4F04 0000map leaf, size 10: @448 → @44F
45F0E 15 00 0700 030000 00 28040000 3E0400 00 55040000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @428 → @43E → @455
4746C 236C6F63616Ctxt "#local"
47B6C 3F7069656365txt "?piece"
4820F 0A 74040000 7B04 0000map leaf, size 10: @474 → @47B
48C6C 236C6F63616Ctxt "#local"
4937C 666F7277617264txt "forward"
49B0F 0A 8C040000 9304 0000map leaf, size 10: @48C → @493
4A56C 236C6F63616Ctxt "#local"
4AC8C 3F666F72776172 64txt "?forward"
4B50F 0A A5040000 AC04 0000map leaf, size 10: @4A5 → @4AC
4BF0E 15 00 0700 030000 00 82040000 9B0400 00 B5040000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @482 → @49B → @4B5
4D46C 236C6F63616Ctxt "#local"
4DB3C 3F746Ftxt "?to"
4DF0F 0A D4040000 DB04 0000map leaf, size 10: @4D4 → @4DB
4E96C 236C6F63616Ctxt "#local"
4F06C 6E756D626572txt "number"
4F70F 0A E9040000 F004 0000map leaf, size 10: @4E9 → @4F0
5016C 236C6F63616Ctxt "#local"
5082C 746Ftxt "to"
50B0F 0A 01050000 0805 0000map leaf, size 10: @501 → @508
5150E 15 00 0700 030000 00 DF040000 F70400 00 0B050000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @4DF → @4F7 → @50B
52A6C 236C6F63616Ctxt "#local"
5313C 3F746Ftxt "?to"
5350F 0A 2A050000 3105 0000map leaf, size 10: @52A → @531
53F5C 656D707479txt "empty"
54509bit true
5460F 0A 3F050000 4505 0000map leaf, size 10: @53F → @545
5500E 11 00 0300 020000 00 35050000 460500 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @535 → @546
5616C 236C6F63616Ctxt "#local"
5683C 3F746Ftxt "?to"
56C0F 0A 61050000 6805 0000map leaf, size 10: @561 → @568
5766C 236C6F63616Ctxt "#local"
57D3C 726F77txt "row"
5810F 0A 76050000 7D05 0000map leaf, size 10: @576 → @57D
58B6C 236C6F63616Ctxt "#local"
5927C 3F746F2D726F77txt "?to-row"
59A0F 0A 8B050000 9205 0000map leaf, size 10: @58B → @592
5A40E 15 00 0700 030000 00 6C050000 810500 00 9A050000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @56C → @581 → @59A
5B96C 236C6F63616Ctxt "#local"
5C03C 3F746Ftxt "?to"
5C40F 0A B9050000 C005 0000map leaf, size 10: @5B9 → @5C0
5CE6C 236C6F63616Ctxt "#local"
5D53C 636F6Ctxt "col"
5D90F 0A CE050000 D505 0000map leaf, size 10: @5CE → @5D5
5E36C 236C6F63616Ctxt "#local"
5EA7C 3F746F2D636F6Ctxt "?to-col"
5F20F 0A E3050000 EA05 0000map leaf, size 10: @5E3 → @5EA
5FC0E 15 00 0700 030000 00 C4050000 D90500 00 F2050000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @5C4 → @5D9 → @5F2
6116C 236C6F63616Ctxt "#local"
6187C 3F746F2D636F6Ctxt "?to-col"
6200F 0A 11060000 1806 0000map leaf, size 10: @611 → @618
62A6C 236C6F63616Ctxt "#local"
6314C 3F636F6Ctxt "?col"
6360F 0A 2A060000 3106 0000map leaf, size 10: @62A → @631
6401C 2Dtxt "-"
6420E 15 00 0700 030000 00 40060000 200600 00 36060000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @640 → @620 → @636
6577C 23696E766F6B65txt "#invoke"
65F0F 0A 57060000 4206 0000map leaf, size 10: @657 → @642
6698C 6D6174682F6162 73txt "math/abs"
6720E 11 00 0300 020000 00 69060000 5F0600 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @669 → @65F
6837C 23696E766F6B65txt "#invoke"
68B0F 0A 83060000 7206 0000map leaf, size 10: @683 → @672
6951C 3Dtxt "="
69702 01000000000000 00i64 1
6A00E 15 00 0700 030000 00 95060000 8B0600 00 97060000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @695 → @68B → @697
6B57C 23696E766F6B65txt "#invoke"
6BD0F 0A B5060000 A006 0000map leaf, size 10: @6B5 → @6A0
6C76C 236C6F63616Ctxt "#local"
6CE7C 3F746F2D726F77txt "?to-row"
6D60F 0A C7060000 CE06 0000map leaf, size 10: @6C7 → @6CE
6E06C 236C6F63616Ctxt "#local"
6E74C 3F726F77txt "?row"
6EC0F 0A E0060000 E706 0000map leaf, size 10: @6E0 → @6E7
6F61C 2Dtxt "-"
6F80E 15 00 0700 030000 00 F6060000 D60600 00 EC060000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @6F6 → @6D6 → @6EC
70D7C 23696E766F6B65txt "#invoke"
7150F 0A 0D070000 F806 0000map leaf, size 10: @70D → @6F8
71F8C 6D6174682F6162 73txt "math/abs"
7280E 11 00 0300 020000 00 1F070000 150700 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @71F → @715
7397C 23696E766F6B65txt "#invoke"
7410F 0A 39070000 2807 0000map leaf, size 10: @739 → @728
74B1C 3Dtxt "="
74D02 01000000000000 00i64 1
7560E 15 00 0700 030000 00 4B070000 410700 00 4D070000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @74B → @741 → @74D
76B7C 23696E766F6B65txt "#invoke"
7730F 0A 6B070000 5607 0000map leaf, size 10: @76B → @756
77D6C 236C6F63616Ctxt "#local"
7845C 3F72616E6Btxt "?rank"
78A0F 0A 7D070000 8407 0000map leaf, size 10: @77D → @784
7941C 3Dtxt "="
7964C 6B696E67txt "king"
79B0E 15 00 0700 030000 00 94070000 8A0700 00 96070000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @794 → @78A → @796
7B07C 23696E766F6B65txt "#invoke"
7B80F 0A B0070000 9B07 0000map leaf, size 10: @7B0 → @79B
7C26C 236C6F63616Ctxt "#local"
7C97C 3F746F2D726F77txt "?to-row"
7D10F 0A C2070000 C907 0000map leaf, size 10: @7C2 → @7C9
7DB6C 236C6F63616Ctxt "#local"
7E24C 3F726F77txt "?row"
7E70F 0A DB070000 E207 0000map leaf, size 10: @7DB → @7E2
7F11C 2Dtxt "-"
7F30E 15 00 0700 030000 00 F1070000 D10700 00 E7070000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @7F1 → @7D1 → @7E7
8087C 23696E766F6B65txt "#invoke"
8100F 0A 08080000 F307 0000map leaf, size 10: @808 → @7F3
81A6C 236C6F63616Ctxt "#local"
8218C 3F666F72776172 64txt "?forward"
82A0F 0A 1A080000 2108 0000map leaf, size 10: @81A → @821
8341C 3Dtxt "="
8360E 15 00 0700 030000 00 34080000 100800 00 2A080000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @834 → @810 → @82A
84B7C 23696E766F6B65txt "#invoke"
8530F 0A 4B080000 3608 0000map leaf, size 10: @84B → @836
85D2C 6F72txt "or"
8600E 15 00 0700 030000 00 5D080000 B80700 00 53080000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @85D → @7B8 → @853
8757C 23696E766F6B65txt "#invoke"
87D0F 0A 75080000 6008 0000map leaf, size 10: @875 → @860
8874E 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 73070000array leaf, size 69, shift 0, bitmap FFFF: @196 → @1EC → @245 → @29F → @2F6 → @34D → @3A9 → @405 → @45F → @4BF → @515 → @550 → @5A4 → @5FC → @6BD → @773
8CC4E 09 00 0100 7D0800 00array leaf, size 9, shift 0, bitmap 0001: @87D
8D506 11 04 0300 110000 00 87080000 CC0800 00array branch, size 17, shift 4, bitmap 0003, count 17 (root): @887 → @8CC
8E65C 7768657265txt "where"
8EC0F 0A E6080000 D508 0000map leaf, size 10: @8E6 → @8D5
8F64C 66696E64txt "find"
8FB0F 0A F6080000 4E01 0000map leaf, size 10: @8F6 → @14E
90507 0E 0A000000 EC08 0000 FB080000map branch, size 14, depth 0 (root), slots 1, 3: @8EC → @8FB
9136C 236C6F63616Ctxt "#local"
91A3C 3F746Ftxt "?to"
91E0F 0A 13090000 1A09 0000map leaf, size 10: @913 → @91A
9285C 236C696E6Btxt "#link"
92E0F 0A 28090000 1E09 0000map leaf, size 10: @928 → @91E
9386C 737175617265txt "square"
93F0F 0A 38090000 2E09 0000map leaf, size 10: @938 → @92E
9495C 656D707479txt "empty"
94F09bit true
9500F 0A 49090000 4F09 0000map leaf, size 10: @949 → @94F
95A5C 656D707479txt "empty"
96001bit false
9610F 0A 5A090000 6009 0000map leaf, size 10: @95A → @960
96B6C 236C6F63616Ctxt "#local"
9725C 3F6E657874txt "?next"
9780F 0A 6B090000 7209 0000map leaf, size 10: @96B → @972
9826C 236C6F63616Ctxt "#local"
9896C 3F636F6C6F72txt "?color"
9900F 0A 82090000 8909 0000map leaf, size 10: @982 → @989
99A4C 6E657874txt "next"
99F0F 0A 9A090000 9009 0000map leaf, size 10: @99A → @990
9A94C 7475726Etxt "turn"
9AE0F 0A A9090000 7809 0000map leaf, size 10: @9A9 → @978
9B807 0E 00880000 9F09 0000 AE090000map branch, size 14, depth 0 (root), slots 11, 15: @99F → @9AE
9C65C 3F66726F6Dtxt "?from"
9CC0F 0A C6090000 5009 0000map leaf, size 10: @9C6 → @950
9D66C 3F7069656365txt "?piece"
9DD0F 0A D6090000 3F09 0000map leaf, size 10: @9D6 → @93F
9E75C 3F67616D65txt "?game"
9ED0F 0A E7090000 B809 0000map leaf, size 10: @9E7 → @9B8
9F73C 3F746Ftxt "?to"
9FB0F 0A F7090000 6109 0000map leaf, size 10: @9F7 → @961
A0507 16 14050000 CC09 0000 DD090000 ED09 0000 FB090000map branch, size 22, depth 0 (root), slots 2, 4, 8, 10: @9CC → @9DD → @9ED → @9FB
A1B5C 7175657279txt "query"
A210F 0A 1B0A0000 0509 0000map leaf, size 10: @A1B → @905
A2B5C 7061746368txt "patch"
A310F 0A 2B0A0000 050A 0000map leaf, size 10: @A2B → @A05
A3B07 0E 40020000 210A 0000 310A0000map branch, size 14, depth 2, slots 6, 9: @A21 → @A31
A4907 0A 01000000 3B0A 0000map branch, size 10, depth 1, slots 0: @A3B
A5307 0A 80000000 490A 0000map branch, size 10, depth 0 (root), slots 7: @A49
A5DBC 6465666D757461 74696F6Etxt "defmutation"
A690E 1D 00 1F00 050000 00 5D0A0000 100000 00 44000000 AB0000 00 530A0000array leaf, size 29, shift 0, bitmap 001F, count 5 (root): @A5D → @10 → @44 → @AB → @A53
A867C 23696E766F6B65txt "#invoke"
A8E0F 0A 860A0000 690A 0000map leaf, size 10: @A86 → @A69
Offset (hex)Bytes (hex)Meaning

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:

TRON130 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
046C 236C6F63616Ctxt "#local"
0B5C 7365747570txt "setup"
110F 0A 04000000 0B00 0000map leaf, size 10: @4 → @B
1B6C 236C6F63616Ctxt "#local"
225C 626F617264txt "board"
280F 0A 1B000000 2200 0000map leaf, size 10: @1B → @22
326C 236C6F63616Ctxt "#local"
394C 6D6F7665txt "move"
3E0F 0A 32000000 3900 0000map leaf, size 10: @32 → @39
486C 6578706F7274txt "export"
4F0E 19 00 0F00 040000 00 48000000 110000 00 28000000 3E0000 00array leaf, size 25, shift 0, bitmap 000F, count 4 (root): @48 → @11 → @28 → @3E
687C 23696E766F6B65txt "#invoke"
700F 0A 68000000 4F00 0000map leaf, size 10: @68 → @4F

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.

go927 B
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:

text104 B
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.