Crate me2finale

source ·
Expand description

Mass Effect 2 Final Mission Analysis

This crate defines types that encode decision paths and outcomes related to the final mission of Mass Effect 2. Although the game presents many, many choices to the player, only certain ones affect the survival of your allies into and through Mass Effect 3, if you transfer your save file. This crate is only concerned with those aspects of the game.

Particulars of decision paths and outcomes are documented in DecisionPath and Outcome, respectively.

The generate::outcome_map function traverses all possible decision paths, determines their outcomes, and returns an OutcomeMap—a HashMap keyed by Outcome. Instead of storing all DecisionPaths that led to each Outcome, the OutcomeMap’s values contain one such decision path and a count. The reason for this is limited memory, as there are over 64 billion possible decision paths.

The allies involved in the choices and tabulated in the outcomes are encoded in the Ally enum and its dedicated collection type, AllySet. To effect your own queries of the outcome data, you will want a passing familiarity with these types. The following example determines how often Tali, the Quarian, survives out of all possibilities—that is, her absolute survival rate.

use me2finale::prelude::*;
 
#[cfg(feature = "generate")]
let outcome_map = me2finale::generate::outcome_map();

#[cfg(not(feature = "generate"))]
let outcome_map = {
    use serde::Deserialize;
    let file = std::fs::File::open("outcome_map.rmp")?;
    let mut deserializer = rmp_serde::Deserializer::new(file);
    OutcomeMap::deserialize(&mut deserializer)?
};

let total_traversals = outcome_map
    .values()
    .map(|metadata| metadata.count)
    .sum::<usize>();

let tali_survivals = outcome_map
    .iter()
    .filter_map(|(outcome, metadata)| {
        outcome
            .survivors
            .contains(Ally::Tali)
            .then_some(metadata.count)
    })
    .sum::<usize>();

let tali_survival_rate = tali_survivals as f32 / total_traversals as f32;
println!("Tali's absolute survival rate is {tali_survival_rate}.");

Optional Features

By default, this crate merely exposes types and facilities necessary to query and serialize/deserialize (via serde traits) existing outcome data. If you wish to generate the outcome data yourself, you must enable the generate feature. Doing so adds a few external dependencies and gives access to generate::outcome_map.

More Examples

The me2finale repository includes examples for generating and analyzing outcome data.

Modules

Ally enumeration
Ally collection and iteration
Decision-related types
Outcome data generation
Outcome data types
Commonly used types

Structs

Set-like type optimized for Ally
Result of one or more complete decision paths

Enums

Enumeration of all allies in Mass Effect 2

Type Definitions

HashMap of Outcomes to metadata describing the DecisionPaths from which they were produced