Learn R Programming

fourinarow (version 0.1.1)

testBots: Simulate many games of Four in a Row

Description

This is a convenient way to test two bots against each other over a large number of games while ensuring that neither bot has an advantage from going first more often than the other.

Usage

testBots(playerOne, playerTwo, n = 100)

Value

Returns a vector of counts for the number of ties, wins by

playerOne, and wins by playerTwo.

Arguments

playerOne

A function that takes the current board as input and returns the next move (1-7) for Player 1.

playerTwo

Same for Player 2. Note that both functions see their pieces as "X" and opponent's pieces as "O".

n

Numerical value of how many games to simulate. Must be an even number, so that both bots get the same number of games with the first move (default = 100).

Examples

Run this code
testBots(easyBot, randomBot)

Run the code above in your browser using DataLab