Skip to content

Commit

Permalink
doc: update example
Browse files Browse the repository at this point in the history
  • Loading branch information
loks0n committed Feb 3, 2023
1 parent 08643e4 commit a481db3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# rapid-draughts ⚡

**rapid-draughts** is a *super speedy, blazing fast, rocket-powered* 8x8 board TypeScript draughts/checkers engine.
**rapid-draughts** is a *super speedy, blazing fast, rocket-powered* TypeScript draughts/checkers engine.

It uses bitboards, a board representation that holds the draughts board in three 32 bit unsigned integers. One for the light pieces, dark pieces and the king pieces.
It uses bitboards, a board representation that holds the draughts board in three 32 or 64 bit unsigned integers. One for the light pieces, dark pieces and the king pieces.

Bitboards enable fast move generation and have minimal memory usage.

Expand All @@ -21,19 +21,20 @@ const moves = draughts.moves();
draughts.move(moves[0]);

// Initialise two AIs
const weakAI = EnglishDraughts.AI.alphaBeta({ maxDepth: 4, quiescence: false });
const strongAI = EnglishDraughts.AI.alphaBeta({ maxDepth: 6 });
const weakAI = EnglishDraughts.AI.random();
const strongAI = EnglishDraughts.AI.alphaBeta({ maxDepth: 7 });

// Play with the AIs until there is a winner
while (draughts.status() === Status.PLAYING) {
console.log(draughts.toString());
console.log(`${draughts.toString()}`);
console.log(`to_move = ${draughts.player()}`);
const move =
draughts.player() === Player.LIGHT ? weakAI(engine) : strongAI(engine);
if (move) engine.move(move);
}

// Announce the winner
console.log(draughts.toString());
console.log(`result = ${draughts.status()}`);
console.log(`${draughts.toString()}`);
console.log(`status = ${draughts.status()}`);

```
11 changes: 6 additions & 5 deletions examples/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ const moves = draughts.moves();
draughts.move(moves[0]);

// Initialise two AIs
const weakAI = EnglishDraughts.AI.alphaBeta({ maxDepth: 4, quiescence: false });
const strongAI = EnglishDraughts.AI.alphaBeta({ maxDepth: 6 });
const weakAI = EnglishDraughts.AI.random();
const strongAI = EnglishDraughts.AI.alphaBeta({ maxDepth: 7 });

// Play with the AIs until there is a winner
while (draughts.status() === Status.PLAYING) {
console.log(draughts.toString());
console.log(`${draughts.toString()}`);
console.log(`to_move = ${draughts.player()}`);
const move =
draughts.player() === Player.LIGHT ? weakAI(engine) : strongAI(engine);
if (move) engine.move(move);
}

// Announce the winner
console.log(draughts.toString());
console.log(`result = ${draughts.status()}`);
console.log(`${draughts.toString()}`);
console.log(`status = ${draughts.status()}`);

0 comments on commit a481db3

Please sign in to comment.