Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust repeater with local runner integration #124

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

elsid
Copy link

@elsid elsid commented Jan 21, 2019

Introduced as replacement for Repeater (https://russianaicup.ru/p/repeater) to use for Rust-only strategies (same approach could be use for any other language). The idea is to read stdin with game log and communicate with local runner in the same time. Local runner data is ignored. Instead stdin is used to read and parse game state. Strategy output action is ignored. Default action is sent to local runner. So local runner will not show any activity, but one could use custom rendering to visualize in schematic view any data.

Usage example:

  1. Download game log from https://russianaicup.ru/game/view/<...>
  2. Run local runner and repeater:
local_runner/codeball2018 --p2 empty &
target/release/repeater elsid < game.log

elsid added 2 commits January 22, 2019 00:51
Introduced as replacement for Repeater
(https://russianaicup.ru/p/repeater) to use for Rust-only strategies.
The idea is to read stdin with game log and communicate with local
runner in the same time. Local runner data is ignored. Instead stdin
line is used. Strategy output action is ignored. Default action sends
to local runner. So local runner will not show any activity, but one
could use custom rendering to visualize in schematic view any data.

Usage example:
local_runner/codeball2018 --p2 empty &
target/release/repeater elsid < game.log
@elsid
Copy link
Author

elsid commented Jan 29, 2019

Fixed conversion to opposite coordinates. x should be same.

How to check.

  1. Make strategy with code (prints all robots coordinates to stdout):
impl Strategy for MyStrategyImpl {
    fn act(&mut self, me: &Robot, rules: &Rules, game: &Game, action: &mut Action) {
        println!("{} {:?}", me.id, game.robots.iter().map(|v| (v.id, v.x)).collect::<Vec<_>>());
        action.target_velocity_x = 30.0;
    }
}
  1. Run for both sides:
local_runner/codeball2018 \
    --noshow \
    --team-size 1 \
    --log-file ${PWD}/game.json \
    --p1-name a \
    --p2-name b \
    --p1 tcp-31001 \
    --p2 tcp-31002 &
sleep 1
target/release/my-strategy 127.0.0.1 31001 0000000000000000 > a1.log &
sleep 1
target/release/my-strategy 127.0.0.1 31002 0000000000000000 > b1.log
wait
  1. Run repeat:
local_runner/codeball2018 \
    --noshow \
    --team-size 1 \
    --p1-name a \
    --p2-name b \
    --p1 tcp-31001 \
    --p2 tcp-31002 &
sleep 1
target/release/repeater a 127.0.0.1 31001 0000000000000000 < ${PWD}/game.json > a2.log &
sleep 1
target/release/repeater b 127.0.0.1 31002 0000000000000000 < ${PWD}/game.json > b2.log
wait
  1. Strategies outputs should be same for original run and repeat:
diff a1.log a2.log
diff b1.log b2.log

It differs without 424b1d1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant