This commit is contained in:
dabreegster 2020-11-16 18:27:41 +00:00
parent 31c066a6ac
commit 85df9d5d5e
7 changed files with 62 additions and 32 deletions

View File

@ -1,3 +1,3 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `BUILT_TIME_UTC` constant in crate `game`."><meta name="keywords" content="rust, rustlang, rust-lang, BUILT_TIME_UTC"><title>game::pregame::built_info::BUILT_TIME_UTC - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="shortcut icon" href="../../../favicon.ico"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc constant"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../../../game/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><div class="sidebar-elems"><p class='location'><a href='../../index.html'>game</a>::<wbr><a href='../index.html'>pregame</a>::<wbr><a href='index.html'>built_info</a></p><script>window.sidebarCurrent = {name: 'BUILT_TIME_UTC', ty: 'constant', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><span class="help-button">?</span>
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../../../src/game/home/runner/work/abstreet/abstreet/target/debug/build/game-26b47b6c62d293fe/out/built.rs.html#49' title='goto source code'>[src]</a></span><span class='in-band'>Constant <a href='../../index.html'>game</a>::<wbr><a href='../index.html'>pregame</a>::<wbr><a href='index.html'>built_info</a>::<wbr><a class="constant" href=''>BUILT_TIME_UTC</a></span></h1><pre class='rust const'>pub const BUILT_TIME_UTC: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a> = &quot;Mon, 16 Nov 2020 17:55:14 +0000&quot;;</pre><div class='docblock'><p>The built-time in RFC2822, UTC</p>
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../../../src/game/home/runner/work/abstreet/abstreet/target/debug/build/game-26b47b6c62d293fe/out/built.rs.html#49' title='goto source code'>[src]</a></span><span class='in-band'>Constant <a href='../../index.html'>game</a>::<wbr><a href='../index.html'>pregame</a>::<wbr><a href='index.html'>built_info</a>::<wbr><a class="constant" href=''>BUILT_TIME_UTC</a></span></h1><pre class='rust const'>pub const BUILT_TIME_UTC: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a> = &quot;Mon, 16 Nov 2020 18:25:11 +0000&quot;;</pre><div class='docblock'><p>The built-time in RFC2822, UTC</p>
</div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../";window.currentCrate = "game";</script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `recorder` mod in crate `sim`."><meta name="keywords" content="rust, rustlang, rust-lang, recorder"><title>sim::recorder - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="shortcut icon" href="../../favicon.ico"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../../sim/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class='location'>Module recorder</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#structs">Structs</a></li></ul></div><p class='location'><a href='../index.html'>sim</a></p><script>window.sidebarCurrent = {name: 'recorder', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><span class="help-button">?</span>
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../../src/sim/recorder.rs.html#1-79' title='goto source code'>[src]</a></span><span class='in-band'>Module <a href='../index.html'>sim</a>::<wbr><a class="mod" href=''>recorder</a></span></h1><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../../src/sim/recorder.rs.html#1-94' title='goto source code'>[src]</a></span><span class='in-band'>Module <a href='../index.html'>sim</a>::<wbr><a class="mod" href=''>recorder</a></span></h1><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table><tr class='module-item'><td><a class="struct" href="struct.TrafficRecorder.html" title='sim::recorder::TrafficRecorder struct'>TrafficRecorder</a></td><td class='docblock-short'><p>Records trips beginning and ending at a specified set of intersections. This can be used to
capture and reproduce behavior in a gridlock-prone chunk of the map, without simulating
everything.</p>

File diff suppressed because one or more lines are too long

View File

@ -112,7 +112,7 @@
<span class="doccomment">/// The output of `rustdoc -V`</span>
<span class="kw">pub</span> <span class="kw">const</span> <span class="ident">RUSTDOC_VERSION</span>: <span class="kw-2">&amp;</span><span class="ident">str</span> <span class="op">=</span> <span class="string">&quot;rustdoc 1.47.0 (18bf6b4f0 2020-10-07)&quot;</span>;
<span class="doccomment">/// The built-time in RFC2822, UTC</span>
<span class="kw">pub</span> <span class="kw">const</span> <span class="ident">BUILT_TIME_UTC</span>: <span class="kw-2">&amp;</span><span class="ident">str</span> <span class="op">=</span> <span class="string">&quot;Mon, 16 Nov 2020 17:55:14 +0000&quot;</span>;
<span class="kw">pub</span> <span class="kw">const</span> <span class="ident">BUILT_TIME_UTC</span>: <span class="kw-2">&amp;</span><span class="ident">str</span> <span class="op">=</span> <span class="string">&quot;Mon, 16 Nov 2020 18:25:11 +0000&quot;</span>;
<span class="doccomment">/// The target architecture, given by `cfg!(target_arch)`.</span>
<span class="kw">pub</span> <span class="kw">const</span> <span class="ident">CFG_TARGET_ARCH</span>: <span class="kw-2">&amp;</span><span class="ident">str</span> <span class="op">=</span> <span class="string">&quot;x86_64&quot;</span>;
<span class="doccomment">/// The endianness, given by `cfg!(target_endian)`.</span>

View File

@ -78,15 +78,30 @@
<span id="77">77</span>
<span id="78">78</span>
<span id="79">79</span>
<span id="80">80</span>
<span id="81">81</span>
<span id="82">82</span>
<span id="83">83</span>
<span id="84">84</span>
<span id="85">85</span>
<span id="86">86</span>
<span id="87">87</span>
<span id="88">88</span>
<span id="89">89</span>
<span id="90">90</span>
<span id="91">91</span>
<span id="92">92</span>
<span id="93">93</span>
<span id="94">94</span>
</pre><div class="example-wrap"><pre class="rust ">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">collections</span>::{<span class="ident">BTreeMap</span>, <span class="ident">BTreeSet</span>};
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">collections</span>::<span class="ident">BTreeSet</span>;
<span class="kw">use</span> <span class="ident">geom</span>::<span class="ident">Time</span>;
<span class="kw">use</span> <span class="ident">map_model</span>::{<span class="ident">IntersectionID</span>, <span class="ident">LaneID</span>, <span class="ident">Map</span>, <span class="ident">Position</span>, <span class="ident">Traversable</span>};
<span class="kw">use</span> <span class="ident">map_model</span>::{<span class="ident">IntersectionID</span>, <span class="ident">Map</span>, <span class="ident">PathStep</span>, <span class="ident">Position</span>, <span class="ident">Traversable</span>};
<span class="kw">use</span> <span class="kw">crate</span>::{
<span class="ident">AgentID</span>, <span class="ident">CarID</span>, <span class="ident">DrivingGoal</span>, <span class="ident">Event</span>, <span class="ident">IndividTrip</span>, <span class="ident">PersonID</span>, <span class="ident">PersonSpec</span>, <span class="ident">Scenario</span>, <span class="ident">SpawnTrip</span>,
<span class="ident">TripPurpose</span>, <span class="ident">VehicleType</span>,
<span class="ident">AgentID</span>, <span class="ident">DrivingGoal</span>, <span class="ident">DrivingSimState</span>, <span class="ident">Event</span>, <span class="ident">IndividTrip</span>, <span class="ident">PersonID</span>, <span class="ident">PersonSpec</span>, <span class="ident">Scenario</span>,
<span class="ident">SpawnTrip</span>, <span class="ident">TripID</span>, <span class="ident">TripManager</span>, <span class="ident">TripPurpose</span>, <span class="ident">VehicleType</span>,
};
<span class="doccomment">/// Records trips beginning and ending at a specified set of intersections. This can be used to</span>
@ -98,8 +113,7 @@
<span class="comment">// TODO The RNG will determine vehicle length, so this won&#39;t be a perfect capture. Hopefully</span>
<span class="comment">// good enough.</span>
<span class="ident">trips</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">IndividTrip</span><span class="op">&gt;</span>,
<span class="comment">// Where and when did a car encounter one of the capture_points?</span>
<span class="ident">entered</span>: <span class="ident">BTreeMap</span><span class="op">&lt;</span><span class="ident">CarID</span>, (<span class="ident">Time</span>, <span class="ident">LaneID</span>)<span class="op">&gt;</span>,
<span class="ident">seen_trips</span>: <span class="ident">BTreeSet</span><span class="op">&lt;</span><span class="ident">TripID</span><span class="op">&gt;</span>,
}
<span class="kw">impl</span> <span class="ident">TrafficRecorder</span> {
@ -107,28 +121,44 @@
<span class="ident">TrafficRecorder</span> {
<span class="ident">capture_points</span>,
<span class="ident">trips</span>: <span class="ident">Vec</span>::<span class="ident">new</span>(),
<span class="ident">entered</span>: <span class="ident">BTreeMap</span>::<span class="ident">new</span>(),
<span class="ident">seen_trips</span>: <span class="ident">BTreeSet</span>::<span class="ident">new</span>(),
}
}
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">handle_event</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">time</span>: <span class="ident">Time</span>, <span class="ident">ev</span>: <span class="kw-2">&amp;</span><span class="ident">Event</span>, <span class="ident">map</span>: <span class="kw-2">&amp;</span><span class="ident">Map</span>) {
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">handle_event</span>(
<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>,
<span class="ident">time</span>: <span class="ident">Time</span>,
<span class="ident">ev</span>: <span class="kw-2">&amp;</span><span class="ident">Event</span>,
<span class="ident">map</span>: <span class="kw-2">&amp;</span><span class="ident">Map</span>,
<span class="ident">driving</span>: <span class="kw-2">&amp;</span><span class="ident">DrivingSimState</span>,
<span class="ident">trips</span>: <span class="kw-2">&amp;</span><span class="ident">TripManager</span>,
) {
<span class="kw">if</span> <span class="kw">let</span> <span class="ident">Event</span>::<span class="ident">AgentEntersTraversable</span>(<span class="ident">a</span>, <span class="ident">on</span>, <span class="kw">_</span>) <span class="op">=</span> <span class="ident">ev</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="ident">AgentID</span>::<span class="ident">Car</span>(<span class="ident">car</span>) <span class="op">=</span> <span class="ident">a</span> {
<span class="kw">if</span> <span class="kw">let</span> <span class="ident">Traversable</span>::<span class="ident">Lane</span>(<span class="ident">l</span>) <span class="op">=</span> <span class="ident">on</span> {
<span class="kw">let</span> <span class="ident">lane</span> <span class="op">=</span> <span class="ident">map</span>.<span class="ident">get_l</span>(<span class="kw-2">*</span><span class="ident">l</span>);
<span class="kw">if</span> <span class="self">self</span>.<span class="ident">capture_points</span>.<span class="ident">contains</span>(<span class="kw-2">&amp;</span><span class="ident">lane</span>.<span class="ident">src_i</span>) {
<span class="self">self</span>.<span class="ident">entered</span>.<span class="ident">insert</span>(<span class="kw-2">*</span><span class="ident">car</span>, (<span class="ident">time</span>, <span class="kw-2">*</span><span class="ident">l</span>));
} <span class="kw">else</span> <span class="kw">if</span> <span class="self">self</span>.<span class="ident">capture_points</span>.<span class="ident">contains</span>(<span class="kw-2">&amp;</span><span class="ident">lane</span>.<span class="ident">dst_i</span>) {
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>((<span class="ident">depart</span>, <span class="ident">from</span>)) <span class="op">=</span> <span class="self">self</span>.<span class="ident">entered</span>.<span class="ident">remove</span>(<span class="ident">car</span>) {
<span class="self">self</span>.<span class="ident">trips</span>.<span class="ident">push</span>(<span class="ident">IndividTrip</span>::<span class="ident">new</span>(
<span class="ident">depart</span>,
<span class="ident">TripPurpose</span>::<span class="ident">Shopping</span>,
<span class="ident">SpawnTrip</span>::<span class="ident">VehicleAppearing</span> {
<span class="ident">start</span>: <span class="ident">Position</span>::<span class="ident">start</span>(<span class="ident">from</span>),
<span class="ident">goal</span>: <span class="ident">DrivingGoal</span>::<span class="ident">Border</span>(<span class="ident">lane</span>.<span class="ident">dst_i</span>, <span class="ident">lane</span>.<span class="ident">id</span>, <span class="prelude-val">None</span>),
<span class="ident">is_bike</span>: <span class="ident">car</span>.<span class="number">1</span> <span class="op">==</span> <span class="ident">VehicleType</span>::<span class="ident">Bike</span>,
},
));
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">trip</span>) <span class="op">=</span> <span class="ident">trips</span>.<span class="ident">agent_to_trip</span>(<span class="ident">AgentID</span>::<span class="ident">Car</span>(<span class="kw-2">*</span><span class="ident">car</span>)) {
<span class="kw">if</span> <span class="self">self</span>.<span class="ident">seen_trips</span>.<span class="ident">contains</span>(<span class="kw-2">&amp;</span><span class="ident">trip</span>) {
<span class="kw">return</span>;
}
<span class="kw">if</span> <span class="kw">let</span> <span class="ident">Traversable</span>::<span class="ident">Lane</span>(<span class="ident">l</span>) <span class="op">=</span> <span class="ident">on</span> {
<span class="kw">if</span> <span class="self">self</span>.<span class="ident">capture_points</span>.<span class="ident">contains</span>(<span class="kw-2">&amp;</span><span class="ident">map</span>.<span class="ident">get_l</span>(<span class="kw-2">*</span><span class="ident">l</span>).<span class="ident">src_i</span>) {
<span class="comment">// Where do they exit?</span>
<span class="kw">for</span> <span class="ident">step</span> <span class="kw">in</span> <span class="ident">driving</span>.<span class="ident">get_path</span>(<span class="kw-2">*</span><span class="ident">car</span>).<span class="ident">unwrap</span>().<span class="ident">get_steps</span>() {
<span class="kw">if</span> <span class="kw">let</span> <span class="ident">PathStep</span>::<span class="ident">Turn</span>(<span class="ident">t</span>) <span class="op">=</span> <span class="ident">step</span> {
<span class="kw">if</span> <span class="self">self</span>.<span class="ident">capture_points</span>.<span class="ident">contains</span>(<span class="kw-2">&amp;</span><span class="ident">t</span>.<span class="ident">parent</span>) {
<span class="self">self</span>.<span class="ident">trips</span>.<span class="ident">push</span>(<span class="ident">IndividTrip</span>::<span class="ident">new</span>(
<span class="ident">time</span>,
<span class="ident">TripPurpose</span>::<span class="ident">Shopping</span>,
<span class="ident">SpawnTrip</span>::<span class="ident">VehicleAppearing</span> {
<span class="ident">start</span>: <span class="ident">Position</span>::<span class="ident">start</span>(<span class="kw-2">*</span><span class="ident">l</span>),
<span class="ident">goal</span>: <span class="ident">DrivingGoal</span>::<span class="ident">Border</span>(<span class="ident">t</span>.<span class="ident">parent</span>, <span class="ident">t</span>.<span class="ident">src</span>, <span class="prelude-val">None</span>),
<span class="ident">is_bike</span>: <span class="ident">car</span>.<span class="number">1</span> <span class="op">==</span> <span class="ident">VehicleType</span>::<span class="ident">Bike</span>,
},
));
<span class="self">self</span>.<span class="ident">seen_trips</span>.<span class="ident">insert</span>(<span class="ident">trip</span>);
<span class="kw">return</span>;
}
}
}
}
}
}

View File

@ -1684,7 +1684,7 @@
<span class="ident">m</span>.<span class="ident">handle_event</span>(<span class="self">self</span>.<span class="ident">time</span>, <span class="kw-2">&amp;</span><span class="ident">ev</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>.<span class="ident">scheduler</span>);
}
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="kw-2">ref</span> <span class="kw-2">mut</span> <span class="ident">r</span>) <span class="op">=</span> <span class="self">self</span>.<span class="ident">recorder</span> {
<span class="ident">r</span>.<span class="ident">handle_event</span>(<span class="self">self</span>.<span class="ident">time</span>, <span class="kw-2">&amp;</span><span class="ident">ev</span>, <span class="ident">map</span>);
<span class="ident">r</span>.<span class="ident">handle_event</span>(<span class="self">self</span>.<span class="ident">time</span>, <span class="kw-2">&amp;</span><span class="ident">ev</span>, <span class="ident">map</span>, <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">driving</span>, <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">trips</span>);
}
<span class="self">self</span>.<span class="ident">analytics</span>.<span class="ident">event</span>(<span class="ident">ev</span>, <span class="self">self</span>.<span class="ident">time</span>, <span class="ident">map</span>);