pswish‐dev‐diary - TheEvergreenStateCollege/upper-division-cs-23-24 GitHub Wiki
-
Week 1: Team prototype work, week1. We worked on transcribing the provided code then proceeded to refactor and trace down errors. Team leveraged current Rust knowledge to continue improving. Teammate G continued on their own after class
-
Week 2: Team prototype 11, team worked on implementing latest code changes from prototype 0, 111 was basically empty. Began factoring the win condition.
-
Week 4: Worked on trying to refactor the avenue and street function in the rust address problem. I ended the day with chasing a theory. see below week 6
-
Week 6: Worked on Addressor integration to my rust code, it complied but did not function, hung up on the printing of the grid. I might keep trying since i think this might be easier than trying to find the bug in the class code base. Regardless, this is the output:
-
Week7: https://github.com/TheEvergreenStateCollege/upper-division-cs/wiki/Pswish-week7
Hello, city!
Added Avenue 8
Added Avenue 12
Added Avenue 20
Added Avenue 27
Added Avenue 36
Added Avenue 42
Added Street 5
Added Street 12
Added Street 16
Added Street 24
Added Street 28
Added Street 31
Added Street 37
Added Street 42
The number of generated addresses is 1012
The address at coordinates (0, 30) is 852 Street 31
The address at coordinates (35, 30) is 436 Avenue 36
.......o#o.o#o.....o#o....o#o......o#o...o#o......
.......o#o.o#o.....o#o....o#o......o#o...o#o......
.......o#o.o#o.....o#o....o#o......o#o...o#o......
.......o#o.o#o.....o#o....o#o......o#o...o#o......
oooooooo#ooo#ooooooo#oooooo#oooooooo#ooooo#ooooooo
##################################################
oooooooo#ooo#ooooooo#oooooo#oooooooo#ooooo#ooooooo
.......o#o.o#o.....o#o....o#o......o#o...o#o......
##################################################
.......o#o.o#o.....o#o....o#o......o#o...o#o......
.......o#o.o#o.....o#o....o#o......o#o...o#o......
oooooooo#ooo#ooooooo#oooooo#oooooooo#ooooo#ooooooo
##################################################
oooooooo#ooo#ooooooo#oooooo#oooooooo#ooooo#ooooooo
.......o#o.o#o.....o#o....o#o......o#o...o#o......
oooooooo#ooo#ooooooo#oooooo#oooooooo#ooooo#ooooooo
##################################################
oooooooo#ooo#ooooooo#oooooo#oooooooo#ooooo#ooooooo
.......o#o.o#o.....o#o....o#o......o#o...o#o......
.......o#o.o#o.....o#o....o#o......o#o...o#o......
##################################################
.......o#o.o#o.....o#o....o#o......o#o...o#o......
.......o#o.o#o.....o#o....o#o......o#o...o#o......
oooooooo#ooo#ooooooo#oooooo#oooooooo#ooooo#ooooooo
##################################################
oooooooo#ooo#ooooooo#oooooo#oooooooo#ooooo#ooooooo
.......o#o.o#o.....o#o....o#o......o#o...o#o......
##################################################
##################################################
oooooooo#ooo#ooooooo#oooooo#oooooooo#ooooo#ooooooo
oooooooo#ooo#ooooooo#oooooo#oooooooo#ooooo#ooooooo
##################################################
oooooooo#ooo#ooooooo#oooooo#oooooooo#ooooo#ooooooo
.......o#o.o#o.....o#o....o#o......o#o...o#o......
.......o#o.o#o.....o#o....o#o......o#o...o#o......
.......o#o.o#o.....o#o....o#o......o#o...o#o......
##################################################
##################################################
oooooooo#ooo#ooooooo#oooooo#oooooooo#ooooo#ooooooo
.......o#o.o#o.....o#o....o#o......o#o...o#o......
.......o#o.o#o.....o#o....o#o......o#o...o#o......
oooooooo#ooo#ooooooo#oooooo#oooooooo#ooooo#ooooooo
##################################################
oooooooo#ooo#ooooooo#oooooo#oooooooo#ooooo#ooooooo
.......o#o.o#o.....o#o....o#o......o#o...o#o......
.......o#o.o#o.....o#o....o#o......o#o...o#o......
.......o#o.o#o.....o#o....o#o......o#o...o#o......
.......o#o.o#o.....o#o....o#o......o#o...o#o......
.......o#o.o#o.....o#o....o#o......o#o...o#o......
.......o#o.o#o.....o#o....o#o......o#o...o#o......
1,012 addresses for generated and then populated into the hash map.
As an Overestimate:
- City of size 50 bound units
- 6 Aves, with locations both east and west, 6 * (50 + 50) = 600
- 12 streets, with locations both north and south, 12 * (50 + 50) = 1200
- 2 two lan streets 2250 = 200, 1,800 - 200 = 1600
- Every Street and even intersect and overlap in 4 addresses.
- 6*12 = 72, intersections, so subtract 4 * 72 addresses.
1312 - 300 = 1012
The address at coordinates (0, 30) is 852 Street 31
The address at coordinates (35, 30) is 436 Avenue 36
Pushed code, my clunky one, plus the working class one: https://github.com/TheEvergreenStateCollege/upper-division-cs/pull/1488
End of day 06 May
Rustling status:
use rand::Rng;
pub mod city_drawer;
#[derive(Debug)]
pub struct Avenue {
pub x: usize,
}
#[derive(Debug)]
pub struct Street {
pub y: usize,
}
#[derive(Debug)]
pub enum Road {
Avenue(Avenue),
Street(Street),
}
use crate::city_drawer::{city_drawer, AddressAvenue, AddressStreet, HEIGHT, WIDTH};
fn gen_random_roads(bound: usize) -> Vec<Road> {
let mut rng = rand::thread_rng();
let mut n_s_avenues = Vec::new();
let mut e_w_streets = Vec::new();
// let mut roads = Vec::new();
let mut pos = 0;
while pos < bound {
let next_pos_avenue = rng.gen_range(1..10);
let next_pos_street = rng.gen_range(0..10);
pos += next_pos_avenue;
if pos < bound {
roads.push(Road::Avenue(Avenue { x: pos }));
}
pos += next_pos_street;
if pos < bound {
roads.push(Road::Street(Street { y: pos }));
}
}
// n_s_avenues.sort.by(|a, b| a.x.cmp(&b.x));
// e_w_streets.sort.by(|a, b| a.y.cmp(&b.y));
city_drawer(&mut n_s_avenues, &mut e_w_streets);
let mut roads = Vec::new();
for avenue in n_s_avenues {
roads.push(Road::Avenue(avenue));
}
for street in e_w_streets {
roads.push(Road::Street(street));
}
for _ in 0..rng.gen_range(1..bound) {}
roads
}
fn main() {
println!("Hello, city!");
// let (mut n_s_avenues, mut e_w_streets) = gen_random_streets(WIDTH, HEIGHT);
let bound = 100;
let roads = gen_random_roads(bound);
println!("Generated roads: {:?}", roads);
}