Skip to content

Commit

Permalink
fix: направление первого бота задается случайно
Browse files Browse the repository at this point in the history
    Так же случайное направление выбирается при создании бота.
  • Loading branch information
xlam committed Nov 28, 2018
1 parent 0825b12 commit 22d5eb1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/main/java/ru/cyberbiology/BasicBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public class BasicBot implements Bot {
public BasicBot(BasicWorld world) {
this.world = world;
setupGeneControllers();
direction = 2;
direction = RANDOM.nextInt(8);
health = 5;
alive = LV_ALIVE;
}
Expand Down Expand Up @@ -902,8 +902,6 @@ private void botDouble(BasicBot bot) {
newbot.c_green = bot.c_green; // цвет такой же, как у предка
newbot.c_blue = bot.c_blue; // цвет такой же, как у предка

newbot.direction = RANDOM.nextInt(8); // направление, куда повернут новорожденный, генерируется случайно

world.setBot(newbot); // отмечаем нового бота в массиве matrix
// todo: https://github.com/xlam/CyberBiology/issues/2
// this.world.population++;
Expand Down Expand Up @@ -956,8 +954,6 @@ private void botMulti(BasicBot bot) {
newbot.c_green = bot.c_green; // цвет такой же, как у предка
newbot.c_blue = bot.c_blue; // цвет такой же, как у предка

newbot.direction = RANDOM.nextInt(8); // направление, куда повернут новорожденный, генерируется случайно

world.setBot(newbot); // отмечаем нового бота в массиве matrix
// todo: https://github.com/xlam/CyberBiology/issues/2
// this.world.population++;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ru/cyberbiology/BasicWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public final void generateAdam() {
bot.c_red = 170; // задаем цвет бота
bot.c_blue = 170;
bot.c_green = 170;
bot.direction = 5; // направление
bot.direction = RANDOM.nextInt(8); // направление
bot.mprev = null; // бот не входит в многоклеточные цепочки, поэтому
// ссылки
bot.mnext = null; // на предыдущего, следующего в многоклеточной цепочке
Expand Down

0 comments on commit 22d5eb1

Please sign in to comment.