ttt_ai: Tic-Tac-Toe AI Player

Description Usage Arguments Details Value Examples

View source: R/ttt_ai.R

Description

Create an AI tic-tac-toe game player

Usage

1
2
3
ttt_ai(name = "ttt AI", level = 0L)

ttt_random(name = "random AI")

Arguments

name

player name

level

AI strength. must be Integer 0 (weekest) to 5 (strongest)

Details

level argument controls the strength of AI, from 0 (weekest) to 5 (strongest). ttt_random is an alias of ttt_ai(level = 0).

A ttt_ai object has the getmove function, which takes ttt_game object and returns a move considered as optimal. getmove function is designed to take a ttt_game object and returns a move using the policy function.

The object has the value and policy functions. The value function maps a game state to the evaluation from the first player's viewpoint. The policy function maps a game state to a set of optimal moves in light of the value evaluation. The functions have been trained through the Q-learning.

Value

ttt_ai object

Fields

name

Player name

level

Strength (0 to 5)

policy_func

xhash object that maps a game state to moves

value_func

xhash object that maps a game state to a value

Methods

getmove(game, ...)

Returns a move considered as optimal.

Input:

  • game: ttt_game object

Output: a move

Examples

1
2
3
game <- ttt_game()
p <- ttt_ai(level=3)
p$getmove(game)

kota7/tictactoe documentation built on Jan. 21, 2018, 3:07 a.m.