Running the simulation

All that's left to do is run warriors in simulation. In the previous chapter, an Individual was responsible for managing its own pmars process. Now, Mars will be responsible for hosting the competitors, which you may have gleaned from the C API. We simply don't have any space in Individual to store something, and by pushing competition into Mars, we can avoid allocation churn on temporary Mars structures.

The compete function that was formerly bound to Individual has now been moved to Mars:

impl Mars {
    /// Competes two Individuals at random locations
    ///
    /// The return of this function indicates the winner.     /// `Winner::Right(12)` will mean that the 'right' player  /// won 12 more rounds than did 'left'. This may mean ...

Get Hands-On Concurrency with Rust now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.