May 2018
Intermediate to advanced
462 pages
11h 5m
English
It's now time to consider how each Individual competes. Earlier, we discussed calling out to pmars on-system, which requires on-disk representations of the two competing Individual warriors. True to that, competition first serializes both warriors to temporary locations on the disk:
pub fn compete(&self, other: &Individual) -> Winner {
let dir = TempDir::new("simulate") .expect("could not make tempdir");
let l_path = dir.path().join("left.red");
let mut lfp = BufWriter::new(File::create(&l_path) .expect("could not write lfp"));
self.serialize(&mut lfp).expect("could not serialize");
drop(lfp);
let r_path = dir.path().join("right.red");
let mut rfp = BufWriter::new(File::create(&r_path) .expect("could not ...Read now
Unlock full access