Created
August 15, 2018 10:39
-
-
Save vanatteveldt/1517f8d38c0e818af2e062f50dcabb6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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