Draft
Placing Robots
15ollyfg
Description:
You are making a simple game where there is a 10x10 map, with the player starting at (5,5). You want a function to place a certain number of robots that the player will have to escape from. This function will take the map (a 10x10 array) and the number of robots to add. It should return the map with the number of robots added to it in random locations. Remember you can't place robots on top of each other (or the player)!
If there isn't enough space, the map should be returned with as many spaces filled as possible.
On the map: "." = empty space "P" = player "r" = robot
So the input map will be:
var map = [
[".",".",".",".",".",".",".",".",".",".",],
[".",".",".",".",".",".",".",".",".",".",],
[".",".",".",".",".",".",".",".",".",".",],
[".",".",".",".",".",".",".",".",".",".",],
[".",".",".",".",".",".",".",".",".",".",],
[".",".",".",".",".","p",".",".",".",".",],
[".",".",".",".",".",".",".",".",".",".",],
[".",".",".",".",".",".",".",".",".",".",],
[".",".",".",".",".",".",".",".",".",".",],
[".",".",".",".",".",".",".",".",".",".",],
];
And an example output map for place_robots(map,10) could be:
[
[".",".","r",".",".",".",".",".",".",".",],
["r",".",".",".",".","r",".","r",".",".",],
[".",".",".",".",".",".",".",".",".",".",],
[".",".",".",".",".",".",".",".",".",".",],
[".",".",".","r",".",".",".","r",".",".",],
["r",".",".",".",".","p",".",".",".",".",],
[".",".",".",".",".",".",".",".",".",".",],
[".",".",".",".",".",".",".",".",".",".",],
["r",".",".","r",".",".",".","r",".",".",],
[".",".",".",".",".",".",".",".",".",".",],
];
Games
Arrays
Similar Kata:
Stats:
Created | Jun 28, 2014 |
Warriors Trained | 33 |
Total Skips | 2 |
Total Code Submissions | 220 |
Total Times Completed | 15 |
JavaScript Completions | 15 |
Total Stars | 0 |
% of votes with a positive feedback rating | 0% of 0 |
Total "Very Satisfied" Votes | 7 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 2 |