Build Othello (Reversi) against the computer. Use /othello play to start as Black, /othello place with a square such as d3 to move, and /othello help to explain the rules, coordinates and commands to a complete beginner. The computer plays White and answers automatically using mee6.search, favouring corners, edges and mobility; easy/medium/hard sets its thinking budget. Follow the standard rules: bracket opposing discs to flip them, reject illegal moves without changing the game, pass automatically when one side cannot move, and announce the winner and both disc counts when neither side can move. Show the whole 8x8 board as one picture, updated in place: alternating rich green squares, readable A-H and 1-8 labels in the margins, beautiful glossy black and ivory-white round disc sprites generated with the image model, and a subtle highlight for the last move. The status must clearly say whose turn it is and show the score. Make it ready to play on any server, with a useful recorded demo showing real legal moves.
Play Othello (also called Reversi) against a strategic computer opponent!
How to Play:
• /othello play [difficulty] — Start a new game as Black (easy/medium/hard)
• /othello place <square> — Place your disc (e.g., d3, e6)
• /othello help — Learn the rules and strategy
You play Black ⚫, the computer plays White ⚪. Bracket opponent discs to flip them to your color. The game shows an 8×8 board with rich green squares, glossy disc pieces, and highlights for the last move. The AI uses strategic evaluation favoring corners, edges, and mobility.
The board is updated in place after each move, with clear disc counts and turn indicators.
Made by MEE6. Remix it to get a copy of your own and change anything you like.
Black ⚫'s turn Black: 7 • White: 9

Placed Black disc at d3. White played: c3.
Placed Black disc at f5. White played: e3.
Placed Black disc at d2. White played: c1.
Placed Black disc at b3. White played: a3.
Placed Black disc at d1. White played: e1.
Placed Black disc at f3. White played: f4.
/** Othello (Reversi) game state */
type Board = number[][]; // 8x8: 0 = empty, 1 = Black (player), 2 = White (computer)
interface Game {
board: Board;
turn: number; // 1 or 2
lastMove: [number, number] | null;
messageId: string;
channelId: string;
playerId: string;
difficulty: 'easy' | 'medium' | 'hard';
}
// Difficulty → how many moves ahead the computer looks. Depth, not time: the same
// position then gets the same answer on a fast machine and on a slow one — as
// long as the depth fits in the time below on the slowest machine, which is
// why medium is 4 (about 0.3 s a move here, 5 would be up to 1 s).
const THINK_DEPTH = { easy: 2, medium: 4, hard: 7 };
// …and the longest it may take over it, in milliseconds, whatever the depth
const THINK_TIME = { easy: 1000, medium: 2000, hard: 3000 };
const DIRECTIONS = [
[-1, -1],
[-1, 0],
[-1, 1],
[0, -1],
[0, 1],
[1, -1],
[1, 0],
[1, 1],
];
/** Create initial Othello board */
function initialBoard(): Board {
const b: Board = Array.from({ length: 8 }, () => Array(8).fill(0));
b[3][3] = 2;
b[3][4] = 1;
b[4][3] = 1;
b[4][4] = 2;
return b;
}
/** Parse move like "d3" → [row, col] or null */
function parseMove(text: string): [number, number] | null {
const m = text
.trim()
.toLowerCase()
.match(/^([a-h])([1-8])$/);
if (!m) return null;
const col = m[1].charCodeAt(0) - 'a'.charCodeAt(0);
const row = parseInt(m[2]) - 1;
return [row, col];
}
/** Format [row, col] → "d3" */
function formatMove(r: number, c: number): string {
return `${'abcdefgh'[c]}${r + 1}`;
}
/** Check if (r, c) is on the board */
function inBounds(r: number, c: number): boolean {
return r >= 0 && r < 8 && c >= 0 && c < 8;
}
/** Find all flips if `who` plays at (r, c), return flipped positions */
function getFlips(b: Board, r: number, c: number, who: number): [number, number][] {
if (b[r][c] !== 0) return [];
const opponent = who === 1 ? 2 : 1;
const flips: [number, number][] = [];
for (const [dr, dc] of DIRECTIONS) {
const line: [number, number][] = [];
let rr = r + dr,
cc = c + dc;
// Collect opponent discs in this direction
while (inBounds(rr, cc) && b[rr][cc] === opponent) {
line.push([rr, cc]);
rr += dr;
cc += dc;
}
// Valid if line ends with our disc
if (line.length > 0 && inBounds(rr, cc) && b[rr][cc] === who) {
flips.push(...line);
}
}
return flips;
}
/** Get all legal moves for `who` */
function legalMoves(b: Board, who: number): [number, number][] {
const moves: [number, number][] = [];
for (let r = 0; r < 8; r++) {
for (let c = 0; c < 8; c++) {
if (getFlips(b, r, c, who).length > 0) {
moves.push([r, c]);
}
}
}
return moves;
}
/** Apply a move, flipping discs (mutates board) */
function applyMove(b: Board, r: number, c: number, who: number): void {
const flips = getFlips(b, r, c, who);
if (flips.length === 0) return;
b[r][c] = who;
for (const [fr, fc] of flips) {
b[fr][fc] = who;
}
}
/** Count discs: [black, white] */
function countDiscs(b: Board): [number, number] {
let black = 0,
white = 0;
for (const row of b) {
for (const cell of row) {
if (cell === 1) black++;
else if (cell === 2) white++;
}
}
return [black, white];
}
/** Check if game is over (no legal moves for either side) */
function gameOver(b: Board): boolean {
return legalMoves(b, 1).length === 0 && legalMoves(b, 2).length === 0;
}
/** Evaluate board for `who`: corners are best, edges good, mobility matters */
function evaluate(b: Board, who: number): number {
const opponent = who === 1 ? 2 : 1;
let score = 0;
// Corner control: corners are very valuable
const corners = [
[0, 0],
[0, 7],
[7, 0],
[7, 7],
];
for (const [r, c] of corners) {
if (b[r][c] === who) score += 25;
else if (b[r][c] === opponent) score -= 25;
}
// Edge control: edges are good but less than corners
for (let i = 0; i < 8; i++) {
if (b[0][i] === who) score += 5;
else if (b[0][i] === opponent) score -= 5;
if (b[7][i] === who) score += 5;
else if (b[7][i] === opponent) score -= 5;
if (b[i][0] === who) score += 5;
else if (b[i][0] === opponent) score -= 5;
if (b[i][7] === who) score += 5;
else if (b[i][7] === opponent) score -= 5;
}
// Mobility: more legal moves is better
const myMoves = legalMoves(b, who).length;
const oppMoves = legalMoves(b, opponent).length;
score += (myMoves - oppMoves) * 2;
// Disc count (minor factor)
const [black, white] = countDiscs(b);
if (who === 1) score += black - white;
else score += white - black;
return score;
}
/** AI: use mee6.search to find best move with given time budget */
function computerMove(game: Game, timeBudget: number): [number, number] | null {
const b = game.board;
const who = 2; // computer is White
const moves = (state: Board, player: number) => legalMoves(state, player);
const apply = (state: Board, move: [number, number], player: number): Board => {
const next = state.map((row) => row.slice());
applyMove(next, move[0], move[1], player);
return next;
};
const winner = (state: Board): number | 'draw' | null => {
if (!gameOver(state)) return null;
const [black, white] = countDiscs(state);
if (black > white) return 1;
if (white > black) return 2;
return 'draw';
};
const result = mee6.search({
state: b,
player: 2,
opponent: 1,
moves,
apply,
evaluate,
winner,
depth: THINK_DEPTH[game.difficulty],
timeMs: timeBudget,
});
return result.move ?? null;
}
/** Render the board as an image */
async function drawBoard(game: Game): Promise<string> {
const cells: string[][] = Array.from({ length: 8 }, () => Array(8).fill(''));
for (let r = 0; r < 8; r++) {
for (let c = 0; c < 8; c++) {
if (game.board[r][c] === 1) cells[r][c] = 'disc_black';
else if (game.board[r][c] === 2) cells[r][c] = 'disc_white';
}
}
return await mee6.board({
cells,
cell: 56,
light: '#4A9B5A',
dark: '#3A7B4A',
highlight: game.lastMove ? [game.lastMove] : [],
labels: {
top: 'ABCDEFGH',
bottom: 'ABCDEFGH',
left: '12345678',
right: '12345678',
},
});
}
/** Status message: whose turn, disc counts */
function statusMessage(game: Game): string {
const [black, white] = countDiscs(game.board);
if (gameOver(game.board)) {
let result = '';
if (black > white) result = '**Black wins!** 🎉';
else if (white > black) result = '**White wins!** 🤖';
else result = '**Draw!** 🤝';
return `${result}\n**Black:** ${black} • **White:** ${white}\n\nGame over. Use \`/othello play\` to start again.`;
}
const turnName = game.turn === 1 ? '**Black** ⚫' : '**White** ⚪';
const canMove = legalMoves(game.board, game.turn).length > 0;
if (!canMove) {
return `${turnName} has no legal moves and must pass.\n**Black:** ${black} • **White:** ${white}`;
}
return `${turnName}'s turn\n**Black:** ${black} • **White:** ${white}`;
}
/** Start a new game */
mee6.command(
'othello play',
{
description: 'Start a new game of Othello as Black',
options: [
{
name: 'difficulty',
type: 'string',
description: 'AI difficulty',
choices: [
{ name: 'Easy', value: 'easy' },
{ name: 'Medium', value: 'medium' },
{ name: 'Hard', value: 'hard' },
],
},
],
},
async (ctx) => {
const difficulty = (ctx.option<string>('difficulty') || 'medium') as 'easy' | 'medium' | 'hard';
// Mark any previous game in this slot as replaced
const oldGame = await mee6.store.get<Game>(`game_${ctx.channelId}_${ctx.author.id}`);
if (oldGame && oldGame.messageId) {
await mee6
.editMessage(oldGame.channelId, oldGame.messageId, {
content: '~~This game was replaced by a new one.~~',
})
.catch(() => {}); // ignore if message was deleted
}
const game: Game = {
board: initialBoard(),
turn: 1, // Black starts
lastMove: null,
messageId: '',
channelId: ctx.channelId,
playerId: ctx.author.id,
difficulty,
};
const url = await drawBoard(game);
const sent = await ctx.reply({
content: statusMessage(game),
embed: { image_url: url, color: 0x4a9d5f },
});
game.messageId = sent.messageId;
await mee6.store.set(`game_${ctx.channelId}_${ctx.author.id}`, game, { ttl: 3600 });
}
);
/** Place a disc */
mee6.command(
'othello place',
{
description: 'Place your disc at a square (e.g., d3)',
options: [{ name: 'square', type: 'string', description: 'Square like d3', required: true }],
ephemeral: true,
},
async (ctx) => {
const game = await mee6.store.get<Game>(`game_${ctx.channelId}_${ctx.author.id}`);
if (!game) {
await ctx.reply('No active game. Use `/othello play` to start.');
return;
}
if (game.playerId !== ctx.author.id) {
await ctx.reply('This is not your game.');
return;
}
if (gameOver(game.board)) {
await ctx.reply('The game is over. Use `/othello play` to start again.');
return;
}
if (game.turn !== 1) {
await ctx.reply("It's White's turn (the computer is thinking).");
return;
}
const square = ctx.option<string>('square');
const move = parseMove(square);
if (!move) {
await ctx.reply(`"${square}" is not a valid square. Use format like d3, e6, etc.`);
return;
}
const [r, c] = move;
const flips = getFlips(game.board, r, c, 1);
if (flips.length === 0) {
await ctx.reply(`${formatMove(r, c)} is not a legal move. You must flip at least one white disc.`);
return;
}
// Apply player's move
applyMove(game.board, r, c, 1);
game.lastMove = [r, c];
let response = `Placed Black disc at ${formatMove(r, c)}.`;
const moves: string[] = [];
// Check if game is over after Black's move
if (gameOver(game.board)) {
game.turn = 1;
await ctx.reply(response);
const url = await drawBoard(game);
await mee6.editMessage(game.channelId, game.messageId, {
content: statusMessage(game),
embed: { image_url: url, color: 0x4a9d5f },
});
await mee6.store.delete(`game_${ctx.channelId}_${ctx.author.id}`);
return;
}
// Keep playing White's turns while Black must pass, using one shared thinking budget
const totalBudget = THINK_TIME[game.difficulty];
const deadline = Date.now() + totalBudget;
while (!gameOver(game.board)) {
// Check if White can move
if (legalMoves(game.board, 2).length === 0) {
// White must pass
moves.push('(White passes)');
// Check if Black can move after White passes
if (legalMoves(game.board, 1).length > 0) {
game.turn = 1;
break;
}
// Both pass: game over
break;
}
// White can move - calculate remaining budget
const now = Date.now();
const remaining = deadline - now;
let compMove: [number, number] | null;
if (remaining > 0) {
// Use search with remaining budget
compMove = computerMove(game, remaining);
} else {
// Budget exhausted: pick first legal move
const whiteMoves = legalMoves(game.board, 2);
compMove = whiteMoves.length > 0 ? whiteMoves[0] : null;
}
if (!compMove) break;
const [cr, cc] = compMove;
applyMove(game.board, cr, cc, 2);
game.lastMove = [cr, cc];
moves.push(formatMove(cr, cc));
// Check if game is over
if (gameOver(game.board)) {
game.turn = 1;
break;
}
// Check if Black can move
if (legalMoves(game.board, 1).length > 0) {
game.turn = 1;
break;
}
// Black must pass, White plays again
moves.push('(Black passes)');
}
if (moves.length > 0) {
response += ' White played: ' + moves.join(', ') + '.';
}
await ctx.reply(response);
const url = await drawBoard(game);
await mee6.editMessage(game.channelId, game.messageId, {
content: statusMessage(game),
embed: { image_url: url, color: 0x4a9d5f },
});
if (gameOver(game.board)) {
await mee6.store.delete(`game_${ctx.channelId}_${ctx.author.id}`);
} else {
await mee6.store.set(`game_${ctx.channelId}_${ctx.author.id}`, game, { ttl: 3600 });
}
}
);
/** Explain the game */
mee6.command(
'othello help',
{
description: 'Learn how to play Othello',
},
async (ctx) => {
await ctx.reply({
embed: {
title: '⚫ How to Play Othello ⚪',
description: `**Othello** (also called Reversi) is a strategy game for two players on an 8×8 board.
**Goal:** Have more discs than your opponent when neither player can move.
**How to Play:**
• You play **Black** ⚫, the computer plays **White** ⚪
• Black moves first
• On your turn, place a disc to **bracket** one or more opponent discs between your new disc and another disc you already have (horizontally, vertically, or diagonally)
• All bracketed opponent discs flip to your color
• If you can't make a legal move, you **pass** automatically
• The game ends when neither player can move
**Commands:**
• \`/othello play [difficulty]\` — Start a new game (easy/medium/hard)
• \`/othello place <square>\` — Place your disc (e.g., \`d3\`, \`e6\`)
• \`/othello help\` — Show this help
**Coordinates:**
Columns are **A–H** (left to right), rows are **1–8** (top to bottom).
Example: \`d3\` is column D, row 3.
**Strategy Tips:**
• **Corners** are very strong — they can't be flipped!
• **Edges** are good too
• Early disc count doesn't matter — it's all about the endgame
Good luck! 🎮`,
color: 0x4a9d5f,
},
});
}
);
The pictures this example ships with. Remix it to change them or add your own.
disc_blackdisc_white