| Menu | JAQForum Ver 26.09 |
Forum Index : Microcontroller and PC projects : MMbg PC3 - a complete backgammon program in MMBasic
| Page 1 of 2 |
||||||
![]() https://youtu.be/x2N5_EjmmYE Hello to all PC3 owners! I'd like to introduce MMbg PC3 - a complete backgammon program for the Pico Computer 3. Features - match play 1 to 15 points with doubling cube and Crawford rule - uses the neural nets of GNU Backgammon: the "big" engine plays at about gnubg "Expert" level (0-ply) and wins ~47 % of 5-point matches against gnubg "World class" (2-ply), measured over 1236 matches - written completely in MMBasic - no CSUB needed - HDMI graphics (MODE 3) with smooth animation, plus an ASCII board on the serial terminal - keyboard or USB mouse, multi-level undo, auto save and resume - .mat export and GNUbg IDs for analysis in gnubg, optional sound - for tinkerers: gnubg on a PC as opponent over WLAN, overnight test runs Requirements PC3 with firmware PicoMitePC3 V7.00.00 RC2 or later. Installation Unzip the ZIP onto the SD card, then: CHDIR "B:/mmbg" LOAD "mmbg_pc3.bas", C RUN The manual (English and German PDF) is included. The version for the PicoCalc (PiCa) will follow ... Have fun playing and testing! Please report all bugs here. Matthias MMbg_PC3.zip |
||||||
Wauw Cant wait to Try it out. Volhout Edited 2026-10-20 15:07 by Volhout |
||||||
That's great, I'm looking forward to the PicoCalc version. Does it also require MMbasic V7? If so, I'll have to update. |
||||||
Great, I really liked your game. I lost five times in a row. It must have a really good built-in opponent, or maybe I'm just a bad player, probably because I've always played the Eastern version of backgammon. :)) By the way, is it possible to make a game using the rules of Eastern backgammon? Thanks. |
||||||
Hi Javavi, Thanks a lot for your kind feedback! I'm really glad to hear you enjoyed playing the game (even if the AI gave you a tough time! :)). To answer your question about adding Eastern backgammon rules: to be honest, I'm not familiar with all the specific details and variations of Eastern backgammon. More importantly, the game's strong AI is based on the gnubg neural network, which was trained strictly on the standard Western rules. Teaching an AI to play Eastern backgammon would require building and training a whole new neural network from scratch for those specific rules. That isn't something I am planning to pursue for this project right now. However, the code is open for anyone who would like to adapt it or implement those rules themselves! Matthias |
||||||
I have the Pico Computer 2B FW V7.0.00b3 with 6MB PSRAM and 16MB Flash. MMBG starts wit ERROR "Not enough memory". Is there anything I can do about it? I changed to V7.00.00RC3 but same Error Edited 2026-10-23 22:23 by PilotPirx |
||||||
Matthias Great work PilotPirx You don't stay what variant of the firmware - HDMIUSB?. Also try updating to the latest version. Edited 2026-10-23 22:28 by matherp |
||||||
Thanks for trying MMbg! The current version is made for the Pico Computer 3 only (PicoMitePC3 firmware, 256 KB program memory, PSRAM). The PC2 has less RAM, so MMbg runs out of memory there. At the moment I'm working on the PicoCalc version, which has to get by with much less memory. Once that is done, a version for the PC2 should be possible too - but please be patient, it can't be done quickly. Matthias |
||||||
matherp Yes, PicoMiteHDMIUSBV7.00.00RC3 Is it possible to get more program memory? |
||||||
Just tested works perfectly with RC3. Did you load the program with LOAD "mmbg_pc3.bas", C as in Matthias' post and in the program header? The ,C is critical |
||||||
matherp One step further! Now i get the Error "[247] String too long" after loading neural nets (gnubg) |
||||||
I think that is because you are running from the A: drive. It is a bug in the program. Run from the B: drive. If you follow Matthias' directions exactly it definitely works Edited 2026-10-24 01:05 by matherp |
||||||
I run from the b: drive (sd-card). It seems to work when I comment out that line. |
||||||
OK, i found it. The program seems to use absolute paths. I had moved the directory one level down. Now it works. Thanks!!! ![]() |
||||||
are you running from a subdirectory or direct from B:/mmbg? |
||||||
At first i was running from a subdirectory b:/games/mmbg which doesn't work. Direct from b:/mmbg and loading with ,C work fine now. |
||||||
I am aware of the problem and it is on my agenda. |
||||||
![]() MMbg 1.10.34 – Backgammon for MMBasic, now also on the Colour Maximite 2 and the PicoCalc A new version of MMbg is available. The program mmbg_pc3.bas now runs on both the PC3 and the Colour Maximite 2, and for the PicoCalc there is the separate edition mmbg_pica.bas. New in this release
PicoCalc (MMbg PiCa 1.10.33): the same game with all engines up to big and deep, for a Pico 2 or Pico 2 W (PicoMite / WebMite RP2350, V7.00.00 RC3 or later). Runs with RAM and SD card only – see below. PS/2 mouse: besides a USB mouse, a PS/2 mouse (channel 2) is also recognised. On the CMM2, plug a dual-mode mouse into the lower USB socket and set OPTION MOUSE 0. Enter key: CR/LF no longer stops a running computer by accident (the CMM2 sends CR+LF for Enter). Setting up the CMM2 (only once) OPTION PICOMITE HDMI OPTION MOUSE 0 ' only with a mouse in the lower socket Then copy the folder mmbg to the SD card and start it: CHDIR "A:/mmbg" LOAD "mmbg_pc3.bas", C RUN There is no WLAN on the CMM2, so gnubg as an opponent (engine E) is not available. Everything else works as it does on the PC3. Hint for 7.00.00b3: if you get "Could not find the file" when starting from the prompt, start mmbg_pc3.bas from the file manager (FM) instead. This works fine and appears to be a beta issue. Behind the scenes: the big nets in the PicoCalc's small RAM The big gnubg nets (contact and crashed) have 250 inputs x 128 neurons = 32 000 weights each. As floating-point numbers that is 256 KB per net, 512 KB for both. The PC3 keeps them in PSRAM. The PicoCalc has no PSRAM and only about 270 KB of free RAM after loading MMbg, of which the game itself needs a good part. How it fits anyway:
Only the rows that are needed: in a real position only about 50 of the 250 inputs are non-zero, so each evaluation needs only those ~50 rows. Each row is processed with three fast firmware commands: MEMORY UNPACK, MATH SCALE and MATH C_ADD. Row buffer plus SD card: as many rows as the free RAM allows stay in a buffer (about 170 to 190 of the 250, with a 44 KB reserve left for the game). A missing row is read from the SD card in under 1 ms. A "clock" method decides which rows may be overwritten. In practice that means about 3 SD reads per second, and the computing time stays at ~0.5 s per move, the same as on the PC3. Does the rounding cost playing strength? Checked against the full-precision evaluation of the PC3: over more than 3 000 positions the equity differed by at most 0.0012, and 679 of 680 move decisions were identical (the one exception: two practically equal moves swapped places). An overnight run on a Pico 2 W against gnubg 2-ply won 199 of 450 matches (44.2 % ± 4.6 %), compared with 46.7 % on the PC3 – well within the statistical spread. The PicoCalc plays as strongly as the PC3. Videos PC3: https://youtu.be/x2N5_EjmmYE PicoCalc: https://youtube.com/shorts/c7xFFryiugg Many thanks to Peter for the OPTION PICOMITE / OPTION CRLF support in the CMM2 firmware. The full manual (English and German) is included in the zip file. Details on the packed nets are in Part 2, chapters P6 and P7. Matthias MMbg_1_10_34.zip |
||||||
Hi Matthias, I can confirm that your BG game will also run on a HDMIUSBI2S variant, which came before the PC3. Thanks for this. Regards Kevin. |
||||||
Hi Kevin, thanks a lot for testing and for letting me know! I only have the "PC1" myself, i.e. the PicoMite HDMI/USB Reference Design, unfortunately without PSRAM. That's why I started developing MMbg on the PC3. Good to know that the "PC2", the HDMIUSBI2S with PSRAM, runs it as well. I'll add it to a device compatibility list. Are there any other backgammon players here? I'd be glad to hear how MMbg plays on your machines. Matthias |
||||||
| Page 1 of 2 |
||||||
| The Back Shed's forum code is written, and hosted, in Australia. |