From e9666aec0fa54321e6c37e09fa9770ffa6c7c744 Mon Sep 17 00:00:00 2001 From: Toshiki Kataoka Date: Mon, 20 Jul 2020 16:46:18 +0900 Subject: [PATCH 1/4] rng --- src/bin/tos.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/bin/tos.rs b/src/bin/tos.rs index e5ade68..a9398cb 100644 --- a/src/bin/tos.rs +++ b/src/bin/tos.rs @@ -1,9 +1,10 @@ use app::client::*; // use std; use std::convert::*; -// use rand::prelude::*; +use rand::Rng; fn run() { + let mut rng = rand::thread_rng(); let server_url = std::env::args().nth(1).unwrap(); let mut client = Client::new(server_url); if std::env::args().len() == 2 { @@ -13,7 +14,7 @@ fn run() { let player_key = std::env::args().nth(2).unwrap(); let mut resp = client.join(&player_key); let power = 32; - let cool = 8; + let cool = 0; let life = 1; resp = client.start(resp.info.ability.potential - power * 4 - cool * 12 - life * 2, power, cool, life); @@ -48,8 +49,10 @@ fn run() { let shoot_now = myship.heat -myship.status.cool + 16 <= myship.max_heat; if shoot_now { - commands.push(Command::Shoot(1, (myship.pos.0 + dx, myship.pos.1 + dy), 64, None)); - dx+=1; + dx = rng.gen_range(-20, 20); + dy = rng.gen_range(-20, 20); + let shoot_power = power; + commands.push(Command::Shoot(1, (myship.pos.0 + dx, myship.pos.1 + dy), shoot_power, None)); } // !!! @@ -62,8 +65,9 @@ fn run() { for ship in resp.state.ships.iter() { for cmd in ship.commands.iter() { match cmd { - Command::Shoot(_, (x,y), _, Some((impact, four))) => { - println!("({},{}) impact={}, four={}", x - ship.pos.0,y - ship.pos.1, impact, four); + Command::Shoot(_, (x,y), p, Some((impact, four))) => { + println!("({},{}), power={} impact={}, four={}", + x - ship.pos.0,y - ship.pos.1, p, impact, four); }, _=> {}, } From 2e015126bebf6b42b38747fc2dc9dd6e0b96abe8 Mon Sep 17 00:00:00 2001 From: Toshiki Kataoka Date: Mon, 20 Jul 2020 17:10:48 +0900 Subject: [PATCH 2/4] fix format --- src/bin/tos.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/bin/tos.rs b/src/bin/tos.rs index a9398cb..4f69a97 100644 --- a/src/bin/tos.rs +++ b/src/bin/tos.rs @@ -49,8 +49,9 @@ fn run() { let shoot_now = myship.heat -myship.status.cool + 16 <= myship.max_heat; if shoot_now { - dx = rng.gen_range(-20, 20); - dy = rng.gen_range(-20, 20); + let fix = resp.info.role; + dx = rng.gen_range(0, 20) + fix; + dy = rng.gen_range(0, 20) + fix; let shoot_power = power; commands.push(Command::Shoot(1, (myship.pos.0 + dx, myship.pos.1 + dy), shoot_power, None)); } @@ -66,7 +67,8 @@ fn run() { for cmd in ship.commands.iter() { match cmd { Command::Shoot(_, (x,y), p, Some((impact, four))) => { - println!("({},{}), power={} impact={}, four={}", + println!("_, x, y, power, impact, four"); + println!("[shoot], {}, {}, {}, {}, {}", x - ship.pos.0,y - ship.pos.1, p, impact, four); }, _=> {}, From c370e0a051b7a356bf7a00efb4a8e84cdc98c569 Mon Sep 17 00:00:00 2001 From: Toshiki Kataoka Date: Mon, 20 Jul 2020 17:53:31 +0900 Subject: [PATCH 3/4] tmp --- src/bin/tos.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/tos.rs b/src/bin/tos.rs index 4f69a97..af8cffc 100644 --- a/src/bin/tos.rs +++ b/src/bin/tos.rs @@ -50,8 +50,10 @@ fn run() { let shoot_now = myship.heat -myship.status.cool + 16 <= myship.max_heat; if shoot_now { let fix = resp.info.role; - dx = rng.gen_range(0, 20) + fix; - dy = rng.gen_range(0, 20) + fix; + // dx = rng.gen_range(0, 20) + fix; + dx = rng.gen_range(32, 96) + fix; + // dy = rng.gen_range(0, 20) + fix; + dy = 0; let shoot_power = power; commands.push(Command::Shoot(1, (myship.pos.0 + dx, myship.pos.1 + dy), shoot_power, None)); } From 76c69e47ab5f759a0e66bfa57b01fa1375c56aa9 Mon Sep 17 00:00:00 2001 From: Toshiki Kataoka Date: Mon, 20 Jul 2020 18:18:36 +0900 Subject: [PATCH 4/4] mv --- src/bin/{tos.rs => tos1.rs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/bin/{tos.rs => tos1.rs} (100%) diff --git a/src/bin/tos.rs b/src/bin/tos1.rs similarity index 100% rename from src/bin/tos.rs rename to src/bin/tos1.rs