├── .jshintrc
├── vendor
└── twitter-bootstrap
│ ├── img
│ ├── glyphicons-halflings.png
│ └── glyphicons-halflings-white.png
│ ├── css
│ ├── bootstrap-responsive.min.css
│ └── bootstrap-responsive.css
│ └── js
│ ├── bootstrap.min.js
│ └── bootstrap.js
├── README.md
├── random-ai.js
├── nginx.conf
├── count-ai.js
├── online-game-list.html
├── online.css
├── online.html
├── app.css
├── online-game-detail.html
├── index.html
├── app.js
├── online.js
└── othello.js
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "bitwise": false,
3 | "curly": false
4 | }
5 |
--------------------------------------------------------------------------------
/vendor/twitter-bootstrap/img/glyphicons-halflings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kana/othello-js/HEAD/vendor/twitter-bootstrap/img/glyphicons-halflings.png
--------------------------------------------------------------------------------
/vendor/twitter-bootstrap/img/glyphicons-halflings-white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kana/othello-js/HEAD/vendor/twitter-bootstrap/img/glyphicons-halflings-white.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Othello JS
2 |
3 | A quick and dirty implementation of [Othello (Reversi)](http://en.wikipedia.org/wiki/Reversi).
4 | [Try it online](https://kana.github.io/othello-js/).
5 |
--------------------------------------------------------------------------------
/random-ai.js:
--------------------------------------------------------------------------------
1 | othello.registerAI({
2 | findTheBestMove: function (gameTree) {
3 | return gameTree.moves[Math.floor(Math.random() * gameTree.moves.length)];
4 | }
5 | });
6 | // vim: expandtab softtabstop=2 shiftwidth=2 foldmethod=marker
7 |
--------------------------------------------------------------------------------
/nginx.conf:
--------------------------------------------------------------------------------
1 | daemon off;
2 | worker_processes 1;
3 |
4 | events {
5 | worker_connections 1024;
6 | }
7 |
8 | http {
9 | include /usr/local/etc/nginx/mime.types;
10 | default_type application/octet-stream;
11 |
12 | server {
13 | listen 8080;
14 |
15 | location / {
16 | root .;
17 | autoindex on;
18 | }
19 | }
20 | }
21 |
22 | # vim: filetype=conf expandtab softtabstop=2 shiftwidth=2
23 |
--------------------------------------------------------------------------------
/count-ai.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | var O = othello;
3 |
4 | function sum(ns) {
5 | return ns.reduce(function (t, n) {return t + n;});
6 | }
7 |
8 | function scoreBoard(board, player) {
9 | var opponent = O.nextPlayer(player);
10 | return sum($.map(board, function (v) {return v == player;})) -
11 | sum($.map(board, function (v) {return v == opponent;}));
12 | }
13 |
14 | O.registerAI({
15 | findTheBestMove: function (gameTree) {
16 | var scores =
17 | gameTree.moves.map(function (m) {
18 | return scoreBoard(O.force(m.gameTreePromise).board, gameTree.player);
19 | });
20 | var maxScore = Math.max.apply(null, scores);
21 | return gameTree.moves[scores.indexOf(maxScore)]
22 | }
23 | });
24 | })();
25 | // vim: expandtab softtabstop=2 shiftwidth=2 foldmethod=marker
26 |
--------------------------------------------------------------------------------
/online-game-list.html:
--------------------------------------------------------------------------------
1 |
26 |
27 |
Current player: -
28 |
29 |
30 |
31 |
32 |
33 |
54 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/app.js:
--------------------------------------------------------------------------------
1 | (function (O) {
2 | 'use strict';
3 |
4 | // UI {{{1
5 |
6 | function drawGameBoard(board, player, moves) {
7 | var ss = [];
8 | var attackable = [];
9 | moves.forEach(function (m) {
10 | if (!m.isPassingMove)
11 | attackable[O.ix(m.x, m.y)] = true;
12 | });
13 |
14 | ss.push('