Skip to content

Reversi Board with edax, which is the strongest reversi engine.

License

Notifications You must be signed in to change notification settings

sensuikan1973/pedax

Repository files navigation

screenshot_macos



pedax is Reversi Board GUI with edax, which is the strongest reversi program.

pedax has 4 features.
  • Mac/Windows/Linux are supported. You can install from Mac App Store or Microsoft Store.
  • Seamlessly, you can see evaluation value, e.g. +4, -10.
  • Customizable important options, e.g. book file path, search level, advanced indicator.
  • 2 languages (English, Japanese) are supported.


Development

Flutter CI codecov Flutter Build Flutter Deployment MacOS Deploy Website

Architecture

The technical point of pedax is as follows.

  • pedax needs to call Expensive Native(C) logic such as computing evaluation value.
  • Native(C) logic needs allocated huge data on memory. It's desirable to daemonize Native(C) process.

So, I have to use some isolates with ffi(libedax4dart) to achieve seamless non-blocking UI.

%% https://mermaid-js.github.io/mermaid/#/sequenceDiagram
sequenceDiagram
  actor User
  participant MainIsolate as Main Isolate
  participant EdaxServer as Edax Server
  participant EphemeralWorker as Ephemeral Worker
  participant EdaxProcess as Edax Process [C]

  link EdaxServer: source @ https://github.com/sensuikan1973/pedax/tree/main/lib/engine
  link EdaxServer: caller @ https://github.com/sensuikan1973/pedax/blob/main/lib/models/board_notifier.dart
  link EphemeralWorker: source @ https://github.com/sensuikan1973/pedax/tree/main/lib/engine
  link EdaxProcess: binding source (Dart) @ https://github.com/sensuikan1973/libedax4dart
  link EdaxProcess: origin source(C) @ https://github.com/sensuikan1973/edax-reversi/tree/libedax_sensuikan1973

  User ->> MainIsolate: launch pedax
  MainIsolate ->> EdaxServer: spawn and notify my SendPort
  EdaxServer ->> MainIsolate: notify my SendPort<br/>and start listening
  EdaxServer ->> EdaxProcess: initialize via ffi

  User ->> MainIsolate: action (e.g. tap)
  MainIsolate ->> EdaxServer: request EdaxCommand<br/>via SendPort

  alt light EdaxCommand
    EdaxServer ->> EdaxProcess: stop EdaxCommand being executed via ffi
    EdaxServer ->> EdaxProcess: execute requested EdaxCommand via ffi
    EdaxProcess ->> EdaxServer: return result
    EdaxServer ->> MainIsolate: notify result via SenPort
    MainIsolate ->> MainIsolate: update UI
  else heavy EdaxCommand
    note right of EdaxServer: spawn another isolate not to block EdaxServer.<br>Then, EdaxServer can accept other requests.
    EdaxServer ->>+ EphemeralWorker: spawn and notify Main Isolate SendPort
    EphemeralWorker ->> EdaxProcess: stop EdaxCommand being executed via ffi
    EphemeralWorker ->> EdaxProcess: execute requested EdaxCommand via ffi
    note over EdaxProcess: heavy...
    EdaxProcess ->> EphemeralWorker: return result
    EphemeralWorker ->>- MainIsolate: notify result via SenPort
    MainIsolate ->> MainIsolate: update UI
  end
Loading

important issues and PR

Run

./scripts/setup_flutter.sh
flutter run --device-id macos --dart-define "SENTRY_DSN=xxx" # env is optional