{"id":481485,"date":"2026-05-29T03:51:33","date_gmt":"2026-05-29T03:51:33","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=481485"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=481485","title":{"rendered":"\u041a\u0430\u043a \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0442\u044c 10 000 NPC \u0432 \u043a\u0430\u0434\u0440\u0435 \u0431\u0435\u0437 \u043f\u0440\u043e\u0441\u0430\u0434\u043e\u043a GC"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>\u0412 \u0434\u0432\u0443\u0445 \u0441\u043b\u043e\u0432\u0430\u0445 \u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0435<\/h3>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u044b \u0434\u0435\u043b\u0430\u0435\u0442\u0435 \u0441\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u044e \u0433\u043e\u0440\u043e\u0434\u0430. \u0418\u043b\u0438 RTS. \u0418\u043b\u0438 RPG \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u043c\u0438\u0440\u043e\u043c. \u0418 \u0443 \u0432\u0430\u0441 \u0432 \u0441\u0446\u0435\u043d\u0435 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f 5, 10, \u0430 \u0442\u043e \u0438 20 \u0442\u044b\u0441\u044f\u0447 \u0436\u0438\u0432\u044b\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432. \u0423 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0432\u043e\u0438 \u0446\u0435\u043b\u0438, \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u044b, \u044d\u043c\u043e\u0446\u0438\u0438, \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u044f\u0437\u0438.<\/p>\n<p>\u0412\u0430\u0448\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 AI \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0442\u0440\u0435\u0449\u0430\u0442\u044c \u043f\u043e \u0448\u0432\u0430\u043c.<\/p>\n<p>\u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u2014 \u0434\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u043c\u0443 NPC \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>Update()<\/code> \u2014 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0451\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0433\u0434\u0435-\u0442\u043e \u043f\u043e\u0441\u043b\u0435 500\u20131000 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0414\u0430\u043b\u044c\u0448\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b:<\/p>\n<ul>\n<li>\n<p>10 000 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0437\u0430 \u043a\u0430\u0434\u0440 \u2192 \u043f\u0440\u043e\u043c\u0430\u0445\u0438 \u043a\u044d\u0448\u0430 \u0438 \u0434\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>LINQ-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u0432\u0440\u0430\u0433\u0430 \u2192 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u0438 GC.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0441\u0447\u0451\u0442 \u044d\u043c\u043e\u0446\u0438\u0439 \u043f\u043e \u043f\u043e\u043b\u043d\u043e\u043c\u0443 \u0433\u0440\u0430\u0444\u0443 \u2192 O(N\u00b2) \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0432\u0441\u0435\u0445 NPC \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0442\u043e\u043f-10 \u2192 \u043f\u0443\u0441\u0442\u0430\u044f \u0442\u0440\u0430\u0442\u0430 O(N log N) \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u0430\u0448\u0438 60 FPS \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u0432 30, \u0430 \u043f\u043e\u0442\u043e\u043c \u0432 15. \u0418\u0433\u0440\u043e\u043a\u0438 \u0436\u0430\u043b\u0443\u044e\u0442\u0441\u044f \u043d\u0430 \u0444\u0440\u0438\u0437\u044b (\u044d\u0442\u043e GC \u0441\u043e\u0431\u0440\u0430\u043b 20 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432). \u0412\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0435 \u043d\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u0430 \u043f\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 AI.<\/p>\n<p>\u042d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u044b.<\/p>\n<h3>\u0427\u0442\u043e \u043b\u0435\u0436\u0438\u0442 \u0432 \u043a\u043e\u0440\u043e\u0431\u043a\u0435<\/h3>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 GameAI.Net \u2014 \u044d\u0442\u043e \u043d\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a. \u042d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u0438\u0440\u043f\u0438\u0447\u0435\u0439. \u0412\u044b \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0451. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0437\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e, \u0438 \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432 \u0441\u0432\u043e\u044e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443.<\/p>\n<p>\u0412\u0435\u0440\u0441\u0438\u044f: <strong>0.1.7<\/strong><br \/>\u0426\u0435\u043b\u0435\u0432\u0430\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430: <strong>.NET 8.0+<\/strong><br \/>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430: <code>dotnet add package GameAI.Net<\/code><\/p>\n<p>\u0427\u0435\u0442\u044b\u0440\u0435 \u043c\u043e\u0434\u0443\u043b\u044f:<\/p>\n<p><strong>1. Behavior Tree \u043d\u0430 \u0441\u0442\u0435\u0440\u043e\u0438\u0434\u0430\u0445<\/strong><\/p>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u2014 \u043f\u043b\u043e\u0441\u043a\u0438\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439. \u0412\u043c\u0435\u0441\u0442\u043e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u2014 \u0446\u0438\u043a\u043b \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c. \u0412\u043c\u0435\u0441\u0442\u043e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u2014 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044c \u043f\u043e <code>NodeKind<\/code>. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: \u0434\u0435\u0440\u0435\u0432\u043e \u0434\u043b\u044f 10 000 NPC \u0442\u0438\u043a\u0430\u0435\u0442 \u0437\u0430 <strong>285 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u043a\u0443\u043d\u0434<\/strong>.<\/p>\n<p>\u0415\u0441\u0442\u044c \u0434\u0432\u0435 \u0444\u043e\u0440\u043c\u044b \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0447\u0451\u0440\u043d\u043e\u0439 \u0434\u043e\u0441\u043a\u0438:<\/p>\n<ul>\n<li>\n<p><code>Blackboard<\/code> \u2014 \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (\u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 NPC).<\/p>\n<\/li>\n<li>\n<p><code>BlackboardSoA<\/code> \u2014 Structure of Arrays \u0434\u043b\u044f \u043c\u0430\u0441\u0441\u043e\u0432\u044b\u0445 \u0442\u0438\u043a\u043e\u0432 (\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d\u043e).<\/p>\n<\/li>\n<\/ul>\n<p><strong>2. Utility Scoring \u0441 SIMD<\/strong><\/p>\n<p>\u0411\u0430\u0442\u0447\u0435\u0432\u0430\u044f \u043e\u0446\u0435\u043d\u043a\u0430 \u043f\u0440\u0438\u0433\u043e\u0434\u043d\u043e\u0441\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 \u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u0443\u044e \u0441\u0443\u043c\u043c\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432. \u0412\u043d\u0443\u0442\u0440\u0438 \u2014 SIMD-\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 (AVX2\/SSE), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0437\u0430 \u043e\u0434\u0438\u043d \u0442\u0430\u043a\u0442 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<\/p>\n<p><code>ScoreAll<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 (\u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u044b \u00d7 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438) \u0438 \u0432\u0435\u043a\u0442\u043e\u0440 \u0432\u0435\u0441\u043e\u0432. \u0414\u043b\u044f 100 000 \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432 \u0441 64 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438 \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u0440\u0430\u0441\u0447\u0451\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 <strong>4.68 \u043c\u0441<\/strong>, \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u2014 <strong>1.16 \u043c\u0441<\/strong> \u043d\u0430 i5-11400F.<\/p>\n<p><strong>3. \u042d\u043c\u043e\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0433\u0440\u0430\u0444<\/strong><\/p>\n<p>\u0420\u0430\u0437\u0440\u0435\u0436\u0435\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444 \u0432 CSR-\u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 NPC. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0434\u0432\u0430 \u0440\u0435\u0436\u0438\u043c\u0430:<\/p>\n<ul>\n<li>\n<p><code>Step<\/code> \u2014 \u043f\u043e\u043b\u043d\u044b\u0439 \u043e\u0431\u0445\u043e\u0434 \u0432\u0441\u0435\u0445 \u0443\u0437\u043b\u043e\u0432 (\u0434\u043e\u0440\u043e\u0433\u043e).<\/p>\n<\/li>\n<li>\n<p><code>StepActive<\/code> \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0437\u043b\u044b, \u0438\u0437\u043c\u0435\u043d\u0438\u0432\u0448\u0438\u0435\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u043a\u0430\u0434\u0440\u0435 (\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d\u043e).<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f 100 000 \u0443\u0437\u043b\u043e\u0432 \u0441 10% \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0440\u0430\u0437 \u0432 4 \u043a\u0430\u0434\u0440\u0430 \u2014 <strong>~0.45 \u043c\u0441 \u043d\u0430 \u043a\u0430\u0434\u0440<\/strong>.<\/p>\n<p><strong>4. \u0421\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0442\u043e\u043b\u043f\u044b \u0441 \u043a\u0432\u043e\u0442\u0430\u043c\u0438<\/strong><\/p>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430: \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0442\u043e\u043f-K \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 3 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0432\u0440\u0430\u0433\u0430, 2 \u0441 \u043d\u0438\u0437\u043a\u0438\u043c \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u0435\u043c, 5 \u0441 \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u0443\u0440\u043e\u043d\u043e\u043c). \u0411\u0435\u0437 \u043f\u043e\u043b\u043d\u043e\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438, \u0431\u0435\u0437 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0439.<\/p>\n<p><code>SelectWithQuotasInto<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 selection \u043d\u0430 \u0441\u0442\u0435\u043a\u0435 \u0434\u043b\u044f \u043c\u0430\u043b\u044b\u0445 \u043a\u0432\u043e\u0442.<\/p>\n<h3>\u0411\u044b\u0441\u0442\u0440\u044b\u0439 \u0441\u0442\u0430\u0440\u0442<\/h3>\n<h4>\u041f\u043e\u0432\u0435\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e<\/h4>\n<pre><code class=\"cs\">using GameAI.Net.BehaviorTree;using GameAI.Net.Core;\/\/ \u0423\u0441\u043b\u043e\u0432\u0438\u0435: float[0] &gt; 0.5var condition = new ConditionProgram(new[]{    new Instruction(OpCode.LoadFloat, argI: 0),    new Instruction(OpCode.PushConst, argF: 0.5f),    new Instruction(OpCode.Gt)});\/\/ \u0414\u0435\u0440\u0435\u0432\u043e: Selector(Sequence(Condition, Attack), Idle)var nodes = new[]{    new Node(NodeKind.Selector, 0, 0),    new Node(NodeKind.Sequence, 0, 0),    new Node(NodeKind.Condition, 0, 0),    new Node(NodeKind.Action, 1, 0),  \/\/ Attack    new Node(NodeKind.Action, 0, 0)   \/\/ Idle};var children = new[] { 1, 4, 2, 3 };var childStart = new[] { 0, 2, 4, 4, 4 };var childCount = new[] { 2, 2, 0, 0, 0 };var tree = new BehaviorTree(nodes, children, childStart, childCount,     new[] { condition }, new MyActions());\/\/ \u0414\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e NPCvar bb = new Blackboard(floats: new float[8]);bb.SetFloat(0, 0.9f);tree.TickFast(new TickContext(1f\/60f, bb));\/\/ \u0414\u043b\u044f 10 000 NPC (SoA)var bbSoA = new BlackboardSoA(10000, floatSlots: 8);for (int i = 0; i &lt; 10000; i++){    bbSoA.SetFloat(i, 0, Random.Shared.NextSingle());    tree.TickFast(1f\/60f, bbSoA, i);}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>\u041f\u0430\u043a\u0435\u0442\u043d\u0430\u044f \u043e\u0446\u0435\u043d\u043a\u0430 \u043f\u0440\u0438\u0433\u043e\u0434\u043d\u043e\u0441\u0442\u0438<\/h4>\n<pre><code class=\"cs\">using GameAI.Net.Utility;using SlidingRank.FastOps;int agents = 10000;int featuresCount = 32;var data = new float[agents * featuresCount];\/\/ ... \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 ...var features = new EmbeddingMatrix(data, agents, featuresCount);var weights = new float[featuresCount];var scores = new float[agents];UtilityScorer.ScoreAll(features, weights, scores);      \/\/ \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043eUtilityScorer.ScoreAllParallel(features, weights, scores); \/\/ \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>\u0413\u0440\u0430\u0444 \u044d\u043c\u043e\u0446\u0438\u0439<\/h4>\n<pre><code class=\"cs\">using GameAI.Net.Emotion;int npcCount = 5000;int[] start = new int[npcCount + 1];int[] to = new int[totalEdges];float[] weight = new float[totalEdges];var graph = new EmotionGraph(npcCount, start, to, weight);\/\/ \u0422\u043e\u043b\u044c\u043a\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438bool[] active = new bool[npcCount];active[42] = true; \/\/ NPC 42 \u0440\u0430\u0437\u043e\u0437\u043b\u0438\u043b\u0441\u044fgraph.StepActive(active, 1f\/60f);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>\u0412\u044b\u0431\u043e\u0440 \u0441 \u043a\u0432\u043e\u0442\u0430\u043c\u0438<\/h4>\n<pre><code class=\"cs\">using GameAI.Net.Crowd;Span&lt;Candidate&gt; candidates = stackalloc Candidate[5000];\/\/ ... \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c ...Span&lt;GroupQuota&gt; quotas = stackalloc GroupQuota[]{    new(1, 2), \/\/ \u0433\u0440\u0443\u043f\u043f\u0430 1: 2 \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u0430    new(2, 1), \/\/ \u0433\u0440\u0443\u043f\u043f\u0430 2: 1 \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442    new(3, 3)  \/\/ \u0433\u0440\u0443\u043f\u043f\u0430 3: 3 \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u0430};Span&lt;int&gt; output = stackalloc int[100];int written = CrowdDirector.SelectWithQuotasInto(candidates, quotas, output);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h3>\u0426\u0438\u0444\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0422\u0435\u0441\u0442\u044b \u043d\u0430 <strong>Intel Core i5-11400F, Windows 11, .NET 8.0, BenchmarkDotNet 0.15.8<\/strong>.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u041c\u043e\u0434\u0443\u043b\u044c<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Behavior Tree (<code>TickFast<\/code>, SoA)<\/p>\n<\/td>\n<td>\n<p align=\"left\">10 000 NPC<\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>285 \u00b5s<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Utility Scoring (\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439)<\/p>\n<\/td>\n<td>\n<p align=\"left\">100k \u00d7 64<\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>4.68 ms<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Utility Scoring (\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439)<\/p>\n<\/td>\n<td>\n<p align=\"left\">100k \u00d7 64<\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>1.16 ms<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">Emotion Graph (\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438)<\/p>\n<\/td>\n<td>\n<p align=\"left\">100k \u0443\u0437\u043b\u043e\u0432, 10% \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445, \u0440\u0430\u0437 \u0432 4 \u043a\u0430\u0434\u0440\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>0.45 ms\/\u043a\u0430\u0434\u0440<\/strong><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0421\u043b\u043e\u0436\u0438\u043c \u0432\u0441\u0451 \u0432\u043c\u0435\u0441\u0442\u0435 \u0434\u043b\u044f 10 000 NPC \u0441 \u043f\u043e\u043b\u043d\u044b\u043c AI (\u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 + \u0441\u043a\u043e\u0440\u0438\u043d\u0433 + \u044d\u043c\u043e\u0446\u0438\u0438 \u0440\u0430\u0437 \u0432 4 \u043a\u0430\u0434\u0440\u0430):<\/p>\n<ul>\n<li>\n<p>Behavior Tree: 0.285 \u043c\u0441<\/p>\n<\/li>\n<li>\n<p>Utility Scoring (\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e): 1.16 \u043c\u0441 (\u0434\u043e\u043b\u044f \u043e\u0442 10 000 \u0438\u0437 100 000)<\/p>\n<\/li>\n<li>\n<p>Emotion Graph: 0.45 \u043c\u0441<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0418\u0442\u043e\u0433\u043e: ~1.9 \u043c\u0441 \u043d\u0430 \u043a\u0430\u0434\u0440.<\/strong> \u041e\u0441\u0442\u0430\u0451\u0442\u0441\u044f 14+ \u043c\u0441 \u043d\u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433, \u0444\u0438\u0437\u0438\u043a\u0443, \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0438 \u0441\u0435\u0442\u044c.<\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/h3>\n<p><strong>\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0439 \u0432 \u0433\u043e\u0440\u044f\u0447\u0435\u043c \u0446\u0438\u043a\u043b\u0435<\/strong><\/p>\n<p>\u0412 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0432\u0441\u0451, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u2014 \u043f\u0440\u0435\u0434\u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043e \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0422\u043e, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043d\u0430 \u0441\u0442\u0435\u043a\u0435 \u2014 \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u0435\u043a\u0435 \u0447\u0435\u0440\u0435\u0437 <code>stackalloc<\/code>. \u0412\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f. GC \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0447\u0435\u0433\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c.<\/p>\n<p><strong>\u041a\u044d\u0448-\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/strong><\/p>\n<p>BlackboardSoA \u0445\u0440\u0430\u043d\u0438\u0442 \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043f\u043e\u0434\u0440\u044f\u0434. \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0442\u0438\u043a\u0430\u0435\u0442\u0435 10 000 NPC \u043f\u043e\u0434\u0440\u044f\u0434, \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0432 \u043a\u044d\u0448 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u0439 \u0431\u043b\u043e\u043a \u043f\u0430\u043c\u044f\u0442\u0438, \u0430 \u043d\u0435 \u0434\u0451\u0440\u0433\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043d\u0430 \u0440\u0430\u0437\u0431\u0440\u043e\u0441\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b.<\/p>\n<p><strong>SIMD \u0431\u0435\u0437 \u0432\u0430\u0448\u0435\u0433\u043e \u0443\u0447\u0430\u0441\u0442\u0438\u044f<\/strong><\/p>\n<p>SIMD-\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0447\u0435\u0440\u0435\u0437 <code>SlidingRank.FastOps<\/code>. \u0412\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c <code>Vector&lt;T&gt;<\/code> \u0438\u043b\u0438 <code>Span&lt;T&gt;<\/code>. \u0412\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0435 <code>ScoreAll<\/code>, \u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u0443\u0436\u0435 \u0440\u0435\u0448\u0435\u043d\u043e: \u0435\u0441\u0442\u044c AVX2 \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0435\u0433\u043e, \u043d\u0435\u0442 \u2014 SSE, \u043d\u0435\u0442 SSE \u2014 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 float.<\/p>\n<p><strong>\u0421\u043b\u0430\u0431\u0430\u044f \u0441\u0432\u044f\u0437\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u0435\u0439<\/strong><\/p>\n<p>\u041c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e Utility Scoring, \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435. \u041c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0442\u043e\u043b\u043f\u044b, \u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0433\u0440\u0430\u0444 \u044d\u043c\u043e\u0446\u0438\u0439. \u041c\u043e\u0436\u0435\u0442\u0435 \u0434\u0430\u0436\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0432 \u0433\u043e\u0440\u044f\u0447\u0435\u043c \u043f\u0443\u0442\u0438, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<h3>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b<\/h3>\n<h4>LOD \u0434\u043b\u044f AI<\/h4>\n<pre><code class=\"cs\">if (distance &lt; 20f){    \/\/ \u041f\u043e\u043b\u043d\u044b\u0439 AI \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u0430\u0434\u0440    tree.TickFast(deltaTime, bb, i);    scorer.ScoreAll(features, weights, scores);}else if (distance &lt; 50f &amp;&amp; frame % 3 == 0){    \/\/ \u0422\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u043a\u0430\u0436\u0434\u044b\u0439 3-\u0439 \u043a\u0430\u0434\u0440    tree.TickFast(deltaTime, bb, i);}else if (frame % 10 == 0){    \/\/ \u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f    bb.SetFloat(i, \"lastSeen\", Time.time);}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>\u041e\u0434\u0438\u043d \u043c\u0430\u0441\u0442\u0435\u0440-\u0442\u0438\u043a \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u044b\u0441\u044f\u0447\u0438 Update()<\/h4>\n<p>\u0412 Unity \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u043d\u043e: \u043d\u0435 \u0432\u0435\u0448\u0430\u0439\u0442\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 \u0441 <code>Update()<\/code> \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e NPC.<\/p>\n<pre><code class=\"cs\">public class AIScheduler : MonoBehaviour{    private static BlackboardSoA _blackboard;    private static BehaviorTree _tree;        void Update()    {        for (int i = 0; i &lt; _blackboard.AgentCount; i++)        {            _tree.TickFast(Time.deltaTime, _blackboard, i);        }    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>\u0410\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0432 \u0433\u0440\u0430\u0444\u0435 \u044d\u043c\u043e\u0446\u0438\u0439<\/h4>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e <code>Step()<\/code> (\u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0441\u0447\u0451\u0442) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>StepActive()<\/code> \u0438 \u0432\u0435\u0434\u0438\u0442\u0435 \u043c\u0430\u0441\u0441\u0438\u0432 \u0444\u043b\u0430\u0433\u043e\u0432 <code>isDirty<\/code>. \u042d\u043c\u043e\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 NPC \u2192 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0445 \u0438 \u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439.<\/p>\n<h3>\u0427\u0435\u0433\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442<\/h3>\n<p>GameAI.Net \u0441\u043e\u0437\u043d\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442:<\/p>\n<ul>\n<li>\n<p><strong>\u041d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044e<\/strong> \u2014 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 A*, NavMesh, \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u0435 \u043f\u043e\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p><strong>\u0410\u043d\u0438\u043c\u0430\u0446\u0438\u0438<\/strong> \u2014 \u044d\u0442\u043e \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0432\u0430\u0448\u0435\u0439 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0435\u0442\u044c<\/strong> \u2014 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 NPC \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0437\u0430 \u0432\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0435\u0434\u0430\u043a\u0442\u043e\u0440<\/strong> \u2014 \u0432\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0435 \u0434\u0435\u0440\u0435\u0432\u044c\u044f \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u0434\u0435 \u0438\u043b\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0435 \u0438\u0445 \u0438\u0437 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u0441\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0413\u043e\u0442\u043e\u0432\u044b\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b<\/strong> \u2014 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u0430\u0451\u0442 \u043a\u0438\u0440\u043f\u0438\u0447\u0438, \u0430 \u043d\u0435 \u0434\u043e\u043c.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u043e\u0434\u043d\u043e\u0433\u043e \u044f\u0434\u0440\u0430<\/h3>\n<p>\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 <code>ScoreAllParallel<\/code> \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>Parallel.For<\/code>. \u0414\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043a\u0430 \u043d\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u2014 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0430\u043c\u0438 \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 NPC \u043d\u0430 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u044b \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0434\u0430\u0447.<\/p>\n<pre><code class=\"cs\">var options = new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount };Parallel.For(0, _blackboard.AgentCount, options, i =&gt;{    _tree.TickFast(deltaTime, _blackboard, i);});<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><strong>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435:<\/strong> <code>Parallel.For<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438 (\u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0438 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u0432, \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u044b). \u0414\u043b\u044f \u0441\u0442\u0440\u043e\u0433\u043e\u0439 zero-alloc-\u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0441\u0432\u043e\u0439 \u043f\u0443\u043b \u0432\u043e\u0440\u043a\u0435\u0440\u043e\u0432 \u0438\u043b\u0438 Unity Jobs.<\/p>\n<p><strong>\u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/strong> \u2014 \u0431\u0435\u0437 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439. \u041a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0438.<\/p>\n<p>GameAI.Net \u0440\u0435\u0448\u0430\u0435\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443: \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0442\u044b\u0441\u044f\u0447 NPC \u0441 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0439 \u043b\u0430\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0431\u0435\u0437 GC-\u0441\u043f\u0430\u0439\u043a\u043e\u0432.<\/p>\n<p>\u041e\u043d\u0430 \u043d\u0435 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u0430\u0448 \u043a\u043e\u0434. \u041e\u043d\u0430 \u0434\u0430\u0451\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u0438\u0440\u043f\u0438\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0435 \u0432 \u0441\u0432\u043e\u044e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443. \u0425\u043e\u0442\u0438\u0442\u0435 \u0434\u0435\u0440\u0435\u0432\u044c\u044f \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u2014 \u0431\u0435\u0440\u0438\u0442\u0435. \u041d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e SIMD-\u0441\u043a\u043e\u0440\u0438\u043d\u0433 \u2014 \u0431\u0435\u0440\u0438\u0442\u0435 \u0435\u0433\u043e. \u0413\u0440\u0430\u0444 \u044d\u043c\u043e\u0446\u0438\u0439 \u2014 \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430. \u0421\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0441 \u043a\u0432\u043e\u0442\u0430\u043c\u0438 \u2014 \u0437\u0430\u0431\u0438\u0440\u0430\u0439\u0442\u0435.<\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u043d\u0430 \u0441\u0432\u043e\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u043b\u0438 \u0432\u0430\u0448 AI \u0442\u043e\u0440\u043c\u043e\u0437\u0438\u0442 \u0438 \u0444\u0440\u0438\u0437\u0438\u0442 \u2014 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u043d\u0430\u0448\u043b\u0438 \u043e\u0442\u0432\u0435\u0442.<\/p>\n<\/div>\n<p>\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\/1040910\/\">https:\/\/habr.com\/ru\/articles\/1040910\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 \u0434\u0432\u0443\u0445 \u0441\u043b\u043e\u0432\u0430\u0445 \u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0435\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u044b \u0434\u0435\u043b\u0430\u0435\u0442\u0435 \u0441\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u044e \u0433\u043e\u0440\u043e\u0434\u0430. \u0418\u043b\u0438 RTS. \u0418\u043b\u0438 RPG \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u043c\u0438\u0440\u043e\u043c. \u0418 \u0443 \u0432\u0430\u0441 \u0432 \u0441\u0446\u0435\u043d\u0435 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f 5, 10, \u0430 \u0442\u043e \u0438 20 \u0442\u044b\u0441\u044f\u0447 \u0436\u0438\u0432\u044b\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432. \u0423 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0432\u043e\u0438 \u0446\u0435\u043b\u0438, \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u044b, \u044d\u043c\u043e\u0446\u0438\u0438, \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u044f\u0437\u0438.\u0412\u0430\u0448\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 AI \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0442\u0440\u0435\u0449\u0430\u0442\u044c \u043f\u043e \u0448\u0432\u0430\u043c.\u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u2014 \u0434\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u043c\u0443 NPC \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c Update() \u2014 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0451\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0433\u0434\u0435-\u0442\u043e \u043f\u043e\u0441\u043b\u0435 500\u20131000 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0414\u0430\u043b\u044c\u0448\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b:10 000 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0437\u0430 \u043a\u0430\u0434\u0440 \u2192 \u043f\u0440\u043e\u043c\u0430\u0445\u0438 \u043a\u044d\u0448\u0430 \u0438 \u0434\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u0432.LINQ-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u0432\u0440\u0430\u0433\u0430 \u2192 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u0438 GC.\u041f\u0435\u0440\u0435\u0441\u0447\u0451\u0442 \u044d\u043c\u043e\u0446\u0438\u0439 \u043f\u043e \u043f\u043e\u043b\u043d\u043e\u043c\u0443 \u0433\u0440\u0430\u0444\u0443 \u2192 O(N\u00b2) \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435.\u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0432\u0441\u0435\u0445 NPC \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0442\u043e\u043f-10 \u2192 \u043f\u0443\u0441\u0442\u0430\u044f \u0442\u0440\u0430\u0442\u0430 O(N log N) \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439.\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u0430\u0448\u0438 60 FPS \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u0432 30, \u0430 \u043f\u043e\u0442\u043e\u043c \u0432 15. \u0418\u0433\u0440\u043e\u043a\u0438 \u0436\u0430\u043b\u0443\u044e\u0442\u0441\u044f \u043d\u0430 \u0444\u0440\u0438\u0437\u044b (\u044d\u0442\u043e GC \u0441\u043e\u0431\u0440\u0430\u043b 20 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432). \u0412\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0435 \u043d\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u0430 \u043f\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 AI.\u042d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u044b.\u0427\u0442\u043e \u043b\u0435\u0436\u0438\u0442 \u0432 \u043a\u043e\u0440\u043e\u0431\u043a\u0435\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 GameAI.Net \u2014 \u044d\u0442\u043e \u043d\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a. \u042d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u0438\u0440\u043f\u0438\u0447\u0435\u0439. \u0412\u044b \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0451. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0437\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e, \u0438 \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432 \u0441\u0432\u043e\u044e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443.\u0412\u0435\u0440\u0441\u0438\u044f: 0.1.7\u0426\u0435\u043b\u0435\u0432\u0430\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430: .NET 8.0+\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430: dotnet add package GameAI.Net\u0427\u0435\u0442\u044b\u0440\u0435 \u043c\u043e\u0434\u0443\u043b\u044f:1. Behavior Tree \u043d\u0430 \u0441\u0442\u0435\u0440\u043e\u0438\u0434\u0430\u0445\u0412\u043c\u0435\u0441\u0442\u043e \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u2014 \u043f\u043b\u043e\u0441\u043a\u0438\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439. \u0412\u043c\u0435\u0441\u0442\u043e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u2014 \u0446\u0438\u043a\u043b \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c. \u0412\u043c\u0435\u0441\u0442\u043e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u2014 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044c \u043f\u043e NodeKind. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: \u0434\u0435\u0440\u0435\u0432\u043e \u0434\u043b\u044f 10 000 NPC \u0442\u0438\u043a\u0430\u0435\u0442 \u0437\u0430 285 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u043a\u0443\u043d\u0434.\u0415\u0441\u0442\u044c \u0434\u0432\u0435 \u0444\u043e\u0440\u043c\u044b \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0447\u0451\u0440\u043d\u043e\u0439 \u0434\u043e\u0441\u043a\u0438:Blackboard \u2014 \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (\u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 NPC).BlackboardSoA \u2014 Structure of Arrays \u0434\u043b\u044f \u043c\u0430\u0441\u0441\u043e\u0432\u044b\u0445 \u0442\u0438\u043a\u043e\u0432 (\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d\u043e).2. Utility Scoring \u0441 SIMD\u0411\u0430\u0442\u0447\u0435\u0432\u0430\u044f \u043e\u0446\u0435\u043d\u043a\u0430 \u043f\u0440\u0438\u0433\u043e\u0434\u043d\u043e\u0441\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 \u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u0443\u044e \u0441\u0443\u043c\u043c\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432. \u0412\u043d\u0443\u0442\u0440\u0438 \u2014 SIMD-\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 (AVX2\/SSE), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0437\u0430 \u043e\u0434\u0438\u043d \u0442\u0430\u043a\u0442 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.ScoreAll \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 (\u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u044b \u00d7 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438) \u0438 \u0432\u0435\u043a\u0442\u043e\u0440 \u0432\u0435\u0441\u043e\u0432. \u0414\u043b\u044f 100 000 \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432 \u0441 64 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c\u0438 \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u0440\u0430\u0441\u0447\u0451\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 4.68 \u043c\u0441, \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u2014 1.16 \u043c\u0441 \u043d\u0430 i5-11400F.3. \u042d\u043c\u043e\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0420\u0430\u0437\u0440\u0435\u0436\u0435\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444 \u0432 CSR-\u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 NPC. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0434\u0432\u0430 \u0440\u0435\u0436\u0438\u043c\u0430:Step \u2014 \u043f\u043e\u043b\u043d\u044b\u0439 \u043e\u0431\u0445\u043e\u0434 \u0432\u0441\u0435\u0445 \u0443\u0437\u043b\u043e\u0432 (\u0434\u043e\u0440\u043e\u0433\u043e).StepActive \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0437\u043b\u044b, \u0438\u0437\u043c\u0435\u043d\u0438\u0432\u0448\u0438\u0435\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u043a\u0430\u0434\u0440\u0435 (\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d\u043e).\u0414\u043b\u044f 100 000 \u0443\u0437\u043b\u043e\u0432 \u0441 10% \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0440\u0430\u0437 \u0432 4 \u043a\u0430\u0434\u0440\u0430 \u2014 ~0.45 \u043c\u0441 \u043d\u0430 \u043a\u0430\u0434\u0440.4. \u0421\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0442\u043e\u043b\u043f\u044b \u0441 \u043a\u0432\u043e\u0442\u0430\u043c\u0438\u0417\u0430\u0434\u0430\u0447\u0430: \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0442\u043e\u043f-K \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 3 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0445 \u0432\u0440\u0430\u0433\u0430, 2 \u0441 \u043d\u0438\u0437\u043a\u0438\u043c \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u0435\u043c, 5 \u0441 \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u0443\u0440\u043e\u043d\u043e\u043c). \u0411\u0435\u0437 \u043f\u043e\u043b\u043d\u043e\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438, \u0431\u0435\u0437 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0439.SelectWithQuotasInto \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 selection \u043d\u0430 \u0441\u0442\u0435\u043a\u0435 \u0434\u043b\u044f \u043c\u0430\u043b\u044b\u0445 \u043a\u0432\u043e\u0442.\u0411\u044b\u0441\u0442\u0440\u044b\u0439 \u0441\u0442\u0430\u0440\u0442\u041f\u043e\u0432\u0435\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043eusing GameAI.Net.BehaviorTree;using GameAI.Net.Core;\/\/ \u0423\u0441\u043b\u043e\u0432\u0438\u0435: float[0] &gt; 0.5var condition = new ConditionProgram(new[]{    new Instruction(OpCode.LoadFloat, argI: 0),    new Instruction(OpCode.PushConst, argF: 0.5f),    new Instruction(OpCode.Gt)});\/\/ \u0414\u0435\u0440\u0435\u0432\u043e: Selector(Sequence(Condition, Attack), Idle)var nodes = new[]{    new Node(NodeKind.Selector, 0, 0),    new Node(NodeKind.Sequence, 0, 0),    new Node(NodeKind.Condition, 0, 0),    new Node(NodeKind.Action, 1, 0),  \/\/ Attack    new Node(NodeKind.Action, 0, 0)   \/\/ Idle};var children = new[] { 1, 4, 2, 3 };var childStart = new[] { 0, 2, 4, 4, 4 };var childCount = new[] { 2, 2, 0, 0, 0 };var tree = new BehaviorTree(nodes, children, childStart, childCount,     new[] { condition }, new MyActions());\/\/ \u0414\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e NPCvar bb = new Blackboard(floats: new float[8]);bb.SetFloat(0, 0.9f);tree.TickFast(new TickContext(1f\/60f, bb));\/\/ \u0414\u043b\u044f 10 000 NPC (SoA)var bbSoA = new BlackboardSoA(10000, floatSlots: 8);for (int i = 0; i &lt; 10000; i++){    bbSoA.SetFloat(i, 0, Random.Shared.NextSingle());    tree.TickFast(1f\/60f, bbSoA, i);}\u041f\u0430\u043a\u0435\u0442\u043d\u0430\u044f \u043e\u0446\u0435\u043d\u043a\u0430 \u043f\u0440\u0438\u0433\u043e\u0434\u043d\u043e\u0441\u0442\u0438using GameAI.Net.Utility;using SlidingRank.FastOps;int agents = 10000;int featuresCount = 32;var data = new float[agents * featuresCount];\/\/ &#8230; \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 &#8230;var features = new EmbeddingMatrix(data, agents, featuresCount);var weights = new float[featuresCount];var scores = new float[agents];UtilityScorer.ScoreAll(features, weights, scores);      \/\/ \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043eUtilityScorer.ScoreAllParallel(features, weights, scores); \/\/ \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0413\u0440\u0430\u0444 \u044d\u043c\u043e\u0446\u0438\u0439using GameAI.Net.Emotion;int npcCount = 5000;int[] start = new int[npcCount + 1];int[] to = new int[totalEdges];float[] weight = new float[totalEdges];var graph = new EmotionGraph(npcCount, start, to, weight);\/\/ \u0422\u043e\u043b\u044c\u043a\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438bool[] active = new bool[npcCount];active[42] = true; \/\/ NPC 42 \u0440\u0430\u0437\u043e\u0437\u043b\u0438\u043b\u0441\u044fgraph.StepActive(active, 1f\/60f);\u0412\u044b\u0431\u043e\u0440 \u0441 \u043a\u0432\u043e\u0442\u0430\u043c\u0438using GameAI.Net.Crowd;Span&lt;Candidate&gt; candidates = stackalloc Candidate[5000];\/\/ &#8230; \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c &#8230;Span&lt;GroupQuota&gt; quotas = stackalloc GroupQuota[]{    new(1, 2), \/\/ \u0433\u0440\u0443\u043f\u043f\u0430 1: 2 \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u0430    new(2, 1), \/\/ \u0433\u0440\u0443\u043f\u043f\u0430 2: 1 \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442    new(3, 3)  \/\/ \u0433\u0440\u0443\u043f\u043f\u0430 3: 3 \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u0430};Span&lt;int&gt; output = stackalloc int[100];int written = CrowdDirector.SelectWithQuotasInto(candidates, quotas, output);\u0426\u0438\u0444\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u0422\u0435\u0441\u0442\u044b \u043d\u0430 Intel Core i5-11400F, Windows 11, .NET 8.0, BenchmarkDotNet 0.15.8.\u041c\u043e\u0434\u0443\u043b\u044c\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442Behavior Tree (TickFast, SoA)10 000 NPC285 \u00b5sUtility Scoring (\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439)100k \u00d7 644.68 msUtility Scoring (\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439)100k \u00d7 641.16 msEmotion Graph (\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438)100k \u0443\u0437\u043b\u043e\u0432, 10% \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445, \u0440\u0430\u0437 \u0432 4 \u043a\u0430\u0434\u0440\u04300.45 ms\/\u043a\u0430\u0434\u0440\u0421\u043b\u043e\u0436\u0438\u043c \u0432\u0441\u0451 \u0432\u043c\u0435\u0441\u0442\u0435 \u0434\u043b\u044f 10 000 NPC \u0441 \u043f\u043e\u043b\u043d\u044b\u043c AI (\u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 + \u0441\u043a\u043e\u0440\u0438\u043d\u0433 + \u044d\u043c\u043e\u0446\u0438\u0438 \u0440\u0430\u0437 \u0432 4 \u043a\u0430\u0434\u0440\u0430):Behavior Tree: 0.285 \u043c\u0441Utility Scoring (\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e): 1.16 \u043c\u0441 (\u0434\u043e\u043b\u044f \u043e\u0442 10 000 \u0438\u0437 100 000)Emotion Graph: 0.45 \u043c\u0441\u0418\u0442\u043e\u0433\u043e: ~1.9 \u043c\u0441 \u043d\u0430 \u043a\u0430\u0434\u0440. \u041e\u0441\u0442\u0430\u0451\u0442\u0441\u044f 14+ \u043c\u0441 \u043d\u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433, \u0444\u0438\u0437\u0438\u043a\u0443, \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0438 \u0441\u0435\u0442\u044c.\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0439 \u0432 \u0433\u043e\u0440\u044f\u0447\u0435\u043c \u0446\u0438\u043a\u043b\u0435\u0412 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0432\u0441\u0451, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u2014 \u043f\u0440\u0435\u0434\u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043e \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0422\u043e, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043d\u0430 \u0441\u0442\u0435\u043a\u0435 \u2014 \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u0435\u043a\u0435 \u0447\u0435\u0440\u0435\u0437 stackalloc. \u0412\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f. GC \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0447\u0435\u0433\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c.\u041a\u044d\u0448-\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044cBlackboardSoA \u0445\u0440\u0430\u043d\u0438\u0442 \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043f\u043e\u0434\u0440\u044f\u0434. \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0442\u0438\u043a\u0430\u0435\u0442\u0435 10 000 NPC \u043f\u043e\u0434\u0440\u044f\u0434, \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0432 \u043a\u044d\u0448 \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u0439 \u0431\u043b\u043e\u043a \u043f\u0430\u043c\u044f\u0442\u0438, \u0430 \u043d\u0435 \u0434\u0451\u0440\u0433\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043d\u0430 \u0440\u0430\u0437\u0431\u0440\u043e\u0441\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b.SIMD \u0431\u0435\u0437 \u0432\u0430\u0448\u0435\u0433\u043e \u0443\u0447\u0430\u0441\u0442\u0438\u044fSIMD-\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0447\u0435\u0440\u0435\u0437 SlidingRank.FastOps. \u0412\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c Vector&lt;T&gt; \u0438\u043b\u0438 Span&lt;T&gt;. \u0412\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0435 ScoreAll, \u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u0443\u0436\u0435 \u0440\u0435\u0448\u0435\u043d\u043e: \u0435\u0441\u0442\u044c AVX2 \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0435\u0433\u043e, \u043d\u0435\u0442 \u2014 SSE, \u043d\u0435\u0442 SSE \u2014 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 float.\u0421\u043b\u0430\u0431\u0430\u044f \u0441\u0432\u044f\u0437\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u0435\u0439\u041c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e Utility Scoring, \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435. \u041c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0442\u043e\u043b\u043f\u044b, \u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0433\u0440\u0430\u0444 \u044d\u043c\u043e\u0446\u0438\u0439. \u041c\u043e\u0436\u0435\u0442\u0435 \u0434\u0430\u0436\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0432 \u0433\u043e\u0440\u044f\u0447\u0435\u043c \u043f\u0443\u0442\u0438, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044bLOD \u0434\u043b\u044f AIif (distance &lt; 20f){    \/\/ \u041f\u043e\u043b\u043d\u044b\u0439 AI \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u0430\u0434\u0440    tree.TickFast(deltaTime, bb, i);    scorer.ScoreAll(features, weights, scores);}else if (distance &lt; 50f &amp;&amp; frame % 3 == 0){    \/\/ \u0422\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u043a\u0430\u0436\u0434\u044b\u0439 3-\u0439 \u043a\u0430\u0434\u0440    tree.TickFast(deltaTime, bb, i);}else if (frame % 10 == 0){    \/\/ \u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f    bb.SetFloat(i, &#171;lastSeen&#187;, Time.time);}\u041e\u0434\u0438\u043d \u043c\u0430\u0441\u0442\u0435\u0440-\u0442\u0438\u043a \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u044b\u0441\u044f\u0447\u0438 Update()\u0412 Unity \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u043d\u043e: \u043d\u0435 \u0432\u0435\u0448\u0430\u0439\u0442\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 \u0441 Update() \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e NPC.public class AIScheduler : MonoBehaviour{    private static BlackboardSoA _blackboard;    private static BehaviorTree _tree;        void Update()    {        for (int i = 0; i &lt; _blackboard.AgentCount; i++)        {            _tree.TickFast(Time.deltaTime, _blackboard, i);        }    }}\u0410\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0432 \u0433\u0440\u0430\u0444\u0435 \u044d\u043c\u043e\u0446\u0438\u0439\u0412\u043c\u0435\u0441\u0442\u043e Step() (\u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0441\u0447\u0451\u0442) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 StepActive() \u0438 \u0432\u0435\u0434\u0438\u0442\u0435 \u043c\u0430\u0441\u0441\u0438\u0432 \u0444\u043b\u0430\u0433\u043e\u0432 isDirty. \u042d\u043c\u043e\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 NPC \u2192 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0445 \u0438 \u0438\u0445 \u0441\u043e\u0441\u0435\u0434\u0435\u0439.\u0427\u0435\u0433\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442GameAI.Net \u0441\u043e\u0437\u043d\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442:\u041d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044e \u2014 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 A*, NavMesh, \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u0435 \u043f\u043e\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.\u0410\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u2014 \u044d\u0442\u043e \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0432\u0430\u0448\u0435\u0439 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.\u0421\u0435\u0442\u044c \u2014 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 NPC \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0437\u0430 \u0432\u0430\u043c\u0438.\u0420\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u2014 \u0432\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0435 \u0434\u0435\u0440\u0435\u0432\u044c\u044f \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u0434\u0435 \u0438\u043b\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0435 \u0438\u0445 \u0438\u0437 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u0441\u0430\u043c\u0438.\u0413\u043e\u0442\u043e\u0432\u044b\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u2014 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u0430\u0451\u0442 \u043a\u0438\u0440\u043f\u0438\u0447\u0438, \u0430 \u043d\u0435 \u0434\u043e\u043c.\u041c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u043e\u0434\u043d\u043e\u0433\u043e \u044f\u0434\u0440\u0430\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 ScoreAllParallel \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Parallel.For. \u0414\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043a\u0430 \u043d\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u2014 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0430\u043c\u0438 \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 NPC \u043d\u0430 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u044b \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0434\u0430\u0447.var options = new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount };Parallel.For(0, _blackboard.AgentCount, options, i =&gt;{    _tree.TickFast(deltaTime, _blackboard, i);});\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435: Parallel.For \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438 (\u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0438 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u0432, \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u044b). \u0414\u043b\u044f \u0441\u0442\u0440\u043e\u0433\u043e\u0439 zero-alloc-\u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0441\u0432\u043e\u0439 \u043f\u0443\u043b \u0432\u043e\u0440\u043a\u0435\u0440\u043e\u0432 \u0438\u043b\u0438 Unity Jobs.\u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u0431\u0435\u0437 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439. \u041a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0438.GameAI.Net \u0440\u0435\u0448\u0430\u0435\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443: \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0442\u044b\u0441\u044f\u0447 NPC \u0441 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0439 \u043b\u0430\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0431\u0435\u0437 GC-\u0441\u043f\u0430\u0439\u043a\u043e\u0432.\u041e\u043d\u0430 \u043d\u0435 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u0430\u0448 \u043a\u043e\u0434. \u041e\u043d\u0430 \u0434\u0430\u0451\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u0438\u0440\u043f\u0438\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0435 \u0432 \u0441\u0432\u043e\u044e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443. \u0425\u043e\u0442\u0438\u0442\u0435 \u0434\u0435\u0440\u0435\u0432\u044c\u044f \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u2014 \u0431\u0435\u0440\u0438\u0442\u0435. \u041d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e SIMD-\u0441\u043a\u043e\u0440\u0438\u043d\u0433 \u2014 \u0431\u0435\u0440\u0438\u0442\u0435 \u0435\u0433\u043e. \u0413\u0440\u0430\u0444 \u044d\u043c\u043e\u0446\u0438\u0439 \u2014 \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430. \u0421\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0441 \u043a\u0432\u043e\u0442\u0430\u043c\u0438 \u2014 \u0437\u0430\u0431\u0438\u0440\u0430\u0439\u0442\u0435.\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u043d\u0430 \u0441\u0432\u043e\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u043b\u0438 \u0432\u0430\u0448 AI \u0442\u043e\u0440\u043c\u043e\u0437\u0438\u0442 \u0438 \u0444\u0440\u0438\u0437\u0438\u0442 \u2014 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u043d\u0430\u0448\u043b\u0438 \u043e\u0442\u0432\u0435\u0442.\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 https:\/\/habr.com\/ru\/articles\/1040910\/<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-481485","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/481485","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=481485"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/481485\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=481485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=481485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=481485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}