{"id":461089,"date":"2025-05-26T21:01:07","date_gmt":"2025-05-26T21:01:07","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=461089"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=461089","title":{"rendered":"<span>\u041a\u0430\u043a \u044f \u043e\u0442\u043a\u0440\u044b\u043b WebSocket \u0434\u043b\u044f \u0421\u043e\u043c\u043d\u0438\u043a\u043e\u0432 \u0438\u0437 \u0427\u0451\u0440\u043d\u043e\u0433\u043e \u0417\u0435\u0440\u043a\u0430\u043b\u0430, \u0430 \u043e\u043d\u0438 \u043d\u0430\u0447\u0430\u043b\u0438 \u0432\u043e\u0434\u0438\u0442\u044c \u0445\u043e\u0440\u043e\u0432\u043e\u0434\u044b<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u042d\u0442\u043e \u043c\u043e\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u043f\u0440\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u0435\u0442-\u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>\u041e\u0442\u043a\u0443\u0434\u0430 \u0440\u0430\u0441\u0442\u0443\u0442 \u043d\u043e\u0433\u0438: \u042f \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b 4 \u044d\u043f\u0438\u0437\u043e\u0434 7 \u0441\u0435\u0437\u043e\u043d\u0430 \u0441\u0435\u0440\u0438\u0430\u043b\u0430 \u00ab\u0427\u0451\u0440\u043d\u043e\u0435 \u0437\u0435\u0440\u043a\u0430\u043b\u043e\u00bb, \u0433\u0434\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u0430\u044f \u0438\u0433\u0440\u0430 \u0441 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u043e\u043c, \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u043c\u0438\u0440\u043e\u043c \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u043b\u0441\u044f \u043c\u0435\u043b\u044c\u043a\u0430\u043d\u0438\u0435\u043c \u043d\u0430 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0435 \u0438 \u0438\u0437\u0434\u0430\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0442\u0438\u0447\u044c\u0438\u0445 (\u0441\u043a\u043e\u0440\u0435\u0435 \u0442\u0440\u0443\u0431\u043d\u044b\u0445) \u0437\u0432\u0443\u043a\u043e\u0432.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d57\/e11\/c26\/d57e11c2637646b46b804c1f9f1b0252.png\" width=\"1460\" height=\"821\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/d57\/e11\/c26\/d57e11c2637646b46b804c1f9f1b0252.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d57\/e11\/c26\/d57e11c2637646b46b804c1f9f1b0252.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0421 \u043f\u0440\u0438\u0445\u043e\u0434\u043e\u043c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439, \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0438\u0434\u044b \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u0430 \u0442\u043e\u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u0432\u043e\u0451 \u043c\u0435\u0441\u0442\u043e \u043f\u043e\u0434 \u0441\u043e\u043b\u043d\u0446\u0435\u043c. \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0449\u0451 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u044b, \u0433\u0434\u0435 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442 \u0438\u0433\u0440\u0430\u0435\u0442 \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0438\u0433\u0440\u044b, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0447\u043a\u0438 \u0437\u0430 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0435 \u0446\u0435\u043b\u0435\u0439 \u0438 \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0432\u043e\u0438\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u0418\u0418 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0435\u043c\u0443 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u043c \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u043c \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c. \u042f \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0418\u0418 \u0441 \u0438\u0433\u0440\u043e\u0432\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e\u043c, \u0430 \u0443\u0436\u0435 \u043f\u043e\u0442\u043e\u043c \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0438\u0433\u0440\u0443 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438 \u0438 \u0441\u043c\u044b\u0441\u043b\u043e\u043c.<\/p>\n<h2>\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b<\/h2>\n<ul>\n<li>\n<p>Java<\/p>\n<\/li>\n<li>\n<p>Spring (WebFlux)<\/p>\n<\/li>\n<li>\n<p>JS + HTML<\/p>\n<\/li>\n<\/ul>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430<\/h2>\n<p>\u0413\u043b\u0430\u0432\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0431\u044b\u043b\u0430 \u0432\u0441\u0451 \u0436\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c &#171;\u0441\u0443\u0449\u0435\u0441\u0442\u0432&#187;. \u042f \u0434\u0430\u043b \u0438\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440, \u0438\u043c\u044f, \u0442\u0438\u043f, \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u0438 \u043d\u0435\u043a\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u043e \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0430 (\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e \u0442\u043e\u0447\u043a\u0438, \u043e\u0442\u0434\u044b\u0445) \u0438 \u0432\u0440\u0435\u043c\u044f, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u043d\u0430 \u044d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u0435\u0440\u0435\u0434 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u043c \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443.<\/p>\n<pre><code class=\"java\">    @Data     @AllArgsConstructor     @NoArgsConstructor     public static class Creature {         private int id;         private float x;         private float y;         private final String type = \"yellow\";         private CreatureState state;         private String name = \"Console\";         private String picture = Picture.IMAGE.toString();<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u043d\u043e\u0439 \u0431\u044b\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u043a\u043b\u0430\u0441\u0441 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438\u0433\u0440\u044b, \u0433\u0434\u0435 \u044f \u0441\u0430\u043c\u044b\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0432\u043a\u043b\u044e\u0447\u0438\u043b \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432 \u0438 \u0432\u043f\u0438\u0441\u0430\u043b \u043e\u0431\u044a\u0435\u043a\u0442-\u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434 \u0444\u043e\u043d\u0430 \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:<\/p>\n<pre><code class=\"java\">    @Data     @AllArgsConstructor     @NoArgsConstructor     public static class GameState {         private List&lt;Creature&gt; creatures;         private Environment environment;     }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0431\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u043d GameStateManager, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u044f \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u043b \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0441\u043f\u0430\u0432\u043d\u0430 \u043d\u043e\u0432\u044b\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438\u0433\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u043b\u0438\u0435\u043d\u0442.<\/p>\n<pre><code class=\"java\">    private final DataModels.GameState gameState;     public GameStateManager(DataModels.GameState gameState){         this.gameState = gameState;     }      private final Queue&lt;DataModels.Creature&gt; toSpawn = new ConcurrentLinkedDeque&lt;&gt;();      public void spawnCreature(String name){         toSpawn.add(new DataModels.Creature(name));     }      public void updateGameState() {         \/\/ \u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432         toSpawn.forEach(creature -&gt; gameState.getCreatures().add(creature));         toSpawn.clear();         gameState.getCreatures().forEach(creature -&gt; {             creature.setX(creature.getX() + creature.getState().getVectorX());             creature.setY(creature.getY() + creature.getState().getVectorY());             creature.getState().add();             creature.updateFrame();             if(creature.getState().getT() &gt; 1){                 \/\/\u041c\u0435\u043d\u044f\u0435\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435                 if((creature.getState().sx == creature.getState().fx) &amp;&amp;                         (creature.getState().sy == creature.getState().fy))                 {                     creature.updateState();                 }else{                     creature.setTimeout();                 }             }             \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0433\u0440\u0430\u043d\u0438\u0446             creature.setX(Math.max(0, Math.min(800, creature.getX())));             creature.setY(Math.max(0, Math.min(600, creature.getY())));         });     }<\/code><\/pre>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 WebSocket<\/h2>\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044f \u043f\u0443\u0442\u044c \u043d\u0430\u0448\u0435\u0439 \u0438\u0433\u0440\u044b, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c. \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438\u0433\u0440\u044b, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044f \u043f\u0435\u0440\u0435\u0434 \u044d\u0442\u0438\u043c \u043d\u0430\u0448\u0443 \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c &#171;Vlad&#187;.<\/p>\n<pre><code class=\"java\">@Component public class GameWebSocketHandler implements WebSocketHandler {      private final ObjectMapper objectMapper = new ObjectMapper();     private final Sinks.Many&lt;String&gt; gameStateSink = Sinks.many().multicast().directBestEffort();     private final GameStateManager gameStateManager = SomWorldApplication.gameStateManager;      public GameWebSocketHandler() {         initializeGameState();         startGameLoop();     }      private void initializeGameState() {         gameStateManager.spawnCreature(\"Vlad\");     }      private void startGameLoop() {         Flux.interval(Duration.ofMillis(16)) \/\/ ~60 FPS                 .subscribe(tick -&gt; {                     gameStateManager.updateGameState();                     broadcastGameState();                 });     }     private void broadcastGameState() {         try {             String jsonState = objectMapper.writeValueAsString(gameStateManager.getGameState());             gameStateSink.tryEmitNext(jsonState);         } catch (JsonProcessingException e) {             System.err.println(\"Error serializing game state: \" + e.getMessage());         }     }      @Override     public Mono&lt;Void&gt; handle(WebSocketSession session) {         \/\/ 1. \u041f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f         Flux&lt;WebSocketMessage&gt; output = gameStateSink.asFlux()                 .map(session::textMessage);          \/\/ 2. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439         Mono&lt;Void&gt; input = session.receive()                 .map(WebSocketMessage::getPayloadAsText)                 .doOnNext(message -&gt; {                     System.out.println(\"Received from client: \" + message);                 })                 .then();          return session.send(output).and(input);     } }<\/code><\/pre>\n<pre><code class=\"java\">@Configuration public class WebSocketConfig {      @Bean     public HandlerMapping webSocketMapping(GameWebSocketHandler handler) {         Map&lt;String, WebSocketHandler&gt; map = new HashMap&lt;&gt;();         map.put(\"\/game\", handler);         SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();         mapping.setOrder(-1);         mapping.setUrlMap(map);         return mapping;     }      @Bean     public WebSocketHandlerAdapter handlerAdapter() {         return new WebSocketHandlerAdapter();     }      @Bean     public WebSocketClient webSocketClient() {         return new ReactorNettyWebSocketClient();     } } <\/code><\/pre>\n<h2>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043b\u0438\u0435\u043d\u0442<\/h2>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 HTML-\u043c\u0430\u043a\u0435\u0442 \u0441 canvas \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432 \u0438 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 JS \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0441\u043e\u043a\u0435\u0442\u0443 \u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u0438\u0433\u0440\u044b<\/p>\n<pre><code class=\"xml\">&lt;div id=\"game-container\"&gt;     &lt;canvas id=\"gameCanvas\"&gt;&lt;\/canvas&gt;     &lt;div id=\"ui\"&gt;         &lt;span id=\"connection-status\"&gt;&lt;\/span&gt;         &lt;span id=\"status-text\"&gt;\u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435...&lt;\/span&gt;     &lt;\/div&gt;     &lt;div id=\"creature-name\" style=\"position:absolute; display:none; background:#fff; padding:4px 8px; border-radius:4px; box-shadow:0 2px 5px rgba(0,0,0,0.2); font-size:14px; pointer-events:none;\"&gt;&lt;\/div&gt; &lt;\/div&gt;<\/code><\/pre>\n<pre><code class=\"javascript\">    function connect() {         const wsProtocol = window.location.protocol === 'https:' ? 'wss:\/\/' : 'ws:\/\/';         const serverUrl = wsProtocol + window.location.host + '\/game';          socket = new WebSocket(serverUrl);<\/code><\/pre>\n<pre><code class=\"javascript\">sortedCreatures.forEach(creature =&gt; {             const creatureImage = new Image();             creatureImage.src = creature.picture;              const x = creature.x * canvas.width \/ 800;             const y = creature.y * canvas.height \/ 600;             const size = 10 * Math.min(canvas.width \/ 800, canvas.height \/ 600);             const imgSize = size * 8; \/\/ \u041f\u043e\u0434\u0431\u0435\u0440\u0438\u0442\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u043f\u043e\u0434 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435              \/\/ drawImage(image, dx, dy, dWidth, dHeight)             \/\/ dx \u0438 dy \u2014 \u044d\u0442\u043e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b, \u0433\u0434\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c             const shadow = new Image();             shadow.src = \"shadow.png\";             loadImage(shadow.src).then(img =&gt; {                 ctx.drawImage(img, x - imgSize \/ 2, y - imgSize \/ 2, imgSize, imgSize);             });             loadImage(creatureImage.src).then(img =&gt; {                 ctx.drawImage(img, x - imgSize \/ 2, y - imgSize \/ 2, imgSize, imgSize);                 });             });<\/code><\/pre>\n<h2>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c<\/h2>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b10\/78d\/0fc\/b1078d0fc1c455f69adb76a4199c2d39.png\" alt=\"\u0417\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442 \u0441 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0430\u043c\u0438, \u0430\u0432\u0442\u043e\u0440\u0441\u0442\u0432\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u043c\u043e\u0435\u0439 \u043b\u044e\u0431\u0438\u043c\u043e\u0439 \u0436\u0435\u043d\u0435\" title=\"\u0417\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442 \u0441 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0430\u043c\u0438, \u0430\u0432\u0442\u043e\u0440\u0441\u0442\u0432\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u043c\u043e\u0435\u0439 \u043b\u044e\u0431\u0438\u043c\u043e\u0439 \u0436\u0435\u043d\u0435\" width=\"1347\" height=\"641\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/b10\/78d\/0fc\/b1078d0fc1c455f69adb76a4199c2d39.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b10\/78d\/0fc\/b1078d0fc1c455f69adb76a4199c2d39.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0417\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442 \u0441 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0430\u043c\u0438, \u0430\u0432\u0442\u043e\u0440\u0441\u0442\u0432\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u043c\u043e\u0435\u0439 \u043b\u044e\u0431\u0438\u043c\u043e\u0439 \u0436\u0435\u043d\u0435<\/figcaption><\/div>\n<\/figure>\n<details class=\"spoiler\">\n<summary>\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043b\u044e\u0431\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 GameState \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0432 Creature \u0431\u0443\u0434\u0443\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u044b \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435. \u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u044f \u0443\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u043b \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c, \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u0435\u043b\u043e\u0447\u0438.<\/p>\n<\/div>\n<\/details>\n<h2>\u0412\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0445\u0430\u043e\u0441\u0430 \u0438 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u0418\u0418<\/h2>\n<p>\u0412 \u043f\u0443\u0441\u0442\u043e\u043c \u043c\u0438\u0440\u0435, \u0433\u0434\u0435 \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u043a\u0440\u043e\u043c\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432, \u043e\u0447\u0435\u043d\u044c \u0441\u043b\u043e\u0436\u043d\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u043e\u0431\u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0446\u0435\u043b\u044c. \u042f \u0440\u0435\u0448\u0438\u043b \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u043f\u0435\u0440\u0432\u043e\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0443 \u0441\u0432\u043e\u0435\u0433\u043e \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0438 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0432 \u043d\u0451\u043c \u0441\u0442\u0430\u0432\u044f\u0442 \u0441\u0435\u0431\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0435\u0439 \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u043d\u0438 \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 <strong>\u2014<\/strong> \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044f. <\/p>\n<p>\u0411\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0418\u0418 (\u043f\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 <strong>Q-learning<\/strong>) \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f, \u043f\u044b\u0442\u0430\u044f\u0441\u044c \u0432\u043d\u0443\u0448\u0438\u0442\u044c \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044e, \u0447\u0442\u043e \u0442\u043e\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u043a\u043b\u0438\u043a\u043d\u0443\u0442\u044c \u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432.<\/p>\n<blockquote>\n<p><strong>Q-learning <\/strong>\u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u043e\u0433\u043e \u043e\u0442 \u0441\u0440\u0435\u0434\u044b \u0432\u043e\u0437\u043d\u0430\u0433\u0440\u0430\u0436\u0434\u0435\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0441\u0442\u0438 Q, \u0447\u0442\u043e \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0434\u0430\u0451\u0442 \u0435\u043c\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u0436\u0435 \u043d\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f, \u0430 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u043f\u044b\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u043e \u0441\u0440\u0435\u0434\u043e\u0439.<\/p>\n<\/blockquote>\n<h2>\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430<\/h2>\n<ol>\n<li>\n<p>\u041a\u0430\u0436\u0434\u043e\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u043c stress, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0451\u043d\u043d\u044b\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0437\u0430 \u0448\u0430\u0433.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u0436\u0434\u043e\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u043c dopamine_layers, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u043d\u0430 1 \u043a\u0430\u0436\u0434\u044b\u0439 \u0448\u0430\u0433 (\u043d\u043e \u043d\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 0), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u0442 stress \u043d\u0430 \u0441\u0432\u043e\u0451 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 stress &lt; 0, \u0442\u043e \u043e\u043d \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f 50, \u043d\u043e \u043d\u0430 \u043f\u043e\u043b\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u043e\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e. (\u0418\u0418 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u0430\u0433\u0440\u0430\u0434\u0443)<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 stress &gt; 100, \u0442\u043e \u043e\u043d\u043e \u043f\u0440\u043e\u043f\u0430\u0434\u0430\u0435\u0442. (\u0418\u0418 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0448\u0442\u0440\u0430\u0444)<\/p>\n<\/li>\n<li>\n<p>\u041a\u043b\u0438\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0435\u0433\u043e dopamine_layers. (\u0418\u0418 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u0430\u0433\u0440\u0430\u0434\u0443)<\/p>\n<\/li>\n<\/ol>\n<h2>\u0418\u0442\u043e\u0433 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u043e\u043f\u044b\u0442\u043a\u0438<\/h2>\n<p>\u041a\u0430\u0436\u0434\u043e\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0441\u0435\u0431\u0435 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 (10% &#8212; \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0439; 90% &#8212; \u0441\u0430\u043c\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439)  \u043d\u0430 100 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0448\u0430\u0433\u043e\u0432, \u043d\u0430\u0433\u0440\u0430\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u0437\u0430 \u044d\u0442\u0438 \u0448\u0430\u0433\u0438, \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0433\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430.<\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043d\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u043b\u0438 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0441\u043e\u0432\u0441\u0435\u043c, \u043a\u0440\u043e\u043c\u0435 \u0442\u0435\u0445 \u0440\u0430\u0437\u043e\u0432, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u043b \u0443 \u043d\u0438\u0445 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u0412 \u043e\u0434\u043d\u043e \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u044f \u043a\u043b\u0438\u043a\u043d\u0443\u043b \u043f\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443 \u0438 \u044d\u0442\u043e \u0432\u044b\u0437\u0432\u0430\u043b\u043e \u0440\u0435\u0430\u043a\u0446\u0438\u044e \u0443 \u0432\u0441\u0435\u0433\u043e \u043f\u043b\u0435\u043c\u0435\u043d\u0438. \u041c\u043e\u0451 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u044f\u0432\u043d\u043e \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u043b\u043e \u0431\u044b \u043e\u0434\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u043d\u0435\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435, \u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0437\u0430 \u043d\u0438\u043c \u043f\u043e\u0441\u043b\u0435 \u043a\u043b\u0438\u043a\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 <strong>\u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0432\u0430\u043b.<\/strong><\/p>\n<p>\u042f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043b \u043d\u0430\u0433\u0440\u0430\u0434\u044b, \u0430 \u043f\u043e\u0442\u043e\u043c \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0432 \u043b\u0438\u0448\u044c \u043f\u0430\u0440\u0443 \u043a\u043b\u0438\u043a\u043e\u0432 \u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432, \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0445\u043e\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u043b\u043e \u043c\u043e\u0451 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u044f \u0437\u0430\u043c\u0435\u0442\u0438\u043b, \u0447\u0442\u043e \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043d\u0430\u0447\u0430\u043b\u0438 \u0440\u0435\u0436\u0435, \u043d\u043e \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f. <\/p>\n<p>\u0422\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435, \u043d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u044f \u0443\u0436\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u043b, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0418\u0418 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0438\u0440\u0443\u0435\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e, \u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u0442 \u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438 (\u0413\u0438\u043f\u043e\u0442\u0435\u0437\u0430 \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u0432\u0435\u0440\u043d\u0430, \u0432\u0435\u0434\u044c \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0435\u0440\u0435\u0448\u0451\u043b \u043a \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043d\u043e\u0432\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.<\/p>\n<h2>\u0412\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430 (\u041a\u043e\u043b\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0440\u0430\u0437\u0443\u043c)<\/h2>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043f\u0443\u0442\u0438, \u0437\u0434\u0435\u0441\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043e\u0441\u044c x, y, t.<\/p>\n<pre><code class=\"java\">boolean[][][] path = new boolean[1600][900][100];   boolean[][][] path = new boolean[80][45][600]; \/\/\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438<\/code><\/pre>\n<blockquote>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 (\u0447\u0438\u0441\u043b\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0445 \u044f\u0447\u0435\u0435\u043a \u0440\u0430\u0432\u043d\u044f\u0435\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u0443 \u0441\u0443\u0449\u0435\u0441\u0442\u0432), \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0447\u0431 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 80 \u043d\u0430 45 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430 (\u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c 600 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445). \u0410 \u0434\u0430\u043b\u044c\u0448\u0435 \u043e\u0431\u0449\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0430\u044f \u0418\u0418, \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u044b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0430.<\/p>\n<\/blockquote>\n<h2>\u0418\u0442\u043e\u0433 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 2\u0430<\/h2>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/685\/a47\/47d\/685a4747d4fe4fe5570d4ed3e42d4bfe.png\" width=\"1360\" height=\"649\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/685\/a47\/47d\/685a4747d4fe4fe5570d4ed3e42d4bfe.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/685\/a47\/47d\/685a4747d4fe4fe5570d4ed3e42d4bfe.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041f\u0435\u0440\u0432\u044b\u0435 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u044b\u043b\u0438 \u043f\u043e\u0445\u043e\u0436\u0438 \u043d\u0430 \u0447\u0442\u043e-\u0442\u043e \u0442\u0430\u043a\u043e\u0435: \u0441\u0443\u0449\u0435\u0441\u0442\u0432 \u0440\u0430\u0437\u0431\u0440\u043e\u0441\u0430\u043b\u043e \u043d\u0430 \u043a\u0440\u0430\u044f \u044d\u043a\u0440\u0430\u043d\u0430, \u0447\u0442\u043e \u044f \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043f\u043e\u043e\u0449\u0440\u044f\u043b. \u041d\u0430\u0433\u0440\u0430\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043a\u043b\u0438\u043a\u0430\u043c\u0438 \u0431\u044b\u043b\u043e \u0437\u0434\u0435\u0441\u044c \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u0443\u043c\u0435\u0441\u0442\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u043e \u0431\u044b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043e\u0432 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0445\u043e\u0442\u044c \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0432\u043d\u044f\u0442\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432.<\/p>\n<p>\u041c\u043d\u043e\u044e \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0433\u0430\u0440\u043c\u043e\u043d\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u044f, \u0442\u0435\u043f\u0435\u0440\u044c \u044f \u043f\u043e\u043e\u0449\u0440\u044f\u043b \u0418\u0418 \u0437\u0430 \u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0443\u0437\u043e\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0432 \u0441\u0438\u043b\u0430\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c (\u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c, \u0438\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043e\u0442 \u0441\u043b\u043e\u044f \u0434\u043e \u0441\u043b\u043e\u044f). \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u043b\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u043d\u0430 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442 \u0432\u0442\u043e\u0440\u043e\u0439, \u0442\u043e \u0418\u0418 \u0448\u0442\u0440\u0430\u0444\u043e\u0432\u0430\u043b\u0441\u044f.<\/p>\n<h2>\u0418\u0442\u043e\u0433 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 2\u0431<\/h2>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u0438\u0432\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0441\u0435\u0431\u0435 \u0443\u0433\u043e\u043b \u0443 \u043d\u0443\u043b\u0435\u0432\u044b\u0445 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0438 \u043d\u0430\u0447\u0430\u043b\u0438 \u0432\u043e\u0434\u0438\u0442\u044c \u0442\u0430\u043c &#171;\u0445\u043e\u0440\u043e\u0432\u043e\u0434&#187;. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432 \u0441\u0442\u043e\u0438\u0442 \u0431\u0435\u0437 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0438 \u043e\u0447\u043a\u043e\u0432, \u0438 \u043b\u0438\u0448\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u043d\u0438\u0445 \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0443\u0437\u043e\u0440. \u0412 \u043c\u043e\u0451\u043c \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0438 \u044d\u0442\u043e \u0431\u044b\u043b \u0443\u0436\u0435 \u0445\u043e\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0443\u0441\u043f\u0435\u0445.<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e82\/5d2\/e21\/e825d2e219d72855aa99f0a42d6135c1.png\" width=\"455\" height=\"345\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/e82\/5d2\/e21\/e825d2e219d72855aa99f0a42d6135c1.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e82\/5d2\/e21\/e825d2e219d72855aa99f0a42d6135c1.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<div class=\"floating-image\">\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9c0\/212\/b6a\/9c0212b6ae0fee1097c5997e72814e68.png\" width=\"482\" height=\"362\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/9c0\/212\/b6a\/9c0212b6ae0fee1097c5997e72814e68.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9c0\/212\/b6a\/9c0212b6ae0fee1097c5997e72814e68.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/286\/42a\/5dc\/28642a5dc0b3e930f0cd5d6d1d97b068.png\" width=\"471\" height=\"346\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/286\/42a\/5dc\/28642a5dc0b3e930f0cd5d6d1d97b068.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/286\/42a\/5dc\/28642a5dc0b3e930f0cd5d6d1d97b068.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/279\/951\/8a7\/2799518a7b51b1b2dcf5ec62ac0f36a7.png\" width=\"459\" height=\"355\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/279\/951\/8a7\/2799518a7b51b1b2dcf5ec62ac0f36a7.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/279\/951\/8a7\/2799518a7b51b1b2dcf5ec62ac0f36a7.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<\/div>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1ae\/e61\/f1a\/1aee61f1ac059720484130247db89f6a.png\" width=\"397\" height=\"357\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/1ae\/e61\/f1a\/1aee61f1ac059720484130247db89f6a.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1ae\/e61\/f1a\/1aee61f1ac059720484130247db89f6a.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h2>\u0422\u0440\u0435\u0442\u044c\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430 (\u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u0442\u043e\u0440\u043e\u0439)<\/h2>\n<p>\u042f \u043d\u0430\u0447\u0430\u043b \u0448\u0442\u0440\u0430\u0444\u043e\u0432\u0430\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432 \u0437\u0430 \u0431\u0435\u0437\u0434\u0435\u043b\u044c\u0435, \u043c\u043d\u0435 \u0431\u044b\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0430 \u043d\u0435 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043d\u0441\u0435\u0439\u0432\u0435\u0440 \u0432 \u0432\u0438\u0434\u0435 \u0436\u0451\u043b\u0442\u043e-\u0441\u0438\u043d\u0435\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438. \u0410 \u0435\u0449\u0451 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u044f\u0432\u043b\u044f\u043b\u0438\u0441\u044c \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u044f\u0445 \u044d\u043a\u0440\u0430\u043d\u0430, \u0447\u0442\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u0443 \u0418\u0418. <\/p>\n<h2>\u0418\u0442\u043e\u0433\u0438 \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u043f\u043e\u043f\u044b\u0442\u043a\u0438<\/h2>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8bb\/5d4\/2e7\/8bb5d42e71e179b89fd96ba811d59c9e.png\" width=\"780\" height=\"642\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/8bb\/5d4\/2e7\/8bb5d42e71e179b89fd96ba811d59c9e.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8bb\/5d4\/2e7\/8bb5d42e71e179b89fd96ba811d59c9e.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043d\u0435 \u043e\u0442\u0445\u043e\u0434\u0438\u043b\u0438 \u043e\u0442 \u0441\u0432\u043e\u0435\u0439 \u043f\u0440\u0438\u0432\u044b\u0447\u043a\u0438 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043a\u0440\u0443\u0433\u0438, \u0438\u043c\u0435\u043d\u043d\u043e \u043a\u0440\u0443\u0433 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043b\u0430\u0432\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u0438\u0437 \u043e\u0434\u043d\u0438\u0445 \u0441\u043b\u043e\u0451\u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0432 \u0434\u0440\u0443\u0433\u0438\u0435.<\/p>\n<p>\u0418 \u0442\u0443\u0442 \u043c\u043d\u0435 \u0441\u0442\u0430\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442, \u0435\u0441\u043b\u0438 \u0438\u0445 \u0441\u0442\u0430\u043d\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435&#8230; \u044f \u043d\u0430\u0447\u0430\u043b \u043f\u043e\u043e\u0449\u0440\u044f\u0442\u044c \u0418\u0418 \u043a\u043b\u0438\u043a\u0430\u043c\u0438.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e47\/52d\/c39\/e4752dc39ecf3e66ad6e6a6677a7c2e0.png\" width=\"1308\" height=\"649\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/e47\/52d\/c39\/e4752dc39ecf3e66ad6e6a6677a7c2e0.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e47\/52d\/c39\/e4752dc39ecf3e66ad6e6a6677a7c2e0.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u043e\u0441\u044c \u0431\u043e\u043b\u044c\u0448\u0435, \u043d\u043e \u0443\u0437\u043e\u0440 \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b \u043a \u0441\u0432\u043e\u0435\u043c\u0443 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e\/\u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u043d\u0438\u044e.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/019\/fc4\/851\/019fc4851d049dfd5c82b5d90dc62b1b.png\" width=\"782\" height=\"634\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/019\/fc4\/851\/019fc4851d049dfd5c82b5d90dc62b1b.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/019\/fc4\/851\/019fc4851d049dfd5c82b5d90dc62b1b.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u042f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u043b \u043a\u043b\u0438\u043a\u0430\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0434\u0435\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/315\/fd2\/a33\/315fd2a338b928b02352d56048d9991d.png\" width=\"768\" height=\"645\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/315\/fd2\/a33\/315fd2a338b928b02352d56048d9991d.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/315\/fd2\/a33\/315fd2a338b928b02352d56048d9991d.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0423\u0437\u043e\u0440 \u043d\u0430\u0447\u0430\u043b \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043e\u0447\u0435\u0440\u0442\u0430\u043d\u0438\u0435 \u0434\u0435\u0432\u044f\u0442\u043a\u0438, \u0432\u043e\u0441\u044c\u043c\u0451\u0440\u043a\u0438 \u0438\u043b\u0438 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u0439 \u0431\u0443\u043a\u0432\u044b S<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b12\/c3d\/685\/b12c3d68590f9a41be64f0080ebc3dc9.png\" width=\"714\" height=\"637\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/b12\/c3d\/685\/b12c3d68590f9a41be64f0080ebc3dc9.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b12\/c3d\/685\/b12c3d68590f9a41be64f0080ebc3dc9.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0421 \u043a\u0430\u0436\u0434\u044b\u043c \u043d\u043e\u0432\u044b\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u044f \u0441\u043a\u043b\u043e\u043d\u044f\u043b\u0441\u044f \u043a \u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0443 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0433\u043e \u0443\u0437\u043e\u0440\u0430, \u043d\u043e&#8230; \u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0442.<\/p>\n<h2>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0431\u0435\u0434\u0438\u043b<\/h2>\n<p>\u041e\u043f\u0438\u0441\u044b\u0432\u0430\u044f \u043f\u0435\u0440\u0432\u044b\u0435 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u043b\u043e\u0432\u0430:<\/p>\n<blockquote>\n<p>\u0411\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0418\u0418 (\u043f\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 <strong>Q-learning<\/strong>) \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f, \u043f\u044b\u0442\u0430\u044f\u0441\u044c \u0432\u043d\u0443\u0448\u0438\u0442\u044c \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044e, \u0447\u0442\u043e \u0442\u043e\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u043a\u043b\u0438\u043a\u043d\u0443\u0442\u044c \u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432.<\/p>\n<\/blockquote>\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 \u043c\u043d\u043e\u044e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u043b \u043c\u0430\u0442\u0440\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0451\u0442, \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043d\u0430 \u043d\u0438\u0445 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c. <\/p>\n<p>\u0412\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0442\u043e\u043f-3 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043f\u043e \u0447\u0430\u0441\u0442\u043e\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c:<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/45b\/e9a\/491\/45be9a491be550bf24011fae04538022.png\" width=\"406\" height=\"266\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/45b\/e9a\/491\/45be9a491be550bf24011fae04538022.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/45b\/e9a\/491\/45be9a491be550bf24011fae04538022.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f4c\/65d\/3a7\/f4c65d3a7964c767b40a474580ea34dd.png\" width=\"378\" height=\"284\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/f4c\/65d\/3a7\/f4c65d3a7964c767b40a474580ea34dd.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f4c\/65d\/3a7\/f4c65d3a7964c767b40a474580ea34dd.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/148\/7bf\/28c\/1487bf28c7f0cc46859ec1273c3fd6e3.png\" alt=\"\u041f\u043e\u043b\u043e\u0432\u0438\u043d\u043a\u0430 \u0441\u0435\u0440\u0434\u0446\u0430?\" title=\"\u041f\u043e\u043b\u043e\u0432\u0438\u043d\u043a\u0430 \u0441\u0435\u0440\u0434\u0446\u0430?\" width=\"357\" height=\"303\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/148\/7bf\/28c\/1487bf28c7f0cc46859ec1273c3fd6e3.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/148\/7bf\/28c\/1487bf28c7f0cc46859ec1273c3fd6e3.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041f\u043e\u043b\u043e\u0432\u0438\u043d\u043a\u0430 \u0441\u0435\u0440\u0434\u0446\u0430?<\/figcaption><\/div>\n<\/figure>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043b \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0441 \u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u043c\u0438 \u043b\u0438\u043d\u0438\u044f\u043c\u0438, \u043e\u0434\u043d\u0430\u043a\u043e \u0438\u0437-\u0437\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432, \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u043b\u0438\u0441\u044c \u0431\u0443\u0434\u0442\u043e \u0431\u044b \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u0435 \u0443\u0437\u043e\u0440\u044b, \u043d\u043e  \u0434\u043b\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f\u043a\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u043c\u0430\u043b\u043e \u044e\u043d\u0438\u0442\u043e\u0432. \u042d\u0442\u043e\u0442 \u044d\u0444\u0444\u0435\u043a\u0442 \u0438 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b \u043c\u0435\u043d\u044f \u043f\u043e\u0441\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044e \u0447\u0438\u0441\u043b\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041c\u043e\u0439 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u043f\u043e\u0434\u043e\u0448\u0451\u043b \u043a\u00a0\u043a\u043e\u043d\u0446\u0443, \u044f \u043e\u0436\u0438\u0434\u0430\u043b, \u0447\u0442\u043e\u00a0\u043d\u0430\u0443\u0447\u0443 \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0418\u0418\u2011\u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044e \u043f\u0440\u0438\u0447\u0443\u0434\u043b\u0438\u0432\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0438\u043b\u0438\u00a0\u0444\u0440\u0430\u043a\u0442\u0430\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u043a\u0440\u0430\u0441\u044f\u0442 \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e, \u0438 \u0442\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e\u00a0\u0431\u044b\u043b\u043e\u00a0\u0431\u044b \u0441\u043a\u0430\u0437\u0430\u0442\u044c: \u00ab\u042f \u0441\u043e\u0437\u0434\u0430\u043b \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432 \u0438 \u043d\u0430\u00a0\u043d\u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u0435\u0447\u043d\u043e\u00bb, \u0445\u043e\u0442\u044f \u043d\u0430\u00a0\u0434\u0435\u043b\u0435 \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u044f \u043e\u0431\u043c\u0430\u043d\u0443\u043b \u0441\u0430\u043c \u0441\u0435\u0431\u044f, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432\u00a0\u0431\u0435\u0441\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u043d\u043e\u043c \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0438 \u0436\u0451\u043b\u0442\u044b\u0445 \u0434\u0443\u0440\u0430\u0447\u043a\u043e\u0432.<\/p>\n<p>\u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e\u00a0\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u044b, \u0438\u0437\u043c\u0435\u043d\u0438\u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0438\u0433\u0440\u044b \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043d\u043e\u0432\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u0432\u0430\u0448\u0438\u043c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c \u0432\u00a0\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/912934\/\"> https:\/\/habr.com\/ru\/articles\/912934\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u042d\u0442\u043e \u043c\u043e\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u043f\u0440\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u0435\u0442-\u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>\u041e\u0442\u043a\u0443\u0434\u0430 \u0440\u0430\u0441\u0442\u0443\u0442 \u043d\u043e\u0433\u0438: \u042f \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b 4 \u044d\u043f\u0438\u0437\u043e\u0434 7 \u0441\u0435\u0437\u043e\u043d\u0430 \u0441\u0435\u0440\u0438\u0430\u043b\u0430 \u00ab\u0427\u0451\u0440\u043d\u043e\u0435 \u0437\u0435\u0440\u043a\u0430\u043b\u043e\u00bb, \u0433\u0434\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u0430\u044f \u0438\u0433\u0440\u0430 \u0441 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u043e\u043c, \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u043c\u0438\u0440\u043e\u043c \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u043b\u0441\u044f \u043c\u0435\u043b\u044c\u043a\u0430\u043d\u0438\u0435\u043c \u043d\u0430 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0435 \u0438 \u0438\u0437\u0434\u0430\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0442\u0438\u0447\u044c\u0438\u0445 (\u0441\u043a\u043e\u0440\u0435\u0435 \u0442\u0440\u0443\u0431\u043d\u044b\u0445) \u0437\u0432\u0443\u043a\u043e\u0432.<\/p>\n<figure class=\"full-width\"><\/figure>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0421 \u043f\u0440\u0438\u0445\u043e\u0434\u043e\u043c \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439, \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0438\u0434\u044b \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u0430 \u0442\u043e\u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u0432\u043e\u0451 \u043c\u0435\u0441\u0442\u043e \u043f\u043e\u0434 \u0441\u043e\u043b\u043d\u0446\u0435\u043c. \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0449\u0451 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u044b, \u0433\u0434\u0435 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442 \u0438\u0433\u0440\u0430\u0435\u0442 \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0438\u0433\u0440\u044b, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0447\u043a\u0438 \u0437\u0430 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0435 \u0446\u0435\u043b\u0435\u0439 \u0438 \u043e\u0431\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0432\u043e\u0438\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u0418\u0418 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0435\u043c\u0443 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u043c \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u043c \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c. \u042f \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0418\u0418 \u0441 \u0438\u0433\u0440\u043e\u0432\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e\u043c, \u0430 \u0443\u0436\u0435 \u043f\u043e\u0442\u043e\u043c \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0438\u0433\u0440\u0443 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438 \u0438 \u0441\u043c\u044b\u0441\u043b\u043e\u043c.<\/p>\n<h2>\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b<\/h2>\n<ul>\n<li>\n<p>Java<\/p>\n<\/li>\n<li>\n<p>Spring (WebFlux)<\/p>\n<\/li>\n<li>\n<p>JS + HTML<\/p>\n<\/li>\n<\/ul>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430<\/h2>\n<p>\u0413\u043b\u0430\u0432\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0431\u044b\u043b\u0430 \u0432\u0441\u0451 \u0436\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c &#171;\u0441\u0443\u0449\u0435\u0441\u0442\u0432&#187;. \u042f \u0434\u0430\u043b \u0438\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440, \u0438\u043c\u044f, \u0442\u0438\u043f, \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u0438 \u043d\u0435\u043a\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u043e \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0430 (\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e \u0442\u043e\u0447\u043a\u0438, \u043e\u0442\u0434\u044b\u0445) \u0438 \u0432\u0440\u0435\u043c\u044f, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u043d\u0430 \u044d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u0435\u0440\u0435\u0434 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u043c \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443.<\/p>\n<pre><code class=\"java\">    @Data     @AllArgsConstructor     @NoArgsConstructor     public static class Creature {         private int id;         private float x;         private float y;         private final String type = \"yellow\";         private CreatureState state;         private String name = \"Console\";         private String picture = Picture.IMAGE.toString();<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u043d\u043e\u0439 \u0431\u044b\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u043a\u043b\u0430\u0441\u0441 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438\u0433\u0440\u044b, \u0433\u0434\u0435 \u044f \u0441\u0430\u043c\u044b\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0432\u043a\u043b\u044e\u0447\u0438\u043b \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432 \u0438 \u0432\u043f\u0438\u0441\u0430\u043b \u043e\u0431\u044a\u0435\u043a\u0442-\u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434 \u0444\u043e\u043d\u0430 \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:<\/p>\n<pre><code class=\"java\">    @Data     @AllArgsConstructor     @NoArgsConstructor     public static class GameState {         private List&lt;Creature&gt; creatures;         private Environment environment;     }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0431\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u043d GameStateManager, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u044f \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u043b \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0441\u043f\u0430\u0432\u043d\u0430 \u043d\u043e\u0432\u044b\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438\u0433\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u043b\u0438\u0435\u043d\u0442.<\/p>\n<pre><code class=\"java\">    private final DataModels.GameState gameState;     public GameStateManager(DataModels.GameState gameState){         this.gameState = gameState;     }      private final Queue&lt;DataModels.Creature&gt; toSpawn = new ConcurrentLinkedDeque&lt;&gt;();      public void spawnCreature(String name){         toSpawn.add(new DataModels.Creature(name));     }      public void updateGameState() {         \/\/ \u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432         toSpawn.forEach(creature -&gt; gameState.getCreatures().add(creature));         toSpawn.clear();         gameState.getCreatures().forEach(creature -&gt; {             creature.setX(creature.getX() + creature.getState().getVectorX());             creature.setY(creature.getY() + creature.getState().getVectorY());             creature.getState().add();             creature.updateFrame();             if(creature.getState().getT() &gt; 1){                 \/\/\u041c\u0435\u043d\u044f\u0435\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435                 if((creature.getState().sx == creature.getState().fx) &amp;&amp;                         (creature.getState().sy == creature.getState().fy))                 {                     creature.updateState();                 }else{                     creature.setTimeout();                 }             }             \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0433\u0440\u0430\u043d\u0438\u0446             creature.setX(Math.max(0, Math.min(800, creature.getX())));             creature.setY(Math.max(0, Math.min(600, creature.getY())));         });     }<\/code><\/pre>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 WebSocket<\/h2>\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044f \u043f\u0443\u0442\u044c \u043d\u0430\u0448\u0435\u0439 \u0438\u0433\u0440\u044b, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c. \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438\u0433\u0440\u044b, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044f \u043f\u0435\u0440\u0435\u0434 \u044d\u0442\u0438\u043c \u043d\u0430\u0448\u0443 \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c &#171;Vlad&#187;.<\/p>\n<pre><code class=\"java\">@Component public class GameWebSocketHandler implements WebSocketHandler {      private final ObjectMapper objectMapper = new ObjectMapper();     private final Sinks.Many&lt;String&gt; gameStateSink = Sinks.many().multicast().directBestEffort();     private final GameStateManager gameStateManager = SomWorldApplication.gameStateManager;      public GameWebSocketHandler() {         initializeGameState();         startGameLoop();     }      private void initializeGameState() {         gameStateManager.spawnCreature(\"Vlad\");     }      private void startGameLoop() {         Flux.interval(Duration.ofMillis(16)) \/\/ ~60 FPS                 .subscribe(tick -&gt; {                     gameStateManager.updateGameState();                     broadcastGameState();                 });     }     private void broadcastGameState() {         try {             String jsonState = objectMapper.writeValueAsString(gameStateManager.getGameState());             gameStateSink.tryEmitNext(jsonState);         } catch (JsonProcessingException e) {             System.err.println(\"Error serializing game state: \" + e.getMessage());         }     }      @Override     public Mono&lt;Void&gt; handle(WebSocketSession session) {         \/\/ 1. \u041f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f         Flux&lt;WebSocketMessage&gt; output = gameStateSink.asFlux()                 .map(session::textMessage);          \/\/ 2. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439         Mono&lt;Void&gt; input = session.receive()                 .map(WebSocketMessage::getPayloadAsText)                 .doOnNext(message -&gt; {                     System.out.println(\"Received from client: \" + message);                 })                 .then();          return session.send(output).and(input);     } }<\/code><\/pre>\n<pre><code class=\"java\">@Configuration public class WebSocketConfig {      @Bean     public HandlerMapping webSocketMapping(GameWebSocketHandler handler) {         Map&lt;String, WebSocketHandler&gt; map = new HashMap&lt;&gt;();         map.put(\"\/game\", handler);         SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();         mapping.setOrder(-1);         mapping.setUrlMap(map);         return mapping;     }      @Bean     public WebSocketHandlerAdapter handlerAdapter() {         return new WebSocketHandlerAdapter();     }      @Bean     public WebSocketClient webSocketClient() {         return new ReactorNettyWebSocketClient();     } } <\/code><\/pre>\n<h2>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043a\u043b\u0438\u0435\u043d\u0442<\/h2>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 HTML-\u043c\u0430\u043a\u0435\u0442 \u0441 canvas \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432 \u0438 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 JS \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0441\u043e\u043a\u0435\u0442\u0443 \u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u0438\u0433\u0440\u044b<\/p>\n<pre><code class=\"xml\">&lt;div id=\"game-container\"&gt;     &lt;canvas id=\"gameCanvas\"&gt;&lt;\/canvas&gt;     &lt;div id=\"ui\"&gt;         &lt;span id=\"connection-status\"&gt;&lt;\/span&gt;         &lt;span id=\"status-text\"&gt;\u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435...&lt;\/span&gt;     &lt;\/div&gt;     &lt;div id=\"creature-name\" style=\"position:absolute; display:none; background:#fff; padding:4px 8px; border-radius:4px; box-shadow:0 2px 5px rgba(0,0,0,0.2); font-size:14px; pointer-events:none;\"&gt;&lt;\/div&gt; &lt;\/div&gt;<\/code><\/pre>\n<pre><code class=\"javascript\">    function connect() {         const wsProtocol = window.location.protocol === 'https:' ? 'wss:\/\/' : 'ws:\/\/';         const serverUrl = wsProtocol + window.location.host + '\/game';          socket = new WebSocket(serverUrl);<\/code><\/pre>\n<pre><code class=\"javascript\">sortedCreatures.forEach(creature =&gt; {             const creatureImage = new Image();             creatureImage.src = creature.picture;              const x = creature.x * canvas.width \/ 800;             const y = creature.y * canvas.height \/ 600;             const size = 10 * Math.min(canvas.width \/ 800, canvas.height \/ 600);             const imgSize = size * 8; \/\/ \u041f\u043e\u0434\u0431\u0435\u0440\u0438\u0442\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u043f\u043e\u0434 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435              \/\/ drawImage(image, dx, dy, dWidth, dHeight)             \/\/ dx \u0438 dy \u2014 \u044d\u0442\u043e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b, \u0433\u0434\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c             const shadow = new Image();             shadow.src = \"shadow.png\";             loadImage(shadow.src).then(img =&gt; {                 ctx.drawImage(img, x - imgSize \/ 2, y - imgSize \/ 2, imgSize, imgSize);             });             loadImage(creatureImage.src).then(img =&gt; {                 ctx.drawImage(img, x - imgSize \/ 2, y - imgSize \/ 2, imgSize, imgSize);                 });             });<\/code><\/pre>\n<h2>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c<\/h2>\n<figure class=\"full-width\">\n<div><figcaption>\u0417\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442 \u0441 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0430\u043c\u0438, \u0430\u0432\u0442\u043e\u0440\u0441\u0442\u0432\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u043c\u043e\u0435\u0439 \u043b\u044e\u0431\u0438\u043c\u043e\u0439 \u0436\u0435\u043d\u0435<\/figcaption><\/div>\n<\/figure>\n<details class=\"spoiler\">\n<summary>\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043b\u044e\u0431\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 GameState \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0432 Creature \u0431\u0443\u0434\u0443\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u044b \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435. \u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u044f \u0443\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u043b \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c, \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u0435\u043b\u043e\u0447\u0438.<\/p>\n<\/div>\n<\/details>\n<h2>\u0412\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0445\u0430\u043e\u0441\u0430 \u0438 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u0418\u0418<\/h2>\n<p>\u0412 \u043f\u0443\u0441\u0442\u043e\u043c \u043c\u0438\u0440\u0435, \u0433\u0434\u0435 \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u043a\u0440\u043e\u043c\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432, \u043e\u0447\u0435\u043d\u044c \u0441\u043b\u043e\u0436\u043d\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u043e\u0431\u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0446\u0435\u043b\u044c. \u042f \u0440\u0435\u0448\u0438\u043b \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u043f\u0435\u0440\u0432\u043e\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0443 \u0441\u0432\u043e\u0435\u0433\u043e \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0438 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0432 \u043d\u0451\u043c \u0441\u0442\u0430\u0432\u044f\u0442 \u0441\u0435\u0431\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0435\u0439 \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u043d\u0438 \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 <strong>\u2014<\/strong> \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430-\u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044f. <\/p>\n<p>\u0411\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0418\u0418 (\u043f\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 <strong>Q-learning<\/strong>) \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f, \u043f\u044b\u0442\u0430\u044f\u0441\u044c \u0432\u043d\u0443\u0448\u0438\u0442\u044c \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044e, \u0447\u0442\u043e \u0442\u043e\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u043a\u043b\u0438\u043a\u043d\u0443\u0442\u044c \u043d\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432.<\/p>\n<blockquote>\n<p><strong>Q-learning <\/strong>\u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u043e\u0433\u043e \u043e\u0442 \u0441\u0440\u0435\u0434\u044b \u0432\u043e\u0437\u043d\u0430\u0433\u0440\u0430\u0436\u0434\u0435\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0441\u0442\u0438 Q, \u0447\u0442\u043e \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0434\u0430\u0451\u0442 \u0435\u043c\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u0436\u0435 \u043d\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f, \u0430 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u043f\u044b\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u043e \u0441\u0440\u0435\u0434\u043e\u0439.<\/p>\n<\/blockquote>\n<h2>\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0430<\/h2>\n<ol>\n<li>\n<p>\u041a\u0430\u0436\u0434\u043e\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u043c stress, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0451\u043d\u043d\u044b\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0437\u0430 \u0448\u0430\u0433.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u0436\u0434\u043e\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u043c dopamine_layers, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u043d\u0430 1 \u043a\u0430\u0436\u0434\u044b\u0439 \u0448\u0430\u0433 (\u043d\u043e \u043d\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 0), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u0442 stress \u043d\u0430 \u0441\u0432\u043e\u0451 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 stress &lt; 0, \u0442\u043e \u043e\u043d \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f 50, \u043d\u043e \u043d\u0430 \u043f\u043e\u043b\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u043e\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e. (\u0418\u0418 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u0430\u0433\u0440\u0430\u0434\u0443)<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 stress &gt; 100, \u0442\u043e \u043e\u043d\u043e \u043f\u0440\u043e\u043f\u0430\u0434\u0430\u0435\u0442. (\u0418\u0418 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0448\u0442\u0440\u0430\u0444)<\/p>\n<\/li>\n<li>\n<p>\u041a\u043b\u0438\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0435\u0433\u043e dopamine_layers. (\u0418\u0418 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u0430\u0433\u0440\u0430\u0434\u0443)<\/p>\n<\/li>\n<\/ol>\n<h2>\u0418\u0442\u043e\u0433 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u043e\u043f\u044b\u0442\u043a\u0438<\/h2>\n<p>\u041a\u0430\u0436\u0434\u043e\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0441\u0435\u0431\u0435 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 (10% &#8212; \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0439; 90% &#8212; \u0441\u0430\u043c\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439)  \u043d\u0430 100 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0448\u0430\u0433\u043e\u0432, \u043d\u0430\u0433\u0440\u0430\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u0437\u0430 \u044d\u0442\u0438 \u0448\u0430\u0433\u0438, \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0433\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430.<\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043d\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u043b\u0438 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0441\u043e\u0432\u0441\u0435\u043c, \u043a\u0440\u043e\u043c\u0435 \u0442\u0435\u0445 \u0440\u0430\u0437\u043e\u0432, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u043b \u0443 \u043d\u0438\u0445 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u0412 \u043e\u0434\u043d\u043e \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 <\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-461089","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/461089","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=461089"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/461089\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=461089"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=461089"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=461089"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}