YouTube2Text

Inteligência Artificial DESTRUINDO no Dino Chrome 2.0 — Transcript

by Universo Programado · 7,156 words · 1,196 segments · language en · Watch on YouTube

Full transcript

  1. 0:00Attention, this video is absolutely
  2. 0:03stunning, so to fully enjoy it, watch it
  3. 0:06on a television.
  4. 0:10In 2019 I published this video. In it,
  5. 0:13we saw a neural network learning to play
  6. 0:15the famous Google Chrome dinosaur game.
  7. 0:17Throughout the video, it became clear
  8. 0:19that the original version of the game
  9. 0:20was too easy. The network learned to
  10. 0:22play without any difficulty.
  11. 0:24So, to make it more difficult, I added a
  12. 0:26new obstacle that could only be jumped
  13. 0:28over with a specific action.
  14. 0:30But that didn't help much either. The
  15. 0:33network managed to master the game
  16. 0:35anyway.
  17. 0:36Then, recently rewatching this video, I
  18. 0:38realized how little we've taken
  19. 0:40advantage of this game.
  20. 0:42The fact that it's simple leaves a lot
  21. 0:44of room for us to add interesting
  22. 0:46mechanics. So in today's video, we're
  23. 0:49going to do exactly that.
  24. 0:51We're going to revisit this game and
  25. 0:53enhance it even more.
  26. 0:55We're going to improve its aesthetics
  27. 0:57and add several other obstacles so that
  28. 0:59the game is now really difficult.
  29. 1:02Our goal here will be to find out how
  30. 1:04long the neural network can keep
  31. 1:06learning to play.
  32. 1:08And here's a spoiler: it was much more
  33. 1:10than I expected.
  34. 1:18So, to begin, let's start with the game
  35. 1:20version from the previous video and make
  36. 1:22some modifications. First, let's
  37. 1:24reorganize the screen layout.
  38. 1:27We'll move all the information to the
  39. 1:29bottom to free up space at the top
  40. 1:31because we need that upper area to be
  41. 1:33clear.
  42. 1:35On the left, there's some training
  43. 1:37information and a graph showing the
  44. 1:38learning progress.
  45. 1:40On the right, there's some information
  46. 1:42about the best individual and a small
  47. 1:44screen showing them playing in real time
  48. 1:46.
  49. 1:47In this graphical interface, we also
  50. 1:49have a button that zooms in on the
  51. 1:50neural network and shows the weights of
  52. 1:52the connections individually.
  53. 1:55Second, let's remove the infinite speed
  54. 1:57from the scenario and remove the little
  55. 1:59plane with spikes because they will now
  56. 2:01interfere with the new ideas we're going
  57. 2:03to implement.
  58. 2:05Now the speed starts at five and
  59. 2:07increases until it reaches 10. When it
  60. 2:09reaches 10, it will start to decrease
  61. 2:11until it returns to five.
  62. 2:13It will oscillate in this way infinitely
  63. 2:16. Before, the dinosaurs 'score was per
  64. 2:19pixel traveled.
  65. 2:21Now it will be per obstacle jumped, just
  66. 2:23so we have a more intuitive metric of
  67. 2:24how good the individual really is.
  68. 2:27Okay, let's put it to training just to
  69. 2:29see if everything is working. After
  70. 2:31about eight minutes of training, there
  71. 2:33it is, mastered the game as always.
  72. 2:36The best individual jumped over 15,000
  73. 2:37obstacles before the match was
  74. 2:39interrupted because it lasted too long.
  75. 2:41Perfect. The next step is to improve the
  76. 2:44game's visuals.
  77. 2:46Since they're in the desert, let's make
  78. 2:48the ground sand-colored and the cacti
  79. 2:50green.
  80. 2:52The mountains will be in shades of brown
  81. 2:54to match the desert style, and a blue
  82. 2:55sky with white clouds just to complement
  83. 2:57it.
  84. 2:59Now, so the scenery doesn't look too
  85. 3:01static, let's add a sun that gradually
  86. 3:03sets. When it reaches the horizon, the
  87. 3:06sky will turn orange and then it will be
  88. 3:08night. And of course, if we look behind
  89. 3:11the scenes of the game, it's not so
  90. 3:13pretty.
  91. 3:15The sun is making a kind of crazy circle
  92. 3:16, there are mountains, but no ground,
  93. 3:18and the clouds are teleported to the
  94. 3:19other side.
  95. 3:21Games always trick the player. Okay,
  96. 3:23since I haven't changed any of the game
  97. 3:25mechanics, everything should still be
  98. 3:27working. Let's practice here quickly,
  99. 3:29and there it is, they're still mastering
  100. 3:31the game. Perfect. Let's also improve
  101. 3:33the enlarged graph and the enlarged
  102. 3:35neural network.
  103. 3:37Now their background will be transparent
  104. 3:39, but with reduced lighting to give that
  105. 3:41sense of integration, but without losing
  106. 3:44legibility.
  107. 3:45Perfect. Now, let's make the game harder
  108. 3:47.
  109. 3:48First, let's slightly reduce the
  110. 3:50distance between the obstacles and set
  111. 3:52their size to random within a range.
  112. 3:55When the obstacle is generated, we'll
  113. 3:58multiply its size by a random number
  114. 4:00between 0.75 and 1.25.
  115. 4:02This allows its size to be reduced or
  116. 4:05enlarged by up to 25%.
  117. 4:08This randomness, in addition to making
  118. 4:10the game harder, also generalizes
  119. 4:12learning, because now the network will
  120. 4:13be exposed to a larger set of sizes.
  121. 4:17And this set will make it harder for it
  122. 4:19to simply memorize what to do for each
  123. 4:21specific obstacle.
  124. 4:23After about 18 minutes, they don't care
  125. 4:25anymore.
  126. 4:26They've learned to dodge everything in
  127. 4:28the same way. Awesome. Now let's add two
  128. 4:31super cacti. One will be taller
  129. 4:33vertically and the other taller
  130. 4:34horizontally. And to get past them,
  131. 4:37we're going to add a new action to the
  132. 4:39dinosaur: the double jump.
  133. 4:42So the idea now is for them to learn to
  134. 4:44identify the super cacti and use the
  135. 4:46double jump to get past them.
  136. 4:48And as the name suggests, the double
  137. 4:50jump can only be used after the normal
  138. 4:52jump.
  139. 4:53It only works if the dinosaur is already
  140. 4:55in its first jump.
  141. 4:56Let's put it to the test and see what
  142. 4:58happens.
  143. 5:04After about 15 minutes, there it is. We
  144. 5:07have one good thing and one bad thing.
  145. 5:09The good thing is that they managed to
  146. 5:10learn. Easy. The best individual has
  147. 5:12already jumped over 4,500 obstacles.
  148. 5:15And the bad thing is that they learned
  149. 5:16to use the double jump all the time,
  150. 5:17even when they don't need to.
  151. 5:19Since there's no limit or drawback,
  152. 5:21they'll take advantage of it. This is
  153. 5:24the famous alignment problem. The
  154. 5:27algorithm achieves the objective you
  155. 5:28asked for, but not in the way you wanted
  156. 5:30.
  157. 5:31This happens because there's a tendency
  158. 5:33for the algorithm to follow the simplest
  159. 5:35path.
  160. 5:36And this tendency exists because the
  161. 5:38simplest paths are the most abundant.
  162. 5:41Among all the possible behaviors for
  163. 5:43this neural network, the simplest ones
  164. 5:46are more numerous.
  165. 5:48So, thinking in terms of probability,
  166. 5:50the chance of the algorithm converging
  167. 5:52on one of them is higher.
  168. 5:53Okay.
  169. 5:55Since it exploited a flaw in our design
  170. 5:56to win more easily, let's do the
  171. 5:58following.
  172. 5:59Let's add energy dynamics.
  173. 6:03Every time it uses the double jump, it
  174. 6:05will expend some energy. The energy will
  175. 6:07be limited and will regenerate slowly.
  176. 6:10This will prevent it from using the
  177. 6:12double jump unnecessarily all the time.
  178. 6:15Otherwise, when it reaches the
  179. 6:16supercactus, it will be out of energy to
  180. 6:18jump and will spin. They will start with
  181. 6:21100 energy and the double jump will cost
  182. 6:2420. But here a small problem arises.
  183. 6:27Since the obstacles in the scenario are
  184. 6:29generated randomly, several supercacti
  185. 6:31may appear in sequence.
  186. 6:33Then they will run out of energy to jump
  187. 6:35.
  188. 6:37Not because they used it incorrectly,
  189. 6:38but because the scenario didn't give
  190. 6:39them enough time to regenerate their
  191. 6:41energy.
  192. 6:43So, to get around that, every time the
  193. 6:45individual manages to jump over a
  194. 6:46supercactus, their energy will be
  195. 6:48regenerated by 20, which is precisely
  196. 6:50the cost of the double jump.
  197. 6:53This way, supercacti can come infinitely
  198. 6:55, one after the other, and the
  199. 6:56individual will never run out of energy
  200. 6:59because of them.
  201. 7:00Let's see what happens.
  202. 7:07Now the game has really gotten harder,
  203. 7:09because it took an hour and a half for
  204. 7:10them to reach a higher performance level
  205. 7:12. And this time something rather
  206. 7:14counterintuitive happened.
  207. 7:17When the bird comes very high, they use
  208. 7:19the double jump instead of going
  209. 7:20underneath, which makes no sense,
  210. 7:22because they are wasting energy
  211. 7:23unnecessarily.
  212. 7:26When I saw this, I thought, "Wait, if
  213. 7:28they are wasting energy like that, how
  214. 7:30do they manage to survive more than 800
  215. 7:32obstacles?"
  216. 7:34The energy should have been reset at the
  217. 7:36beginning of the game. Then I watched
  218. 7:38him play and noticed something very
  219. 7:40interesting. They only waste energy when
  220. 7:43they have some left over. When it gets
  221. 7:46close to 40, they stop wasting it. And
  222. 7:48that makes perfect sense.
  223. 7:51To survive, they only need to ensure
  224. 7:52they have at least 20 energy points to
  225. 7:54jump over the supercactus when it comes
  226. 7:56.
  227. 7:57If their energy is at 35, for example,
  228. 7:59and the individual uses a double jump,
  229. 8:01it drops to 15, leaving them in a
  230. 8:03dangerous situation. If the supercactus
  231. 8:05comes now, they don't have the energy to
  232. 8:07jump. But if it's at 40, it drops to 20
  233. 8:10, guaranteeing another double jump.
  234. 8:13In other words, they learned to expend
  235. 8:16energy freely, as long as it's greater
  236. 8:18than 40. The evolutionary process ended
  237. 8:20up selecting not the individuals that
  238. 8:22conserve energy to the maximum and keep
  239. 8:24it always fixed at 100, but rather the
  240. 8:26individuals that always have 20 energy
  241. 8:28saved.
  242. 8:29They don't need to have energy to spare
  243. 8:32, they need to not have energy shortages
  244. 8:34. These are the situations that make me
  245. 8:37enjoy implementing this type of project
  246. 8:39. Situations where the algorithm
  247. 8:41surprises you and does something smarter
  248. 8:43than you were expecting.
  249. 8:46And speaking of waiting, it is with
  250. 8:48great satisfaction that I tell you, it's
  251. 8:50finally over, because the Programmed
  252. 8:52Universe course has arrived.
  253. 8:58Now you're going to learn real computing
  254. 9:01. In these classes, I'll teach you
  255. 9:04everything you need to create projects
  256. 9:05like the ones on this channel. And when
  257. 9:08I say everything, I mean everything,
  258. 9:09from the fundamentals to the
  259. 9:11implementation.
  260. 9:12First, I'll teach you all the computing
  261. 9:14aspects, starting with binary and going
  262. 9:16all the way to programming logic.
  263. 9:19The classes have interactive animations
  264. 9:20that, in addition to facilitating your
  265. 9:22learning, also make everything much more
  266. 9:24interesting.
  267. 9:25This one, for example, is the class on
  268. 9:27memory.
  269. 9:28You can run this simulator on your
  270. 9:30computer to interact with the memory
  271. 9:32yourself and explore how it works
  272. 9:34however you want.
  273. 9:37After you've learned to program, I'll
  274. 9:38teach you how to use a graphics library
  275. 9:40and we'll create a game just like I do
  276. 9:42here on the channel.
  277. 9:44Then, when our game is ready, we'll move
  278. 9:46on to the machine learning stage. We'll
  279. 9:49start by understanding how algorithms
  280. 9:51work and then we'll implement them. In
  281. 9:54this module, we'll implement a neural
  282. 9:56network from scratch. And finally, we'll
  283. 9:59put it all together and have our neural
  284. 10:01network learn to play the game we
  285. 10:03created.
  286. 10:05In other words, by the end of this
  287. 10:06course, you will have built a project
  288. 10:08from start to finish, just like the one
  289. 10:09you're seeing in this video.
  290. 10:12And all these topics are taught
  291. 10:14gradually, sequentially, and from
  292. 10:16absolute zero.
  293. 10:17A true ladder of knowledge. So, it
  294. 10:20doesn't matter if you know nothing about
  295. 10:22programming or mathematics, you will be
  296. 10:24able to learn.
  297. 10:26And just to be clear, this is a computer
  298. 10:28science course with machine learning,
  299. 10:30and its objective is to give you the
  300. 10:32knowledge base you need to understand
  301. 10:34how algorithms work and thus have the
  302. 10:36autonomy to build your own projects.
  303. 10:39On the course page, there are some free
  304. 10:41lessons for you to try and see if you
  305. 10:43like them. There's also a button to open
  306. 10:46the project we're going to create
  307. 10:48directly in your browser.
  308. 10:50Then you can play around with the
  309. 10:52training parameters and see what happens
  310. 10:53.
  311. 10:54The link to the page is in the video
  312. 10:56description.
  313. 10:57Access is lifetime and the current price
  314. 10:59is a pre-launch promotional value. It
  315. 11:02will be adjusted when the course is
  316. 11:04finished.
  317. 11:06So go ahead, visit the page, try the
  318. 11:08free lessons and the project to find out
  319. 11:10if this course makes sense for you.
  320. 11:13Now, back to the video. Perfect. Since
  321. 11:16they've learned, let's make it more
  322. 11:18difficult.
  323. 11:20First, let's change the color of this
  324. 11:22gray text here, which looks really bad.
  325. 11:25Okay, improved.
  326. 11:27Now let's add two new actions to the
  327. 11:29dinosaur, walking forward and walking
  328. 11:31backward, so that it can move
  329. 11:32horizontally across the scenario.
  330. 11:35And let's see the impact of this on the
  331. 11:36game.
  332. 11:41After 1 hour and 40 minutes of training
  333. 11:43, they are already able to jump over
  334. 11:4511,000 obstacles.
  335. 11:47The first thing you can notice here is
  336. 11:49that when they are about to jump over
  337. 11:51the obstacle, they take a step forward
  338. 11:53and when they finish jumping, they go
  339. 11:54back, as if they were trying to get past
  340. 11:56the obstacle as quickly as possible and
  341. 11:58then recover the distance traveled.
  342. 12:01Also notice the speed and precision with
  343. 12:03which they return to the ground after
  344. 12:06passing the obstacle, making the most of
  345. 12:08every millimeter.
  346. 12:13The second thing is that the double jump
  347. 12:15over birds has curiously reappeared.
  348. 12:19Perhaps this behavior actually gives
  349. 12:21them an advantage, and evolution is
  350. 12:22always going in that same direction.
  351. 12:26The third thing is that now that there's
  352. 12:28horizontal movement, the individual can
  353. 12:29jump over the horizontal super cactus
  354. 12:31without using the double jump.
  355. 12:34And this new possibility has caused the
  356. 12:35population to split into two types of
  357. 12:37individuals.
  358. 12:39And the detail here is that, with the
  359. 12:41way I implemented the energy mechanic,
  360. 12:43if it passes the super cactus without
  361. 12:45using the double jump, it literally
  362. 12:46gains 20 energy, since it didn't spend
  363. 12:48anything to jump.
  364. 12:51In other words, once again the
  365. 12:52evolutionary process found a loophole in
  366. 12:55the game's design and generated
  367. 12:56individuals that take advantage of the
  368. 12:58flaw, individuals that can regenerate
  369. 13:00energy faster than normal.
  370. 13:03And last but not least, they learned to
  371. 13:05stay stuck to the left corner of the
  372. 13:06screen without moving much around the
  373. 13:08scenery.
  374. 13:10And of course, that wasn't the idea.
  375. 13:13So to fix this, we have to give them a
  376. 13:14reason to move around the map, something
  377. 13:16that makes it more advantageous to move
  378. 13:18than to stand still.
  379. 13:21And nothing is better to encourage
  380. 13:23someone to do something than money.
  381. 13:25>> We want money!
  382. 13:27We want money!
  383. 13:29>> Let's add a coin that will randomly
  384. 13:32change position during the game.
  385. 13:35When the individual touches it, they
  386. 13:37will earn some extra points. To start,
  387. 13:39let's set the coin to be worth one point
  388. 13:42, the same value as a cactus, just to
  389. 13:44see what happens.
  390. 13:51And after an hour and 20 minutes of
  391. 13:52training, they learned to play. But to
  392. 13:55our dismay, they are ignoring the coin.
  393. 13:58>> What a shame.
  394. 13:59>> This is probably happening because it
  395. 14:01gives few points.
  396. 14:03So at the beginning of the training, the
  397. 14:05individuals who focused on jumping over
  398. 14:07the cacti ended up earning many more
  399. 14:08points than those who learned to chase
  400. 14:10the coin.
  401. 14:11Then, over generations, this behavior
  402. 14:14was reinforced.
  403. 14:15So, let's increase the number of points
  404. 14:18the coin is worth to five to see what
  405. 14:20happens.
  406. 14:21After about 30 minutes of training, I
  407. 14:23noticed the graph was very stagnant and
  408. 14:25decided to take a look at what was
  409. 14:27happening.
  410. 14:29As you can see, catching the coin is now
  411. 14:31so rewarding that their behavior has
  412. 14:33evolved entirely in that direction.
  413. 14:36They learned to chase the coin perfectly
  414. 14:38, but their jumping ability left
  415. 14:39something to be desired.
  416. 14:42So I interrupted the training, reduced
  417. 14:44the number of coin points to three, and
  418. 14:45put them back to training.
  419. 14:48And this was the result. They remained
  420. 14:50fixated on chasing the coin and didn't
  421. 14:52learn to jump. The record was only 24
  422. 14:55obstacles. So I interrupted the training
  423. 14:58again and reduced it to two points. I
  424. 15:00put them back to training and when I
  425. 15:02looked at the graph, I thought it had
  426. 15:03worked, but it hadn't.
  427. 15:05They simply, ironically, went back to
  428. 15:07ignoring the coin.
  429. 15:10In other words, the problem isn't the
  430. 15:12number of coin points; it's somewhere
  431. 15:14else, and most likely it's here.
  432. 15:17Perhaps the neural network is too small
  433. 15:19.
  434. 15:21Perhaps this size isn't able to store
  435. 15:23and represent both behaviors at the same
  436. 15:26time.
  437. 15:27This means we need to increase its size
  438. 15:30. But the question now is, should we
  439. 15:32increase the width or the depth of the
  440. 15:34network?
  441. 15:35Add more neurons to the existing layer
  442. 15:38or add a new layer?
  443. 15:40If we pay attention to the network in
  444. 15:43operation, it seems that some neurons
  445. 15:45are being activated very little.
  446. 15:47This may indicate that what is lacking
  447. 15:49is not the quantity of neurons, but the
  448. 15:52quantity of layers.
  449. 15:54Perhaps the network doesn't have enough
  450. 15:56complexity to learn to jump and chase
  451. 15:58the coin at the same time.
  452. 16:01So, let's add another layer and see if
  453. 16:03that solves it.
  454. 16:10And to our delight, it worked!
  455. 16:13They are jumping and chasing the coin at
  456. 16:15the same time. At this moment, the best
  457. 16:17individual has already scored more than
  458. 16:1915,000 points. Notice how well they are
  459. 16:21spread across the map.
  460. 16:24Some individuals are giving more
  461. 16:25importance to the coin than others, and
  462. 16:27that's a great sign.
  463. 16:29This demonstrates that the diversity of
  464. 16:32the population is still high, and if we
  465. 16:34wanted, we could leave them here
  466. 16:36training for a few more hours and they
  467. 16:38would get even better.
  468. 16:40Also notice that they are not rushing
  469. 16:43towards the coin like crazy.
  470. 16:45They converge in her direction.
  471. 16:48They get closer, but also move away when
  472. 16:50necessary.
  473. 16:52It's as if they're positioning
  474. 16:54themselves in the scene in such a way
  475. 16:56that the coin is in their path, as if
  476. 16:58the coin isn't the objective of the jump
  477. 17:00but a consequence, a bonus, which makes
  478. 17:02perfect sense.
  479. 17:05And since the coin was just a reason for
  480. 17:07the individuals to move around the scene
  481. 17:08, we can consider that the objective was
  482. 17:10successfully achieved.
  483. 17:12So, of course, let's make it more
  484. 17:14difficult.
  485. 17:18First, let's add a moon, because this
  486. 17:20night is too simple.
  487. 17:22Now, let's add another type of obstacle
  488. 17:24, an obstacle that moves around the
  489. 17:26scene. Let's add a giant ball that will
  490. 17:29come towards them.
  491. 17:32But to be realistic, the ball obviously
  492. 17:33has to roll.
  493. 17:36And for it to roll correctly and not
  494. 17:38look like it's slipping on the ground,
  495. 17:40we have to figure out how much we need
  496. 17:42to increase its angle in each frame of
  497. 17:44the game.
  498. 17:45In other words, we have to find out the
  499. 17:48angular velocity. And finding that
  500. 17:50velocity is actually quite easy. Check
  501. 17:52it out.
  502. 17:54If a point on the ball's surface touches
  503. 17:56every point on the ground, then the ball
  504. 17:58is 100%sliding.
  505. 18:01If a point on the ground touches every
  506. 18:03point on the ball's surface, then the
  507. 18:06ball is 100%sliding.
  508. 18:08Now, if each point on the ball's surface
  509. 18:10touches only a single point on the
  510. 18:12ground, then it's rolling.
  511. 18:15Rolling is the middle ground between
  512. 18:17sliding and slipping.
  513. 18:19And if each point on the ball's surface
  514. 18:22only interacts with a single point on
  515. 18:24the ground, this implies that these two
  516. 18:26lengths will always be equal.
  517. 18:29And now the fun begins.
  518. 18:31>> I'm afraid we'll have to use math.
  519. 18:37>> The blue length is precisely the
  520. 18:38horizontal displacement, which is the
  521. 18:40horizontal velocity times the number of
  522. 18:42frames the ball traveled.
  523. 18:45For the red length, we can use the arc
  524. 18:47length formula.
  525. 18:50According to this formula, a segment of
  526. 18:52the circumference measures exactly pi
  527. 18:54times the radius times the angle divided
  528. 18:57by 180. If we isolate this angle from
  529. 18:59the equation, we will have that the
  530. 19:01angle is equal to the horizontal
  531. 19:02velocity times the number of frames
  532. 19:04times 180, all divided by pi times the
  533. 19:06radius.
  534. 19:09But there's a catch: this angle isn't
  535. 19:11what we're looking for. This angle is
  536. 19:14all of this.
  537. 19:15It's the total angle of the entire
  538. 19:17displacement.
  539. 19:18We need the angular velocity.
  540. 19:21We need to find out the measure of the
  541. 19:23angle of these little segments that,
  542. 19:25along the frames, were added together
  543. 19:27and resulted in the entire path.
  544. 19:31And to find this little angle is simple
  545. 19:33, we just divide the total angle by the
  546. 19:34number of frames that formed it.
  547. 19:37If the object rotated, for example, 200
  548. 19:40degrees in 10 frames, then its angular
  549. 19:42velocity was 20 degrees per frame.
  550. 19:45Now, on the left side of the equation,
  551. 19:47we have the angular velocity.
  552. 19:49But any modification we make to one side
  553. 19:51of the equation must be made to the
  554. 19:53other to maintain equality. So we divide
  555. 19:55the right side by the squares as well.
  556. 19:59Now the squares in the numerator will
  557. 20:01neutralize the squares in the
  558. 20:02denominator, the famous cancellation.
  559. 20:06And on the left side, we can replace the
  560. 20:08fraction with the name of the velocity
  561. 20:09itself.
  562. 20:10And voilà, we found the angular velocity
  563. 20:13.
  564. 20:14It will be 180 times the horizontal
  565. 20:16velocity of the ball divided by pi times
  566. 20:18the radius.
  567. 20:20And since we are the ones who define the
  568. 20:22horizontal velocity and the radius of
  569. 20:24the ball, then our work is done.
  570. 20:26We already have everything necessary to
  571. 20:28calculate the angular velocity.
  572. 20:31If we apply this relationship to the
  573. 20:33game, it's there, spinning perfectly.
  574. 20:36And to give it a special touch, let's
  575. 20:38replace this texture with the Chrome
  576. 20:39icon.
  577. 20:41There, now we're good.
  578. 20:44And to be able to jump this new obstacle
  579. 20:45, we're going to add another action to
  580. 20:47the dinosaur, which is the super jump.
  581. 20:50This jump will work like the normal jump
  582. 20:52, except for the maximum height it
  583. 20:53reaches, which will be much higher.
  584. 20:56It will cost 50 energy, because, well,
  585. 20:58it's pretty overpowered.
  586. 21:00And when the character is going up,
  587. 21:02we're going to change its sprite to this
  588. 21:04one.
  589. 21:05As soon as he's coming down, we'll put
  590. 21:07this one in.
  591. 21:09I tried some other sprites too, like
  592. 21:11these, but they didn't turn out as good
  593. 21:12.
  594. 21:14So the super jump will be like this.
  595. 21:17Now, of course, let's train.
  596. 21:25After 1 hour and 20 minutes of training
  597. 21:27, there it is.
  598. 21:31When Chrome appears, they start walking
  599. 21:34backwards, as if they want to gain time
  600. 21:36or space.
  601. 21:41Notice that they've learned again to use
  602. 21:43the double jump to get over the bird.
  603. 21:45But this time the strategy has changed a
  604. 21:47bit. Now that they need the super jump
  605. 21:50to get past Chrome, their energy can't
  606. 21:53drop below 50. In other words, they've
  607. 21:55learned the same strategy, but adapted
  608. 21:58to the new circumstances.
  609. 22:01The better they get, the harder the
  610. 22:03training becomes, because besides taking
  611. 22:06longer to lose the game, which slows
  612. 22:08down the evolutionary process, the
  613. 22:10random mutations end up spending more
  614. 22:12time worsening the individuals than
  615. 22:14improving them.
  616. 22:16That's why the graph always has more or
  617. 22:18less this format, because at the
  618. 22:20beginning of training, when the
  619. 22:21individual is still bad, any negligible
  620. 22:23little mutation can improve them.
  621. 22:26Then the aptitude increases very quickly
  622. 22:28, but as they improve, these mutations
  623. 22:30become scarce.
  624. 22:32Only a few, very specific ones, will be
  625. 22:34able to improve them even further. All
  626. 22:37the others will ruin them. The moral of
  627. 22:40the story is, the better you get, the
  628. 22:42harder it is to improve.
  629. 22:44It's easier to be good at many things
  630. 22:46than excellent at just one.
  631. 22:49As the game is now, there are many
  632. 22:51obstacles to jump over, and none that
  633. 22:53necessarily require going under.
  634. 22:56So, let's add one.
  635. 23:00Let's add a mountain with a tunnel that
  636. 23:02can only be passed through crouching,
  637. 23:04like a cave.
  638. 23:07I tried to find a cool mountain sprite
  639. 23:08on Google, but none were the way I
  640. 23:10wanted.
  641. 23:11So I went to Gemini and spent a long
  642. 23:13time generating various types of
  643. 23:15mountains. And in the end I chose this
  644. 23:17one for two reasons.
  645. 23:19First, we need the mountain to be tall
  646. 23:22enough to touch the top of the screen;
  647. 23:24otherwise, these guys will find a way to
  648. 23:26get over it.
  649. 23:28Second, the fact that it's somewhat
  650. 23:30square will make calculating the
  651. 23:32collision easier.
  652. 23:34And consequently, it will save us
  653. 23:36processing power, because in this type
  654. 23:38of project, every drop of processing
  655. 23:40power is very precious.
  656. 23:42We already have 500 characters with 500
  657. 23:45neural networks being processed in real
  658. 23:48time.
  659. 23:49The last thing we want is an obstacle
  660. 23:51with a complicated collision that will
  661. 23:53further burden the training.
  662. 23:56And to give the feeling that the
  663. 23:57dinosaurs are passing through the
  664. 23:59mountain, we're going to divide its
  665. 24:00sprite into four layers.
  666. 24:03First, we'll draw this one, which will
  667. 24:04be the background.
  668. 24:06Then, on top of the dinosaurs, we'll
  669. 24:08draw this one, which is similar to the
  670. 24:10background but without the section where
  671. 24:11they pass.
  672. 24:13This serves to give a 3D feel when they
  673. 24:15collide with the mountain, as if they
  674. 24:17were colliding in the middle of it.
  675. 24:20Then, we draw this shadow to reduce the
  676. 24:22brightness of the tunnel and create the
  677. 24:25feeling that it's dark.
  678. 24:27And lastly, we half-closed the doors to
  679. 24:29give the feeling that the dinosaurs are
  680. 24:31passing through them to enter the tunnel
  681. 24:33.
  682. 24:35Perfect. Now let's put them to the test
  683. 24:37.
  684. 24:42And after an incredible 15 minutes, they
  685. 24:45had already mastered the game. They are
  686. 24:47going under the mountain perfectly and
  687. 24:50jumping over the other obstacles
  688. 24:51normally.
  689. 24:53The curious thing is that when they
  690. 24:54enter the mountain, they start walking
  691. 24:56forward as if they want to get out as
  692. 24:57quickly as possible.
  693. 24:59And after they get out, they start going
  694. 25:01back. To tell the truth, I didn't
  695. 25:03understand the point of this behavior. I
  696. 25:05can't see an advantage in getting out of
  697. 25:08the mountain quickly.
  698. 25:10Maybe it's a randomly acquired behavior
  699. 25:12.
  700. 25:14If you see an advantage in this, tell me
  701. 25:15in the comments.
  702. 25:17Okay, this mountain was easy. It didn't
  703. 25:20add much difficulty to the game. In fact
  704. 25:22, it even seems to have made it easier,
  705. 25:24because now they learned much faster.
  706. 25:27So let's add a really difficult obstacle
  707. 25:30.
  708. 25:32Since the game already has obstacles to
  709. 25:34go over and now to go under, let's add
  710. 25:36one to go through the middle.
  711. 25:39Now things are going to get crazy.
  712. 25:42This obstacle is a bit strange to
  713. 25:44imagine, because the top part would be
  714. 25:46kind of floating, disconnected from the
  715. 25:48bottom part.
  716. 25:50The first thing I thought of was the
  717. 25:52pipes from Flappy Bird, but that would
  718. 25:54be too disconnected from the game's
  719. 25:55theme.
  720. 25:57Then I thought of a wall of birds, but
  721. 25:59that would increase the computational
  722. 26:01cost because of the collisions.
  723. 26:04So let's do this: let's put a giant tree
  724. 26:06with a passage in the middle.
  725. 26:08It's not the best solution, but it will
  726. 26:10work well.
  727. 26:12Again, I went to Google to look for a
  728. 26:14tree sprite, but this time I managed to
  729. 26:16find this one.
  730. 26:19It wasn't exactly the way I needed it,
  731. 26:21so I changed its color in Photoshop and
  732. 26:23asked Gemini to add the passage.
  733. 26:26Just like we did with the mountain, the
  734. 26:28tree will also be divided into layers.
  735. 26:32This one will be drawn in the background
  736. 26:34and this one on top of the dinosaur to
  737. 26:35give the 3D feeling that they are
  738. 26:37passing through it.
  739. 26:39Perfect. Now, to pass through the tree,
  740. 26:41we're going to add another action to the
  741. 26:43dinosaur, which will be the dash.
  742. 26:46When the individual uses the dash, it's
  743. 26:47like a quick forward sprint in a
  744. 26:49straight line.
  745. 26:51The amount of movement is fixed, and if
  746. 26:53the individual is in the air, vertical
  747. 26:55movement is interrupted and paused while
  748. 26:58the dash is happening.
  749. 27:00It will cost 30 energy because it's kind
  750. 27:02of overpowered.
  751. 27:05So the idea now is for them to learn to
  752. 27:07position themselves in front of the tree
  753. 27:09passage and use the dash to quickly
  754. 27:10cross it.
  755. 27:13But to make it even more difficult, the
  756. 27:15tree passage will be at a height that
  757. 27:17can only be reached with a double jump.
  758. 27:20In other words, they will have to learn
  759. 27:23to combine two abilities.
  760. 27:25First, they will have to use the double
  761. 27:27jump to reach the height of the passage
  762. 27:29and then use the dash to cross it.
  763. 27:32But before we put them to practice,
  764. 27:34let's change the color of this mountain
  765. 27:35because when I look at it, I can only
  766. 27:37see a mountain of poop.
  767. 27:40Okay, a little better. Let's see if they
  768. 27:43can learn this.
  769. 27:49After about 30 minutes of training, they
  770. 27:52had already mastered the game. But two
  771. 27:55problems appeared.
  772. 27:57First, they managed to get through the
  773. 27:59tree using only the double jump with
  774. 28:01ease.
  775. 28:02Look at the precision of these guys.
  776. 28:04There's no way around it, they always
  777. 28:06take the easiest path. If it's possible
  778. 28:09, it will happen.
  779. 28:10Second, they've gone back to ignoring
  780. 28:12the coins and are stuck in the corner of
  781. 28:15the screen again.
  782. 28:16To solve the tree problem, we'll
  783. 28:18increase its width and decrease the
  784. 28:20height of the passage.
  785. 28:23And if that's still not enough, we'll do
  786. 28:24it again.
  787. 28:26At some point, it will have to become
  788. 28:27impossible to pass without the dash. And
  789. 28:30to solve the coin problem, we'll use the
  790. 28:32final blow. We'll change the reward
  791. 28:35format. As it is now, the reward is only
  792. 28:38given when the individual touches the
  793. 28:40coin.
  794. 28:41If they don't touch it, they get nothing
  795. 28:43, zero.
  796. 28:44This is called a sparse reward.
  797. 28:47In this type of reward, the delivery is
  798. 28:50binary.
  799. 28:51Either we reach the correct state and
  800. 28:53get the entire reward, or we get nothing
  801. 28:55.
  802. 28:56And this isn't very good, because at the
  803. 28:58beginning of training the agent's
  804. 29:00behavior is random.
  805. 29:02And achieving rewards by performing
  806. 29:03random actions is quite improbable.
  807. 29:07This means that, in practice, the agent
  808. 29:09will spend most of its time receiving no
  809. 29:10reward at all.
  810. 29:12And if it receives no reward, its
  811. 29:14behavior doesn't improve.
  812. 29:16And if its behavior doesn't improve, it
  813. 29:18continues to miss out on rewards.
  814. 29:21If the rewards are sparse, the agent
  815. 29:23will be forced to explore the scenario
  816. 29:25blindly.
  817. 29:27It will be forced to guess actions
  818. 29:29thousands of times until it eventually
  819. 29:32gets it right and earns some reward.
  820. 29:35This makes training much slower. And
  821. 29:38depending on the complexity of the
  822. 29:40scenario, it may even be impossible.
  823. 29:43Because the probability of achieving the
  824. 29:46reward with random actions may be very,
  825. 29:49very close to zero.
  826. 29:52So we're going to fix this by
  827. 29:54transforming these sparse rewards into
  828. 29:56dense rewards.
  829. 29:58With dense rewards, it's the opposite.
  830. 30:02We'll provide the agent with small
  831. 30:04rewards all the time, so that every time
  832. 30:06it performs an action, it knows whether
  833. 30:08it helped or not.
  834. 30:11Even if it only helped a little, that's
  835. 30:13enough.
  836. 30:14By transforming the rewards into dense
  837. 30:16rewards, we move from a discrete and
  838. 30:18binary format to a continuous format.
  839. 30:22And this continuity ends up creating a
  840. 30:24path of rewards that will lead the agent
  841. 30:27to the objective.
  842. 30:29In the case of the coin, the reward will
  843. 30:31no longer be whether the individual
  844. 30:32touched it or not, but rather the
  845. 30:34distance they are from it.
  846. 30:36The closer they are, the more they earn
  847. 30:38.
  848. 30:39In this way, the evolutionary process
  849. 30:41will have the ability to distinguish
  850. 30:43which individuals are better, even if no
  851. 30:45one has picked up any coin.
  852. 30:48Just the fact that some are closer to
  853. 30:50the coin than others is enough for
  854. 30:52evolution to prioritize those
  855. 30:53individuals.
  856. 30:55And of course, in the Programmed
  857. 30:57Universe course we will also see all
  858. 30:59these techniques in detail. Okay, let's
  859. 31:02test it.
  860. 31:08After 2 hours and 40 minutes of training
  861. 31:10, there it is, nice and neat. They went
  862. 31:13back to chasing the coin and are now
  863. 31:15using the dash to get past the tree.
  864. 31:17Check out this sequence of dinosaurs
  865. 31:19using the dash, how satisfying.
  866. 31:24And since they managed to learn, we will
  867. 31:25continue.
  868. 31:27But before adding the next obstacle,
  869. 31:28let's improve some sprites.
  870. 31:30First, the Chrome image had a very
  871. 31:33innocuous aspect.
  872. 31:34So I asked Gemini to add some spikes to
  873. 31:37it to make it look more hostile. And
  874. 31:40after a few tries, it looked like this.
  875. 31:42Then, I still thought this image of the
  876. 31:44mountain was too ugly.
  877. 31:46So I took this sprite here, which was
  878. 31:48one of the first ones, changed its color
  879. 31:50to gray, and asked Gemini to put it in
  880. 31:52the shape of Sugarloaf Mountain.
  881. 31:54And there it is, that was the result.
  882. 31:57He removed the mountain doors, but
  883. 31:58that's okay, we'll put them back.
  884. 32:01Perfect.
  885. 32:02Now we're going to put that spike from
  886. 32:04the last video back, but this time there
  887. 32:05won't be a plane to get past it.
  888. 32:08This time the spike will be so long that
  889. 32:10the individual will have to learn to
  890. 32:12combine three abilities to get past it.
  891. 32:15First, they'll have to use the super
  892. 32:17jump, then the double jump, and finally
  893. 32:18the dash.
  894. 32:20Notice that now, to jump over the spike
  895. 32:22, the individuals will need to use all
  896. 32:24their energy.
  897. 32:26This will force them to keep their
  898. 32:28energy at 100 all the time.
  899. 32:30They can no longer waste energy
  900. 32:32unnecessarily. Let's see what happens.
  901. 32:41After 40 minutes, how were they?
  902. 32:44Showing off.
  903. 32:47And as expected, they're no longer using
  904. 32:49the double jump to get over the bird,
  905. 32:51which is a great sign.
  906. 32:54But they're still far from perfect. Here
  907. 32:57, for example, he wasted energy where he
  908. 32:59shouldn't have, and when it came to the
  909. 33:00spike, he lacked the energy to complete
  910. 33:02the combo.
  911. 33:03So let's keep training a little longer
  912. 33:05to see how good they can become.
  913. 33:09Oops, wait a minute, there was a small
  914. 33:10unforeseen event here. This was already
  915. 33:13in the middle of the night, and I simply
  916. 33:15fell asleep while waiting for the
  917. 33:17training to happen.
  918. 33:19In other words, they trained all night,
  919. 33:21and when I woke up, they were like this
  920. 33:24.
  921. 33:33When I woke up, the agents were
  922. 33:34incredibly sharp.
  923. 33:36After more than 8 hours of training, the
  924. 33:38best individual jumped over more than
  925. 33:405,000 obstacles without losing.
  926. 33:43Look at that exponential growth
  927. 33:54; they're trying to buy time for the
  928. 33:56spike to detach from the corner of the
  929. 33:59screen because if they jump with the
  930. 34:01spike stuck, they'll lose.
  931. 34:04So I let them train for another two
  932. 34:06hours, and the best individual reached a
  933. 34:09score of 12,000 obstacles.
  934. 34:12Look how he dodges everything, flowing
  935. 34:14through the scenery, so skillful,
  936. 34:15confident, and unpretentious.
  937. 34:18He's got talent, man, he's got talent.
  938. 34:22Then at that moment I thought, what if
  939. 34:24we remove the energy limit and let the
  940. 34:26individuals use their skills freely, let
  941. 34:28them literally spam their skills?
  942. 34:31What strategy will they learn?
  943. 34:34So I went and retrained them without the
  944. 34:36energy limit.
  945. 34:38And they learned to jump over everything
  946. 34:40with the super jump, which actually
  947. 34:42makes sense.
  948. 34:44Look how they get past the tree now on
  949. 34:45the descent with the super jump.
  950. 34:48But there's a catch.
  951. 34:50Removing the energy cost makes several
  952. 34:52behaviors that weren't possible before
  953. 34:55now possible.
  954. 34:57Therefore, now there are several winning
  955. 34:59strategies, several behaviors that can
  956. 35:02survive the obstacles.
  957. 35:04But during training, the population
  958. 35:06converges on one of them randomly.
  959. 35:09This means that if we put them to train
  960. 35:11again, the next strategy learned may be
  961. 35:14very different from the previous
  962. 35:16strategy.
  963. 35:17And that's exactly what happened.
  964. 35:20I restarted the training and now they've
  965. 35:22learned to do this weird, kind of blocky
  966. 35:24movement, using the super jump to go up
  967. 35:27and the dash to go forward all the time
  968. 35:29.
  969. 35:30When they're in the tree, they use the
  970. 35:32super jump to reach the height of the
  971. 35:33opening and then the dash to go through
  972. 35:35it.
  973. 35:37Look at this craziness, them spamming
  974. 35:38the super jump and pressing down at the
  975. 35:40same time.
  976. 35:45Awesome. Now let's go back to the energy
  977. 35:48limit and continue making the game
  978. 35:50harder.
  979. 35:51But first, one more aesthetic
  980. 35:53improvement.
  981. 35:54Let's add some smoke to the super jump
  982. 35:56and the dash to give a sense of momentum
  983. 35:59.
  984. 36:00Let's improve the tree sprite so that it
  985. 36:02connects to the ground in a more organic
  986. 36:04and natural way.
  987. 36:06I asked Gemini to improve its roots, and
  988. 36:08out of all his exaggerations, the one I
  989. 36:10liked the most was this one.
  990. 36:13Then I tried to improve the dinosaur
  991. 36:15sprites themselves. I asked Gemini to
  992. 36:17replace it with a dinosaur that looks
  993. 36:20angry. And there it is, sensational.
  994. 36:23First, a silly dinosaur, then a cute one
  995. 36:25, and finally a more realistic one.
  996. 36:28The sprites turned out incredibly well.
  997. 36:32However, in the game, the dinosaur is
  998. 36:34drawn very small, so all the details
  999. 36:36from these high-quality sprites end up
  1000. 36:38blending together and looking a bit
  1001. 36:40blurry.
  1002. 36:41So I decided not to mess with our
  1003. 36:44pixelated little dinosaur.
  1004. 36:46Now let's make it harder. We're going to
  1005. 36:48add a bird that comes from the sky
  1006. 36:50towards the dinosaur. If the bird
  1007. 36:52touches it, it's game over.
  1008. 36:54And to avoid that, the dino will be
  1009. 36:56equipped with a weapon. So the challenge
  1010. 36:59now will be learning to aim and shoot at
  1011. 37:02the bird.
  1012. 37:03And the difficulty lies in the fact that
  1013. 37:05the player will have to do this while
  1014. 37:07jumping over obstacles. Dodge and shoot
  1015. 37:10at the same time.
  1016. 37:12Even though all the birds come at the
  1017. 37:14same time, each dinosaur will have its
  1018. 37:16own bird.
  1019. 37:17One dinosaur's shot won't hit another's
  1020. 37:20bird. And one dinosaur's bird won't
  1021. 37:22affect another's dinosaur either. When
  1022. 37:24the bird is red, it means it's in
  1023. 37:26aggressive mode. It's going to attack
  1024. 37:28the dinosaur and smash it. I'm
  1025. 37:31>> going to break you, you crazy thing. I'm
  1026. 37:32serious, I'm going to break you.
  1027. 37:33>> When the bird is blue, it means its
  1028. 37:36dinosaur has already gone to meet God
  1029. 37:38and the bird will retreat.
  1030. 37:41When the bird is gray, kind of
  1031. 37:42transparent, it means the dino managed
  1032. 37:44to hit it with a shot and then,
  1033. 37:45unfortunately, it fell asleep without
  1034. 37:46sleep.
  1035. 37:49The dino can rotate the weapon clockwise
  1036. 37:51or counterclockwise and the weapon will
  1037. 37:52shoot in the direction it's pointed.
  1038. 37:55Rotating and shooting will have to cost
  1039. 37:57energy to prevent the agent from
  1040. 37:59spinning and shooting wildly. Therefore
  1041. 38:02, we'll have to increase the dino's
  1042. 38:04energy. Let's put it at about 120 just
  1043. 38:06to start.
  1044. 38:08For the agent to be able to see the bird
  1045. 38:10, we'll pass it the distance and angle
  1046. 38:12between it and the bird.
  1047. 38:14This is called polar coordinates. But
  1048. 38:17there's a problem. The angle is a
  1049. 38:19circular metric.
  1050. 38:210º is equal to 360º.
  1051. 38:241º is very similar to 359º. This will
  1052. 38:28confuse the neural network.
  1053. 38:30It will have to learn to treat the
  1054. 38:32minimum value the same way it treats the
  1055. 38:34maximum value.
  1056. 38:36And this goes a little against how a
  1057. 38:37neural network works.
  1058. 38:39Is it possible? Yes, but it will
  1059. 38:41unnecessarily hinder learning.
  1060. 38:44So, instead of passing us the raw angle
  1061. 38:46, we'll pass us its sine and cosine.
  1062. 38:50This way, we can break down a circular
  1063. 38:52quantity into two linear quantities.
  1064. 38:55Now, let's go, let's train.
  1065. 39:03And now things got really much harder,
  1066. 39:06because they had to train for 4 hours to
  1067. 39:08reach a reasonable level.
  1068. 39:11In the beginning, there are some crazy
  1069. 39:13ones who just shoot randomly and
  1070. 39:14immediately run out of energy and lose
  1071. 39:16the game.
  1072. 39:17In the first attack by the birds, half
  1073. 39:19the population is already down.
  1074. 39:22This happens because, as we've already
  1075. 39:23said, at the end of the training, the
  1076. 39:25random mutations end up doing more harm
  1077. 39:27than good to the individuals.
  1078. 39:29We can see the evolutionary process as a
  1079. 39:32search process.
  1080. 39:33We are looking for a set of values,
  1081. 39:36literally a list of numbers that, when
  1082. 39:39inserted into the weights of the neural
  1083. 39:42network connections, make them behave
  1084. 39:45the way we want, in a winning way.
  1085. 39:48This is the best individual so far.
  1086. 39:50Check out his headshots.
  1087. 39:56But even though they had learned, they
  1088. 39:59went back to ignoring the coins and
  1089. 40:01sticking to the wall. But now this makes
  1090. 40:04a lot of sense.
  1091. 40:06If they keep chasing the coin, they'll
  1092. 40:08be forced to learn to shoot in a 180-
  1093. 40:10degree range, because the bird can come
  1094. 40:12from any direction.
  1095. 40:16But if they stick to the wall, they
  1096. 40:17reduce that range to 90 degrees, which
  1097. 40:20is much easier.
  1098. 40:22And since hitting the bird is worth more
  1099. 40:24than getting the coin, they end up
  1100. 40:26converging on this strategy.
  1101. 40:28Obviously, this wasn't the result I
  1102. 40:30expected.
  1103. 40:31This behavior of sticking to the wall
  1104. 40:33greatly reduced the difficulty of
  1105. 40:35shooting the birds.
  1106. 40:37So I started thinking about ways to
  1107. 40:39solve this and came up with an
  1108. 40:40interesting solution.
  1109. 40:43Notice that the act of jumping over
  1110. 40:45obstacles is quite independent of the
  1111. 40:47act of shooting.
  1112. 40:49It's as if they were two distinct tasks
  1113. 40:52in the same agent. Then I thought, what
  1114. 40:54if we use two neural networks? One just
  1115. 40:58to avoid obstacles and the other just to
  1116. 41:00shoot. Like GTA, while one drives, the
  1117. 41:03other shoots.
  1118. 41:05And best of all, if we separate the
  1119. 41:07agent's neural network into two, we can
  1120. 41:10reuse a network that we've already
  1121. 41:12trained.
  1122. 41:14We can reuse that neural network that
  1123. 41:16already knows how to jump over obstacles
  1124. 41:19very well. Then we'll only need to train
  1125. 41:21the network that shoots. So that's
  1126. 41:24exactly what we're going to do. Here we
  1127. 41:27have two separate networks. The top one
  1128. 41:29only shoots, and the bottom one jumps
  1129. 41:32and chases the coin.
  1130. 41:34The top network starts completely random
  1131. 41:36because it's the one that will be
  1132. 41:38refined during training.
  1133. 41:41For the bottom network, we'll load that
  1134. 41:44agent that trained for 10 hours and
  1135. 41:46jumped over 12,000 obstacles.
  1136. 41:48We'll put its neural network into all
  1137. 41:51the individuals in this new training.
  1138. 41:54Everyone will have the same neural
  1139. 41:56network that jumps.
  1140. 41:57Only the network that shoots will be
  1141. 41:59different for each one.
  1142. 42:01During training, the bottom network will
  1143. 42:03remain frozen. It won't be modified in
  1144. 42:06any way. And since it already knows how
  1145. 42:08to chase the coin, it will move around
  1146. 42:10the scenario normally.
  1147. 42:13In other words, the jumping network's
  1148. 42:15behavior will force the other network to
  1149. 42:17learn to shoot in a 180-degree circle.
  1150. 42:20And this strategy worked incredibly well
  1151. 42:24.
  1152. 42:25In just 5 minutes of training, the
  1153. 42:27shooting neural network had already
  1154. 42:29managed to take down 700 birds.
  1155. 42:32Look how they're doing it.
  1156. 42:34The bottom network is moving around the
  1157. 42:35scene, while the top one protects from
  1158. 42:37the birds.
  1159. 42:38Awesome.
  1160. 42:39Now there's just one little thing
  1161. 42:41missing to make it perfect. The bird is
  1162. 42:44taking too long to return.
  1163. 42:46Let's make a new bird appear as soon as
  1164. 42:49the previous one is shot down, so it
  1165. 42:51keeps shooting all the time.
  1166. 42:54Now that's crazy!
  1167. 42:57Check them out shooting during the jump
  1168. 42:58. Amazing.
  1169. 43:03We started like this, now we're like
  1170. 43:06this.
  1171. 43:07The secret is always to start with the
  1172. 43:09simple things that work and only then
  1173. 43:11increase and improve them.
  1174. 43:13If you start straight with the complex,
  1175. 43:15errors will appear and you won't be able
  1176. 43:17to find where they are.
  1177. 43:20Here I realized that the video was
  1178. 43:22getting gigantic and that the AI hadn't
  1179. 43:23given any sign that it would be defeated
  1180. 43:25.
  1181. 43:26So there's no way around it.
  1182. 43:28If you want this video to have a sequel
  1183. 43:30so we can improve it even more until the
  1184. 43:32game becomes literally impossible, let
  1185. 43:34me know in the comments.
  1186. 43:37While you're at it, leave me a
  1187. 43:38suggestion for what mechanics would be
  1188. 43:40interesting to add to the game.
  1189. 43:43If you want to play this modified
  1190. 43:44version of the game, it's available here
  1191. 43:46in the channel's members area.
  1192. 43:48Just go there and download it.
  1193. 43:50And of course, the link to the course
  1194. 43:52where I'll teach you everything you saw
  1195. 43:53in this video is in the description.
  1196. 43:56See you soon!

About this transcript

This page contains the full transcript of Inteligência Artificial DESTRUINDO no Dino Chrome 2.0 by Universo Programado, generated from the public captions YouTube serves with the video. The transcript has 7,156 words across 1,196 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.