Learn R Programming

fourinarow (version 0.1.1)

invertPieces: Switch X's and O's

Description

Convenience function called internally by play4inaRow that switches the player symbols, so that each player sees their own pieces as "X" and their opponents' as "O".

Usage

invertPieces(game)

Value

Returns the game matrix with "X" and "O"

symbols switched.

Arguments

game

A 6x7 matrix object representing the current game board.

Examples

Run this code
game <- matrix(sample(c('X','O','.'), 6*7, replace=TRUE), nrow = 6, ncol = 7)
game
invertPieces(game)

Run the code above in your browser using DataLab