generate_open_moves: Generate array which shows moves that Karel can and can't...

View source: R/set_up.R

generate_open_movesR Documentation

Generate array which shows moves that Karel can and can't make

Description

This function creates open_moves, a nx x ny x 4 array of TRUE/FALSE values indicating if Karel can move to each direction from a given position. For example, if Karel is in the bottom left corner, which is cell [1, 1], it can't go south or left, so we have both open_moves[1, 1, 3] and open_moves[1, 1, 4] set to FALSE. Depending on the existing walls it could move south or north, so open_moves[1, 1, 1] and open_moves[1, 1, 2] could be TRUE or FALSE.

Usage

generate_open_moves(nx, ny, hor_walls, ver_walls)

Arguments

nx

ny size of the world

hor_walls

ver_walls dataset of horizontal and vertical walls as described in the details for the function .generate_world.

Details

Taking into account the size of the world and the walls, this function properly defines the array open_moves.

Value

A 6nx x ny x 4 array of TRUE/FALSE values


mpru/karel documentation built on May 12, 2024, 5:16 p.m.