forked from CyberBiology/CyberBiology
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
imitate: добавление гена подражания в поведении
Команда копирует случайный участок генома другого бота в свой геном и передает туда управление.
- Loading branch information
Showing
3 changed files
with
83 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package ru.cyberbiology.test.gene; | ||
|
||
import ru.cyberbiology.test.prototype.IBot; | ||
import ru.cyberbiology.test.prototype.gene.ABotGeneController; | ||
|
||
/** | ||
* Имитирование, подражание в поведении. | ||
* Команда копирует случайный участок генома друго бота в свой геном. | ||
* | ||
* @author Sergey Sokolov <[email protected]> | ||
*/ | ||
public class GeneImitate extends ABotGeneController { | ||
|
||
@Override | ||
public boolean onGene(IBot bot) { | ||
// направление действия | ||
int dir = bot.getParam() % 8; | ||
// адрес начала копирования в геноме другого бота | ||
bot.incCommandAddress(bot.imitate(dir)); | ||
// команда завершающая | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getDescription(IBot bot, int i) { | ||
return "имитирование"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,4 +69,6 @@ public interface IBot | |
public void genAttack(); | ||
public IWorld getWorld(); | ||
|
||
public int imitate(int dir); | ||
|
||
} |