1657704141

Simple Monte Carlo algorithm to determine dead stones on a Go board.

Use npm to install:

```
$ npm install @sabaki/deadstones
```

To use this module, require it as follows:

```
const deadstones = require('@sabaki/deadstones')
```

This module supports fetching the WASM file via `fetch`

on the web if no node environment is found. Use a bundler like webpack and call the following method right after `import`

or `require`

:

```
deadstones.useFetch('./path/to/deadstones_bg.wasm')
```

Make sure you have the Rust toolchain installed via `rustup`

. This project uses the native WASM target which you can acquire with:

```
$ rustup target add wasm32-unknown-unknown
```

Make sure you have `wasm-pack`

, Node.js 8 or higher, and npm installed. Clone this repository and install its dependencies with npm:

```
$ git clone https://github.com/SabakiHQ/deadstones
$ cd deadstones
$ npm install
```

To build WASM binaries and to start tests, use the following commands:

```
$ npm run build
$ npm test
```

The board arrangement is represented by an array of arrays. Each of those subarrays represent one row, all containing the same number of integers. `-1`

denotes a white stone, `1`

a black stone, and `0`

represents an empty vertex

```
[[ 0, 0, 1, 0, -1, -1, 1, 0, 0],
[ 1, 0, 1, -1, -1, 1, 1, 1, 0],
[ 0, 0, 1, -1, 0, 1, -1, -1, 0],
[ 1, 1, 1, -1, -1, -1, 1, -1, 0],
[ 1, -1, 1, 1, -1, 1, 1, 1, 0],
[-1, -1, -1, -1, -1, 1, 0, 0, 0],
[ 0, -1, -1, 0, -1, 1, 1, 1, 1],
[ 0, 0, 0, 0, 0, -1, -1, -1, 1],
[ 0, 0, 0, 0, 0, 0, 0, -1, 0]]
```

Board positions are represented by an array of the form `[x, y]`

where `x`

and `y`

are non-negative integers, zero-based coordinates of the vertex. `[0, 0]`

denotes the top left position of the board.

This module exposes four functions:

`async deadstones.guess(data[, options])`

`data`

- Board data`options`

`<Object>`

*(optional)*

`finished`

`<boolean>`

*(optional)* - Default: `false`

If set `true`

, deadstones will assume that player areas have been completely surrounded, yielding better results.

`iterations`

`<integer>`

*(optional)* - Default: `100`

The number of random playthroughs to make.

Returns an array of vertices that Sabaki thinks are dead.

`async deadstones.getProbabilityMap(data, iterations)`

`data`

- Board data`iterations`

`<integer>`

- The number of random playthroughs to make.

Returns an array of arrays of the same size as `data`

. Each entry is a number between `-1`

and `1`

and corresponds to a vertex. A number closer to `-1`

is more likely controlled by white and a number closer to `1`

is more likely controlled by black.

`async deadstones.playTillEnd(data, sign)`

`data`

- Board data`sign`

`-1`

|`1`

- White player corresponds to`-1`

, black player is represented by`1`

.

Makes random alternating moves, starting with the player determined by sign, until only eye filling moves can be made. Then all eyes that are left will be filled with the corresponding color. This final board arrangement data will be returned.

`async deadstones.getFloatingStones(data)`

`data`

- Board data

A fast function that returns an array of vertices of stones that are inside enemy territory and do not surround more than one point of territory themselves.

Author: SabakiHQ

Source Code: https://github.com/SabakiHQ/deadstones

License: MIT license

#rust #javascript #go #game #strategy

1657704141

Simple Monte Carlo algorithm to determine dead stones on a Go board.

Use npm to install:

```
$ npm install @sabaki/deadstones
```

To use this module, require it as follows:

```
const deadstones = require('@sabaki/deadstones')
```

This module supports fetching the WASM file via `fetch`

on the web if no node environment is found. Use a bundler like webpack and call the following method right after `import`

or `require`

:

```
deadstones.useFetch('./path/to/deadstones_bg.wasm')
```

Make sure you have the Rust toolchain installed via `rustup`

. This project uses the native WASM target which you can acquire with:

```
$ rustup target add wasm32-unknown-unknown
```

Make sure you have `wasm-pack`

, Node.js 8 or higher, and npm installed. Clone this repository and install its dependencies with npm:

```
$ git clone https://github.com/SabakiHQ/deadstones
$ cd deadstones
$ npm install
```

To build WASM binaries and to start tests, use the following commands:

```
$ npm run build
$ npm test
```

The board arrangement is represented by an array of arrays. Each of those subarrays represent one row, all containing the same number of integers. `-1`

denotes a white stone, `1`

a black stone, and `0`

represents an empty vertex

```
[[ 0, 0, 1, 0, -1, -1, 1, 0, 0],
[ 1, 0, 1, -1, -1, 1, 1, 1, 0],
[ 0, 0, 1, -1, 0, 1, -1, -1, 0],
[ 1, 1, 1, -1, -1, -1, 1, -1, 0],
[ 1, -1, 1, 1, -1, 1, 1, 1, 0],
[-1, -1, -1, -1, -1, 1, 0, 0, 0],
[ 0, -1, -1, 0, -1, 1, 1, 1, 1],
[ 0, 0, 0, 0, 0, -1, -1, -1, 1],
[ 0, 0, 0, 0, 0, 0, 0, -1, 0]]
```

Board positions are represented by an array of the form `[x, y]`

where `x`

and `y`

are non-negative integers, zero-based coordinates of the vertex. `[0, 0]`

denotes the top left position of the board.

This module exposes four functions:

`async deadstones.guess(data[, options])`

`data`

- Board data`options`

`<Object>`

*(optional)*

`finished`

`<boolean>`

*(optional)* - Default: `false`

If set `true`

, deadstones will assume that player areas have been completely surrounded, yielding better results.

`iterations`

`<integer>`

*(optional)* - Default: `100`

The number of random playthroughs to make.

Returns an array of vertices that Sabaki thinks are dead.

`async deadstones.getProbabilityMap(data, iterations)`

`data`

- Board data`iterations`

`<integer>`

- The number of random playthroughs to make.

Returns an array of arrays of the same size as `data`

. Each entry is a number between `-1`

and `1`

and corresponds to a vertex. A number closer to `-1`

is more likely controlled by white and a number closer to `1`

is more likely controlled by black.

`async deadstones.playTillEnd(data, sign)`

`data`

- Board data`sign`

`-1`

|`1`

- White player corresponds to`-1`

, black player is represented by`1`

.

Makes random alternating moves, starting with the player determined by sign, until only eye filling moves can be made. Then all eyes that are left will be filled with the corresponding color. This final board arrangement data will be returned.

`async deadstones.getFloatingStones(data)`

`data`

- Board data

A fast function that returns an array of vertices of stones that are inside enemy territory and do not surround more than one point of territory themselves.

Author: SabakiHQ

Source Code: https://github.com/SabakiHQ/deadstones

License: MIT license

1599854400

Go announced Go 1.15 version on 11 Aug 2020. Highlighted updates and features include Substantial improvements to the Go linker, Improved allocation for small objects at high core counts, X.509 CommonName deprecation, GOPROXY supports skipping proxies that return errors, New embedded tzdata package, Several Core Library improvements and more.

As Go promise for maintaining backward compatibility. After upgrading to the latest Go 1.15 version, almost all existing Golang applications or programs continue to compile and run as older Golang version.

#go #golang #go 1.15 #go features #go improvement #go package #go new features

1602133570

https://www.mobiwebtech.com/why-you-should-design-your-own-board-game-app/

The dice, decks and game board are built with pixel art and you can design any game imaginable with your creativity. You can design a brand-new board game app or innovate your favourite game. You can design crazy games or role-playing maps with your art. You can play it online with your family and friends in your private game room in real-time.

#board game app development #board game app development company #board game app developers #board game app development services #board game app development usa #board game website development

1593864360

Reinforcement learning has gained tremendous popularity in the last decade with a series of successful real-world applications in robotics, games and many other fields.

In this article, I will provide a high-level structural overview of classic reinforcement learning algorithms. The discussion will be based on their similarities and differences in the intricacies of algorithms.

Let’s start with a quick refresher on some basic concepts. If you are already familiar with all the terms of RL, feel free to skip this section.

Reinforcement learning models are a type of state-based models that utilize the markov decision process(MDP). The basic elements of RL include:

**Episode(rollout)**: playing out the whole sequence of state and action until reaching the terminate state;

**Current state s (or s_t_)**: where the agent is current at;

**Next state s’ (or s_t+1_)**: next state from the current state;

**Action a**: the action to take at state s;

**Transition probability P(s’|s, a)**: the probability of reaching s’ if taking action at at state s_t_;

**Policy π(s, a)**: a mapping from each state to an action that determines how the agent acts at each state. It can be either deterministic or stochastic

**Reward r (or R(s, a))**: a reward function that generates rewards for taking action a at state s;

**Return G_t_**: total future rewards at state s_t;_

**Value V(s)**: expected return for starting from state s;

**Q value Q(s, a)**: expected return for starting from state s and taking action a;

**Bellman equation**

According to the Bellman equation, the current value is equal to current reward plus the discounted(γ) value at the next step, following the policy **π**. It can also be expressed using the Q value as:

This is the theoretical core in most reinforcement learning algorithms.

There are two fundamental tasks of reinforcement learning: prediction and control.

In prediction tasks, we are given a policy and our goal is to evaluate it by estimating the value or Q value of taking actions following this policy.

In control tasks, we don’t know the policy, and the goal is to find the optimal policy that allows us to collect most rewards. In this article, we will only focus on control problems.

Below is a graph I made to visualize the high-level structure of different types of algorithms. In the next few sections, we will delve into the intricacies of each type.

In the MDP world, we have a mental model of how the world works, meaning that we know the MDP dynamics (transition P(s’|s,a) and reward function R(s, a)), so we can directly build a model using the Bellman equation.

Again, in control tasks our goal is to find a policy that gives us maximum rewards. To achieve it, we use dynamic programming.

**1. Policy Iteration**

Policy iteration essentially performs two steps repeatedly until convergence: policy evaluation and policy improvement.

In the policy evaluation step, we evaluate the policy **π **at state **s** by calculating the Q value using the Bellman equation:

In the policy improvement step, we update the policy by greedily searching for the action that maximizes the Q value at each step.

Let’s see how policy iteration works.

**2. Value Iteration**

Value iteration combines the two steps in policy iteration so we only need to update the Q value. We can interpret value iteration as always following a greedy policy because at each step it always tries to find and take the action that maximizes the value. Once the values converge, the optimal policy can be extracted from the value function.

In most real-world scenarios, we don’t know the MDP dynamics so the applications of iterative methods are limited. In the next section, we will switch gears and discuss reinforcement learning methods that can deal with the unknown world.

#monte-carlo #deep-q-learning #algorithms #algorithms

1593347004

The Greedy Method is an approach for solving certain types of optimization problems. The greedy algorithm chooses the optimum result at each stage. While this works the majority of the times, there are numerous examples where the greedy approach is not the correct approach. For example, let’s say that you’re taking the greedy algorithm approach to earning money at a certain point in your life. You graduate high school and have two options:

#computer-science #algorithms #developer #programming #greedy-algorithms #algorithms