-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from pilksoc/backend
Add local grid
- Loading branch information
Showing
6 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ pub mod space; | |
pub mod kube; | ||
pub mod player; | ||
pub mod llm; | ||
pub mod local_grid; | ||
|
||
type Coordinate = [u64; 2]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use crate::Coordinate; | ||
use crate::grid::Grid; | ||
use crate::space::Space; | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
pub struct LocalGrid { | ||
spaces: Vec<Space>, | ||
} | ||
impl LocalGrid { | ||
pub fn from_grid_and_coord(grid: &Grid, coordinate: Coordinate, local_size: u64) -> LocalGrid { | ||
let mut spaces: Vec<Space> = Vec::new(); | ||
for space in grid.get_neighbours_n_away(coordinate, local_size) { | ||
spaces.push(space.clone()) | ||
} | ||
LocalGrid { spaces } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters