Skip to content

Instantly share code, notes, and snippets.

@sug0
sug0 / sin.rs
Last active February 16, 2022 09:57
Constant function sin table in Rust
#![feature(const_fn)]
#![feature(const_raw_ptr_deref)]
fn main() {
const SIN_90: f32 = SINTAB[90];
println!("{}", SIN_90);
}
const fn to_radians(x: f64) -> f64 {
x * (std::f64::consts::PI / 180.0)

Deterministic save load in Factorio

One of the key parts of the save/load process in Factorio is that it must be deterministic. This means that for a given save file (when no external factors change) saving, exiting, and loading the save shouldn't change any observable behavior.

There are a few reasons and benefits for this strict requirement:

  • Without it: You couldn't join a running multiplayer game (and by proxy save, exit, and resume one)
  • Without it: the replay system wouldn't work if you ever saved, exited, and resumed playing.
  • With it: we can easily test that saving and loading produces no observable change letting us know we implemented save/load correctly.
  • With it: you won't see things change randomly as a result of "reloading" like you do in so many other games.
; The official HD AI
; An Artificial Intelligence Script written by Archon and Promiskuitiv
; Get in contact with Promiskuitiv by sending a mail to [email protected]
; List of taunts it reacts to:
; Standard taunts.
; 33 - Stop slinging resources. If slinging is requested early and is immediately canceled it may mess up the strategy.
; 38 - Sling Resources. Human player only, stops any unit production except for civilian units.