Function battleship_bot::place_boat

source ·
pub fn place_boat(boats: &mut BoatMap, boat: Boat, horizontal: bool, pos: Pos)
Expand description

Places a boat in boats

Places a boat in boats, either horizontally or not at pos.

Example

use battleship_bot::*;
 
let mut boats = [[Boat::Empty; 10]; 10];
 
place_boat(&mut boats, Boat::Destroyer, true, pos!(0, 0));
 
assert!(boats[0][0] == Boat::Destroyer);
assert!(boats[1][0] == Boat::Destroyer);
 
let mut boats = [[Boat::Empty; 10]; 10];
 
place_boat(&mut boats, Boat::Destroyer, false, pos!(0, 0));
 
assert!(boats[0][0] == Boat::Destroyer);
assert!(boats[0][1] == Boat::Destroyer);