Skip to content

Instantly share code, notes, and snippets.

@vanatteveldt
Created August 15, 2018 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanatteveldt/1517f8d38c0e818af2e062f50dcabb6e to your computer and use it in GitHub Desktop.
Save vanatteveldt/1517f8d38c0e818af2e062f50dcabb6e to your computer and use it in GitHub Desktop.
setwd("/home/wva/Dropbox/Games/stars/minesim2")
library(tidyverse)
results = list()
scenario = "sim_cardinal"
N = 500
for (i in 1:N) {
name = paste(scenario, i, sep = "_")
message(name)
# generate and export results
system(paste0("cp ", scenario, "/* ."))
system("wine ../starsjrc4.exe -g Game.hst")
system("wine ../starsjrc4.exe -df Game.m2")
f = read.csv("Game.f2", sep="\t", quote=NULL, fileEncoding = "latin1") %>% as_tibble %>% filter(grepl("Test", Fleet.Name)) %>% select(name=Fleet.Name, n=Ship.Cnt) %>% mutate(i=i, scenario=scenario)
results[[name]] = f
}
saveRDS(results, "results_minesim2.rds")
results = readRDS("results_minesim2.rds")
bind_rows(results) %>% group_by(scenario, name) %>% summarize(chance_hit = 1 - sum(n) / N)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment