From 58cf33d6af5d8d49adfb02caf65ff2cbe245081a Mon Sep 17 00:00:00 2001 From: vandomej Date: Wed, 10 Sep 2025 22:32:54 -0700 Subject: [PATCH] Adjustments for container deployment --- .gitignore | 2 +- evolved-npcs/build.rs | 33 ++++++++++++----- .../src/fighter_nn/fighter_context.rs | 2 +- evolved-npcs/src/fighter_nn/mod.rs | 36 +++++++++---------- 4 files changed, 44 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 8f7e003..73d4174 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ # will have compiled files and executables debug/ target/ -ai_fighter/Package/ +/Packages/ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html diff --git a/evolved-npcs/build.rs b/evolved-npcs/build.rs index e6b8ca6..aeed331 100644 --- a/evolved-npcs/build.rs +++ b/evolved-npcs/build.rs @@ -1,11 +1,26 @@ fn main() { - // Replace this with the path to the directory containing `fann.lib` - let lib_dir = "F://vandomej/Downloads/vcpkg/packages/fann_x64-windows/lib"; - - println!("cargo:rustc-link-search=native={}", lib_dir); - println!("cargo:rustc-link-lib=static=fann"); - // Use `dylib=fann` instead of `static=fann` if you're linking dynamically - - // If there are any additional directories where the compiler can find header files, you can specify them like this: - // println!("cargo:include={}", path_to_include_directory); + // Determine the target platform + let target = std::env::var("TARGET").unwrap_or_default(); + + if target.contains("windows") { + // Windows-specific linking + let lib_dir = "F://vandomej/Downloads/vcpkg/packages/fann_x64-windows/lib"; + println!("cargo:rustc-link-search=native={}", lib_dir); + println!("cargo:rustc-link-lib=static=fann"); + } else if target.contains("linux") { + // Linux-specific linking + // OR if you have a custom location for Linux libs + let lib_dir = "/mnt/f/vandomej/Projects/evolved-npcs/ai_fighter/AI_Fight_Sim/Plugins/NeuralNetworkAIController/Source/NeuralNetworkAIController/ThirdParty/FANN/lib/linux/x86_64-unknown-linux-gnu/"; + let lib_path = std::path::Path::new(&lib_dir).join("libfann.a"); + if lib_path.exists() { + println!("cargo:rustc-link-search=native={}", lib_dir); + println!("cargo:rustc-link-lib=static=fann"); + println!("cargo:warning=Found libfann.a at: {:?}", lib_path); + } else { + println!("cargo:warning=libfann.a not found at: {:?}", lib_path); + panic!("libfann.a not found in specified directory"); + } + } + + // Add other target platforms as needed } diff --git a/evolved-npcs/src/fighter_nn/fighter_context.rs b/evolved-npcs/src/fighter_nn/fighter_context.rs index 56c328f..dc0ea22 100644 --- a/evolved-npcs/src/fighter_nn/fighter_context.rs +++ b/evolved-npcs/src/fighter_nn/fighter_context.rs @@ -4,7 +4,7 @@ use serde::ser::SerializeTuple; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use tokio::sync::Semaphore; -const SHARED_SEMAPHORE_CONCURRENCY_LIMIT: usize = 50; +const SHARED_SEMAPHORE_CONCURRENCY_LIMIT: usize = 5; const VISIBLE_SIMULATIONS_CONCURRENCY_LIMIT: usize = 1; #[derive(Debug, Clone)] diff --git a/evolved-npcs/src/fighter_nn/mod.rs b/evolved-npcs/src/fighter_nn/mod.rs index ba5d396..3fa753a 100644 --- a/evolved-npcs/src/fighter_nn/mod.rs +++ b/evolved-npcs/src/fighter_nn/mod.rs @@ -28,7 +28,7 @@ use uuid::Uuid; use self::neural_network_utility::{crossbreed, major_mutation}; -const BASE_DIR: &str = "F:\\\\vandomej\\Projects\\dootcamp-AI-Simulation\\Simulations"; +const BASE_DIR: &str = "..\\Simulations"; const POPULATION: usize = 200; const NEURAL_NETWORK_INPUTS: usize = 22; @@ -57,7 +57,7 @@ const SIMULATION_ROUNDS: usize = 5; const SURVIVAL_RATE_MIN: f32 = 0.1; const SURVIVAL_RATE_MAX: f32 = 0.9; const GAME_EXECUTABLE_PATH: &str = - "F:\\\\vandomej\\Projects\\dootcamp-AI-Simulation\\Package\\Windows\\AI_Fight_Sim.exe"; + "..\\Linux_Static_Library\\AI_Fight_Sim\\Binaries\\Linux\\AI_Fight_Sim"; // Here is the folder structure for the FighterNN: // base_dir/fighter_nn_{fighter_id}/{generation}/{fighter_id}_fighter_nn_{nn_id}.net @@ -846,22 +846,22 @@ async fn run_1v1_simulation( trace!("Running simulation for {} vs {}", nn_1_id, nn_2_id); - let _output = if display_simulation { - Command::new(GAME_EXECUTABLE_PATH) - .arg(&config1_arg) - .arg(&config2_arg) - .output() - .await - .expect("Failed to execute game") - } else { - Command::new(GAME_EXECUTABLE_PATH) - .arg(&config1_arg) - .arg(&config2_arg) - .arg(&disable_unreal_rendering_arg) - .output() - .await - .expect("Failed to execute game") - }; + // let _output = if display_simulation { + // Command::new(GAME_EXECUTABLE_PATH) + // .arg(&config1_arg) + // .arg(&config2_arg) + // .output() + // .await + // .expect("Failed to execute game") + // } else { + Command::new(GAME_EXECUTABLE_PATH) + .arg(&config1_arg) + .arg(&config2_arg) + .arg(&disable_unreal_rendering_arg) + .output() + .await + .expect("Failed to execute game"); + // }; trace!( "Simulation completed for {} vs {}: {}",