I'm doing some Neuroevolution simulations to teach R to play a simple snake game.
I have a game board as a 10x10 matrix filled with integers from 0 to 2. 0 being empty, 1 the player and 2 is the reward ("apple").
Currently i'm drawing the game by simply using the image-function. Which gives me kind of a boring view of the board. Since I later need to present the results that I'm getting, i'd like to know if there are cooler ways to do this.
Is there a way to plot this matrix so that every 1 would be converted into a image (like pacman or something) and every two would convert into a apple? Using ggplot2 or any similar packages is an option.
Small example of what I'm currently using:
#Initialize empty board
gameBoard <- matrix(0, nrow=10, ncol=10)
#Randomly select 20 spots for apples and assign 2 to those spots
appleSpots <- sample(10*10, 20)
gameBoard[appleSpots] <- 2
#Put player in the middle of the board
gameBoard[5,5] <- 1
#Plot the board
image(gameBoard)