r/backgammon • • 4d ago

Yet Another Backgammon Engine: Grebe is fully open source, runs entirely in the browser, looks competitive with the top engines

Yes, just what everyone wanted: another backgammon engine. I built Grebe (for Generally Reliable Engine for Backgammon Evaluation lol) because i wanted an engine for BackgammonDB that ran in the browser, both to play against and for analysis. The goal was something "good enough": close enough to gnubg and XG that you can study with it and know the advice is sound in most positions.

How it works and how I measured it: https://backgammondb.com/grebe

You can play it now here: https://backgammondb.com/play (side note: i think the playing interface on bgdb is the best out there, works great on a phone in landscape if you hit full screen. but obv i'm biased)

Code: https://github.com/chalkstreamdev/grebe

npm: https://www.npmjs.com/package/@backgammondb/grebe

Most of this I didn't really do myself; i have not trained a new neural net. Grebe is built on Alex Strehl's PureTD network, which is incredibly strong, and on Eran Lambooij's HedgeHog board and cube code. So all credit there, and ty both for the MIT licenses (Grebe is also MIT licensed). Thanks also to Sage for a great public benchmark, which I used. On top of that, Grebe adds a few new things: search depth that changes with the position, exact two-sided bear-off tables (built on the fly when needed), a SIMD port to wasm, tuned cube efficiency, and match equity for match play.

Top line: It's a strong engine, but prob not frontier of engine analysis. Head to head, Grebe Smart beat or tied every engine i could test:

  • It beats gnubg at depth* 3 and depth 4, and Sage at depth 3, in money games and 5-point matches.
  • It beats both of HedgeHog's published networks (Fox 1.0 and Aureus) in HedgeHog's own open search at depth 2.
  • When i put those networks into Grebe's own search, it beats Aureus in money games, and the rest are too close to call.

XG World Class grades Grebe Smart's play at a PR of about 0.3 in money and matches, the closest to XG of any engine i tested (caveat: i tuned it against XG)

Grebe doesn't have any kind of truncated rollout right now, so it won't be as strong at the absolute front end. Even so, on Sage's benchmark it beats Sage 1T and is level with XG Roller+ (PR 0.41), while searching only to depth 3. Sage 2T/3T and XG Roller++ still score better (as will Gammon.ai's top truncated rollout, I'm sure).

Grebe Smart decides in under a second; it should feel instant on most decisions whether playing on desktop or phone. All the benchmark data is public (match files, PR tables, everything), so you can check any of this.

Why any of this matters:

  • If you're a web/app developer, including commercial tools, you can add strong analysis with a few lines of code and no server at all.
  • If you're a BackgammonDB user, you can now play on the site and every match and every position immediately goes into your database. Any text file you upload will be analyzed by either Grebe Quick or Smart.

(* i'm using "depth 2" and "depth 3" as an alternative to ply, to avoid ambiguity. Depth 3 = what XG calls 3-ply: every candidate move on roll, plus 2 more ply after that)

19 Upvotes

21 comments sorted by

3

u/teffflon 4d ago

this is already great, but do you plan to add in-game tutor mode? (or did i miss it)

2

u/chrismantis 4d ago

There's no tutor mode yet. Def something i could add. tbh not something i've really used before so wasn't really on my radar, but should not an easy thing to do, i'll add it to the todo list.

4

u/juicybot 4d ago

i love shitting all over these posts but backgammondb seems actually promising, hope this works out!

5

u/chrismantis 4d ago edited 3d ago

haha thank you. BGDB has been under constant development for going on a year now, so i'm hoping to have cleared the "weekend AI slop project" hurdle 😄

2

u/Aqua-marine-blu 4d ago edited 4d ago

Glad you took this step, less dependency on other bots make the app more accessible. 

  Hope in close future, the interface of backgammondb will be fully adapted for mobile ios  app. 

Also it will be nice to have a single graph for errors/blunders for different phase of the game , or a single unified graph with different types errors to have a clear image where are The biggest holes in the game. 

1

u/chrismantis 4d ago

Long term, I'd like to make proper phone apps, but that'll be a long way off. I haven't tested on iOS on web, but i will do. I tested https://backgammondb.com/play quite extensively on Android and when you're in landscape and hit the full screen, the experience is really good - how does it work for you?

Re graphs/stats for errors - def an area i want to look into. right now bgdb's game phases are pretty "naive" - it is split into opening (the first few rolls pre contact), mid-game, end-game contact, race and bear-off, i think. A huge amount of the game is in that "mid-game" status - it's probably 70% of most games. So just having a graph of errors splitting these out might not be too useful... but i do have plans for dedicated sections showing your errors in the opening and errors in bear-off. Within mid-game, it might be useful breaking down errors my position type (holding, back game, prime vs prime etc)

2

u/crooktimber 1d ago

As with many of these new pop up backgammon bots, crying out for simple keyboard shortcuts. spacebar to roll/confirm; backspace to undo etc

1

u/chrismantis 1d ago edited 1d ago

good feedback, thanks.

Play does have some shortcuts. Right now, enter should confirm a move, but if space is more standard i can change it to that. Backspace should undo (as well as ctrl-z) - does it not work for you? D switches the active die.

I don't have a shortcut for roll-vs-double, that requires a click. I can add to it.

As an side, there's actually a lot of time spent on shortcuts throughout backgammondb - eg in match review you can control the whole review process through the keyboard, including star/tag/comment without taking your hands off the keyboard. But game play i've never used the keyboard before on other platforms, and play tested this mostly on the phone,.

Also, it's lacking a shortcut menu. when you're in review, pressing ? brings up all the shortcuts. I need to add that to the Play surface too.

(as an aside, backgammondb is v much not a pop up backgammon bot. been in development for a year, live for around 6 months, and this is the ~16th feature update in that time! i'm constantly integrating feedback from users. This will go on the list for sure)

2

u/crooktimber 1d ago

hey, thanks for replying. I couldn't see anything documented about keyboard shortcuts, spacebar is pretty standard for roll/confirm in my experience.

I didn't mean to insult your hard work by saying 'pop up', but you have to realise there has been a flurry of similar platforms in the last few weeks, and with such a glut of same-but-different options it's hard not to look at them through narrowed eyelids. it must feel unfair but from an end user pov, effort behind the scenes isn't part of the criteria.

2

u/chrismantis 1d ago

oh 100%, completely understand. just wanted to clarify :)

2

u/crooktimber 1d ago

just to add and explain: spacebar is superior to the enter key because it's right above the trackpad; users move their fingers not their entire hand.

2

u/chrismantis 1d ago

Give it a try now. I've just deployed a new version with full keyboard control

- spacebar or enter to roll the dice or submit a roll
- backspace, ctrl-z or 'u' to undo. alt-backspace or alt-u to undo all
- when facing roll or double, R is roll (or enter, or space) or D is double
- T and P for take and pass
- shift-R to resign, then arrow keys or letters to submit a resignation
- A now swaps the active die
- Various shortcuts during game end
- Experimental: You can also use arrow keys to move between checkers, then hit space/enter to move it.

so you should now be able to play an entire match on the keyboard only.

also, ? (or icon top right) brings up a new modal that shows all the shortcuts and also lists all the mouse actions.

Let me know how you get on.

1

u/Unable_Balance 1d ago

I look the look of it - very clean on the PC. I had trouble using it in a browser on android using a touch interface in analyze mode. How do you move checkers? (Sorry if I'm being slow!)

1

u/chrismantis 1d ago

Ahh yes - analyze just straight up doesn't work on phones right now! sorry about that. tbh none of the site was really designed for a phone until i launched the Play feature, then it became obvious of the deficiencies on phone displays. So i'm working through them one by one; Play now works well, and Quiz should work, but everything else is going to be pretty ropey and/or just straight up not work i'm afraid.

it's proving quite tricky to code in nice interfaces for a variety of phone sizes and work in portrait and landscape naturally. but i'm working on it! next up, the analyze screen.

1

u/chrismantis 1d ago

ok i've just pushed out a fix for this. In portrait (at least on my android phone), it works pretty well now; You can click/drag checkers; but that's a bit fiddly. so i've also added an 'add/remove' toggle. when in 'remove' mode, click a checker to put it in the checker tray. then in 'add' mode, you distribute checkers from the tray onto the board wherever you click. (you can also do this by selecting the checker trays of either color)

. I've also improved the layout so it makes better use of vertical space - it fits in the move cards and you can see more candidate moves. Let me know how you get on.

1

u/crooktimber 1d ago

Pretty, pretty good! Nice work. My favourite feature is 'delete match from library' :)

1

u/bubba_bath 3d ago

Nice work! I have been playing with it for an hour or so. One thing I noticed is that, if on the bar, it will say "cannot move" while the dice animation is still ongoing. I'm struggling a bit with getting it to detect a tap on some of the corner points, maybe just I have fat fingers. But overall, I quite like it. Appreciate the waterfowl logo too.

1

u/chrismantis 1d ago

Regarding taps on corner points - i pushed a change up yesterday that means you can click anywhere on a point to move the top checker (before, you had to hit the checker, and clicking on a point meant "move two checkers to this point") - this might help

I haven't experience the "cannot move" but i'll check it out. if you click when the animation is going it should immediately end the animation and a second click should make the move, but maybe there's something funky going on when you're on the bar

1

u/bubba_bath 1d ago

Thanks, works more good for me on mobile now. FYI, I also had a Claude project that I created to create descriptive explanations for positions tap into the WASM for Grebe, and that's working great too.

3

u/Maxogen05 4d ago

Intresting will check out

2

u/techcheckers 3d ago

Playes a 5 point match - grebe is good, very quick and id’d the blunders well, add to the list : )