Skip to content

Commit

Permalink
add seed in localrunner
Browse files Browse the repository at this point in the history
  • Loading branch information
BorisKolganov committed Sep 29, 2017
1 parent d7bde81 commit 5116d99
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 26 deletions.
52 changes: 30 additions & 22 deletions localrunner/visualizer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,38 @@
<input type="range" min="0" max="7199" step="1" value="0" class="range slider btn_disabled"
style="margin-bottom: 14px; " disabled/>
<br/>
<div class="toolbar__play">
<div class="js-run toolbar__btn">
<i class="icon-play"></i>
<div class="row">
<div class="col-sm-6">
<div class="toolbar__play">
<div class="js-run toolbar__btn">
<i class="icon-play"></i>
</div>
<div class="js-pause toolbar__btn btn_disabled">
<i class="icon-pause"></i>
</div>
<div class="js-x1 toolbar__btn pressed" style="margin-left: 20px;">
<span>x1</span>
</div>
<div class="js-x2 toolbar__btn">
<span>x2</span>
</div>
<div class="js-x4 toolbar__btn">
<span>x4</span>
</div>
</div>
</div>
<div class="js-pause toolbar__btn btn_disabled">
<i class="icon-pause"></i>
<div class="col-sm-6">
<div class="toolbar__user js-score-time-user" data-href="{% url 'contest:get_user_by_solution' %}">
Игрок слева: <span class="js-username-first-player"
data-href-template="{% url 'core:open_profile' 0 %}"></span> <span
class="user__score js-current-score-first-player">0</span> очков,<br/>
Игрок справа: <span class="js-username-second-player"
data-href-template="{% url 'core:open_profile' 0 %}"></span> <span
class="user__score js-current-score-second-player">0</span> очков,<br/>
Осталось: <span class="js-till-time">02:00</span><br/>
Seed: <span class="js-seed">&mdash;</span>
</div>
</div>
<div class="js-x1 toolbar__btn pressed" style="margin-left: 20px;">
<span>x1</span>
</div>
<div class="js-x2 toolbar__btn">
<span>x2</span>
</div>
<div class="js-x4 toolbar__btn">
<span>x4</span>
</div>
</div>
<br/>
<div class="toolbar__user js-score-time-user">
Игрок слева: <span class="js-username-first-player"></span> <span
class="user__score js-current-score-first-player">0</span> очков,<br/>
Игрок справа: <span class="js-username-second-player"></span> <span
class="user__score js-current-score-second-player">0</span> очков,<br/>
Осталось: <span class="js-till-time">02:00</span>
</div>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions localrunner/visualizer/js/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ define(['conf', 'underscore'], function (conf, _) {
var currentSpan = $('.js-score-time-user');
var leftConsole = $('#left-console');
var rightConsole = $('#right-console');
var seedSpan = $('.js-seed');

var visio = data;
var config = visio.config;
Expand All @@ -33,6 +34,7 @@ define(['conf', 'underscore'], function (conf, _) {
conf.WIDTH = ww.width();
conf.FLOOR_HEIGHT *= conf.MULTIPL;
conf.HEIGHT = (config.FLOORS_COUNT + 1) * conf.FLOOR_HEIGHT;
seedSpan.html(config.SEED || '&mdash;');

var renderer = new PIXI.autoDetectRenderer(conf.WIDTH, conf.HEIGHT);
var world = init.initWorld(visio.game_data, config, renderer, scoreAndTimeSetter(currentSpan, visio.players), range, leftConsole, rightConsole);
Expand Down
4 changes: 1 addition & 3 deletions localrunner/world/core/game_objects/passenger.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ def on_tick(self):

if self.state == self.PASSENGER_STATE['moving_to_elevator']:
if self.elevator.floor == self.floor and self.elevator.is_filling():
if self.elevator.x < 0 and self.x > self.elevator.x:
self.move(x=sign(self.elevator.x))
elif self.elevator.x > 0 and self.x < self.elevator.x:
if abs(self.x - self.elevator.x) >= self.speed:

This comment has been minimized.

Copy link
@Daramant

Daramant Sep 30, 2017

Если лифт находится слева (координата x отрицательная), а пассажир еще левее, то пассажир пойдет влево, а нужно вправо (для правого лифта симметричная ситуация).
вот исправление: #84

self.move(x=sign(self.elevator.x))
elif self.elevator.floor == self.from_floor and self.elevator.can_enter():
self.elevator.enter(self)
Expand Down
11 changes: 10 additions & 1 deletion localrunner/world/core/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
from random import randint
from random import randint, seed
import sys

try:
sd = int(sys.argv[1])
except (ValueError, TypeError, IndexError):
sd = randint(0, 10000000)

seed(sd)

PLAYERS = {
"FIRST_PLAYER_KEY": "FIRST_PLAYER",
Expand All @@ -20,6 +28,7 @@
'FLOORS_COUNT': 9,
'FIRST_FLOOR': 1,
'INDICATOR_POSITION': 350,
'SEED': sd
}

BUILDING.update(BUILDING_VISIO)
Expand Down

0 comments on commit 5116d99

Please sign in to comment.