1 00:00:00,080 --> 00:00:01,660 The following content is provided 2 00:00:01,660 --> 00:00:03,800 under a Creative Commons license. 3 00:00:03,800 --> 00:00:06,540 Your support will help MIT OpenCourseWare continue 4 00:00:06,540 --> 00:00:10,150 to offer high quality educational resources for free. 5 00:00:10,150 --> 00:00:12,690 To make a donation or to view additional materials 6 00:00:12,690 --> 00:00:16,600 from hundreds of MIT courses, visit MIT OpenCourseWare 7 00:00:16,600 --> 00:00:17,260 at ocw.mit.edu. 8 00:00:27,340 --> 00:00:30,220 PROFESSOR: So I'll be sitting down here and showing you 9 00:00:30,220 --> 00:00:33,970 a whole lot of really cool videos on YouTube, 10 00:00:33,970 --> 00:00:38,380 and battlecode players that I have programmed especially 11 00:00:38,380 --> 00:00:39,440 for tonight. 12 00:00:39,440 --> 00:00:41,730 So here we go. 13 00:00:41,730 --> 00:00:44,220 What's the point here? 14 00:00:44,220 --> 00:00:47,950 The point here is to talk about the things that 15 00:00:47,950 --> 00:00:52,350 have been done before in swarm, and thinking about swarm. 16 00:00:52,350 --> 00:00:55,660 So let's go straight to a YouTube video 17 00:00:55,660 --> 00:00:59,600 and look at this animation. 18 00:00:59,600 --> 00:01:04,379 So you can see here, there will be these birds that 19 00:01:04,379 --> 00:01:10,510 are following the green blob, and they avoid the red blob. 20 00:01:10,510 --> 00:01:15,460 And what they're trying to do is match one another's direction, 21 00:01:15,460 --> 00:01:18,920 try to get a certain distance from the other birds, 22 00:01:18,920 --> 00:01:20,647 and try to avoid obstacles. 23 00:01:20,647 --> 00:01:22,230 And so you can see how the combination 24 00:01:22,230 --> 00:01:26,640 of a few simple rules can create a behavior that's 25 00:01:26,640 --> 00:01:29,590 sort of complicated looking, or a behavior that's 26 00:01:29,590 --> 00:01:30,450 somewhat fluid. 27 00:01:30,450 --> 00:01:32,110 Whereas if you had manually tried 28 00:01:32,110 --> 00:01:35,060 to get them all to go in the same direction, 29 00:01:35,060 --> 00:01:36,870 it might have looked somewhat more rigid. 30 00:01:36,870 --> 00:01:38,870 And it might not have been able to handle things 31 00:01:38,870 --> 00:01:40,010 like obstacles. 32 00:01:40,010 --> 00:01:44,230 So let's look at another video of how this is done in nature. 33 00:01:44,230 --> 00:01:46,880 Now, this is a massive number of birds. 34 00:01:46,880 --> 00:01:51,110 I think in the video description it says this is 300,000 birds. 35 00:01:51,110 --> 00:01:51,895 Wow. 36 00:01:51,895 --> 00:01:58,450 And it's so pretty how it undulates and smushes around. 37 00:01:58,450 --> 00:02:00,340 Here's another view of the same thing. 38 00:02:00,340 --> 00:02:02,900 I think they'll all take off in the distance. 39 00:02:02,900 --> 00:02:04,530 Look at how pretty that is. 40 00:02:04,530 --> 00:02:06,890 And the all sort of do it once, but there's certainly 41 00:02:06,890 --> 00:02:09,240 nobody in control. 42 00:02:09,240 --> 00:02:13,340 What a pretty-- ah, you've got to love pictures of nature, 43 00:02:13,340 --> 00:02:15,980 in the evening, in a lecture hall. 44 00:02:15,980 --> 00:02:18,120 We're about as far from nature as people can get. 45 00:02:18,120 --> 00:02:19,786 My goodness. 46 00:02:19,786 --> 00:02:21,050 Ah, that's so pleasing. 47 00:02:21,050 --> 00:02:23,010 When are they going to show the birds? 48 00:02:23,010 --> 00:02:25,240 I'm referring to the birds that aren't in the water. 49 00:02:25,240 --> 00:02:27,110 The birds in the air, yeah. 50 00:02:27,110 --> 00:02:30,470 So what we want to do today is just 51 00:02:30,470 --> 00:02:33,940 talk about the things that are recognized 52 00:02:33,940 --> 00:02:35,720 as elements of swarm behavior. 53 00:02:35,720 --> 00:02:38,190 And then we'll show how our robots 54 00:02:38,190 --> 00:02:41,670 can do much better than the enemy robots if we do it right. 55 00:02:41,670 --> 00:02:42,320 Look at this. 56 00:02:42,320 --> 00:02:45,480 It's almost like two separate swarms in certain areas. 57 00:02:45,480 --> 00:02:48,980 And it's an interesting problem to say, at what point 58 00:02:48,980 --> 00:02:51,542 is it possible to split into two swarms? 59 00:02:51,542 --> 00:02:53,750 Because maybe one of them got too far from the other, 60 00:02:53,750 --> 00:02:56,350 or maybe it's just too gosh darn big. 61 00:02:56,350 --> 00:02:59,280 Or maybe one half of them are Democrats, the other half 62 00:02:59,280 --> 00:03:00,650 Republicans. 63 00:03:00,650 --> 00:03:02,550 There are a lot of reasons that they 64 00:03:02,550 --> 00:03:05,140 might want to split into parts. 65 00:03:05,140 --> 00:03:08,410 So we'll talk about that too. 66 00:03:08,410 --> 00:03:10,250 Next, we'll talk about crowds. 67 00:03:10,250 --> 00:03:12,550 I mean, this is a thing that you deal with every day 68 00:03:12,550 --> 00:03:15,680 when you go to eat battlecode lecture dinner. 69 00:03:15,680 --> 00:03:19,990 You come up here, and there's people trying to get to food. 70 00:03:19,990 --> 00:03:21,240 And I guess the food is there. 71 00:03:21,240 --> 00:03:23,060 No, this is a bad example, because these guys are just 72 00:03:23,060 --> 00:03:24,900 going to walk through one another. 73 00:03:24,900 --> 00:03:29,370 And the goal is trying to get them to anticipate 74 00:03:29,370 --> 00:03:31,730 who isn't going to be in the way, and to form lanes. 75 00:03:31,730 --> 00:03:35,520 That was the problem that these guys were trying to address. 76 00:03:35,520 --> 00:03:37,640 And I guess nowadays it's becoming 77 00:03:37,640 --> 00:03:40,600 popular to post your thesis material online 78 00:03:40,600 --> 00:03:42,630 and to animate it in 3D. 79 00:03:42,630 --> 00:03:44,380 I don't see why this is animated in 3D. 80 00:03:44,380 --> 00:03:45,796 You could just show the same thing 81 00:03:45,796 --> 00:03:47,470 with a two dimensional map. 82 00:03:47,470 --> 00:03:50,570 Now here you're going to see ripples form. 83 00:03:50,570 --> 00:03:53,590 And that's the expectation path. 84 00:03:53,590 --> 00:03:57,110 And so a small perturbation in the position of someone 85 00:03:57,110 --> 00:04:00,780 is amplified into like avoid this lane. 86 00:04:00,780 --> 00:04:04,050 And here he shows it again with some lines. 87 00:04:04,050 --> 00:04:06,840 He does it with more people, because every computer 88 00:04:06,840 --> 00:04:09,030 scientist knows that more is better, especially 89 00:04:09,030 --> 00:04:10,710 when it comes to simulations. 90 00:04:10,710 --> 00:04:14,595 And so he shows a bunch of them, and how these guys 91 00:04:14,595 --> 00:04:16,519 are going up, those guys are going down there. 92 00:04:16,519 --> 00:04:19,050 And they sort of make this vortex. 93 00:04:19,050 --> 00:04:20,230 And I think-- oh, yeah. 94 00:04:20,230 --> 00:04:20,730 I remember. 95 00:04:20,730 --> 00:04:22,079 This is really silly. 96 00:04:22,079 --> 00:04:24,010 The end of this video, you're not 97 00:04:24,010 --> 00:04:25,450 going to see it coming at all. 98 00:04:25,450 --> 00:04:28,170 You're thinking, all right, where can he go from here? 99 00:04:28,170 --> 00:04:30,220 He can show-- so there's their model, 100 00:04:30,220 --> 00:04:32,030 and there's some alternative models 101 00:04:32,030 --> 00:04:34,619 showing that their model is a lot better because people 102 00:04:34,619 --> 00:04:35,410 aren't bunching up. 103 00:04:35,410 --> 00:04:38,900 So there's these high ES low and high distance models. 104 00:04:38,900 --> 00:04:41,420 Which basically, the guys are just avoiding one another. 105 00:04:41,420 --> 00:04:44,070 But in their model, they're sort of creating a density 106 00:04:44,070 --> 00:04:47,770 field for an expected position. 107 00:04:47,770 --> 00:04:50,110 I think this is supposed to be simulating armies. 108 00:04:50,110 --> 00:04:52,760 I guess they want a job at Pixar or whatever. 109 00:04:52,760 --> 00:04:54,812 And so they just sort of put this one in here, 110 00:04:54,812 --> 00:04:56,770 like oh, look at how realistic your armies will 111 00:04:56,770 --> 00:04:59,200 look if people at the back move 10 times as fast. 112 00:04:59,200 --> 00:05:01,660 [LAUGHTER] 113 00:05:01,660 --> 00:05:03,980 PROFESSOR: And then another army is over here. 114 00:05:03,980 --> 00:05:06,960 Because just like I said, these computer science people 115 00:05:06,960 --> 00:05:09,560 like nothing more than to have a lot of things. 116 00:05:09,560 --> 00:05:12,190 I once saw a simulation. 117 00:05:12,190 --> 00:05:13,250 Oh, this was crazy. 118 00:05:13,250 --> 00:05:16,130 It was a simulation of neutronics. 119 00:05:16,130 --> 00:05:18,202 So this is like a college campus. 120 00:05:18,202 --> 00:05:20,660 I mean, you could really tell where this guy's coming from. 121 00:05:20,660 --> 00:05:21,507 Movies, campus. 122 00:05:21,507 --> 00:05:23,590 And it's like people are coming from certain doors 123 00:05:23,590 --> 00:05:24,310 and going to others. 124 00:05:24,310 --> 00:05:26,934 And I think the next shot he'll show the paths of these people, 125 00:05:26,934 --> 00:05:29,610 showing that they're not bumping into each other that much, 126 00:05:29,610 --> 00:05:31,560 and that they're kind of straightish paths. 127 00:05:31,560 --> 00:05:33,290 Which is supposed to be very impressive. 128 00:05:33,290 --> 00:05:34,665 But back to my other story, I was 129 00:05:34,665 --> 00:05:36,350 watching a neutronics simulation. 130 00:05:36,350 --> 00:05:38,840 And it had like 2 billion particles in it 131 00:05:38,840 --> 00:05:39,966 that were all in a lattice. 132 00:05:39,966 --> 00:05:42,381 OK, I'm going to pause this here when it gets to the city. 133 00:05:42,381 --> 00:05:43,270 I mean, my goodness. 134 00:05:43,270 --> 00:05:44,720 How more complete do you need? 135 00:05:44,720 --> 00:05:45,850 Once you've seen it, you've kind of seen it. 136 00:05:45,850 --> 00:05:48,230 But anyway, this 2 billion particle lattice, which took 137 00:05:48,230 --> 00:05:50,690 like 10 hours on a giant supercomputer 138 00:05:50,690 --> 00:05:54,390 to do this simulation of damage from radiation, 139 00:05:54,390 --> 00:05:57,010 from like high energy particle radiation. 140 00:05:57,010 --> 00:06:03,090 And the final result of this massive simulation that I saw, 141 00:06:03,090 --> 00:06:06,810 it was to show that this one incoming particle had 142 00:06:06,810 --> 00:06:09,540 ricocheted in a couple of ways. 143 00:06:09,540 --> 00:06:11,794 And the diagram of this final result 144 00:06:11,794 --> 00:06:13,210 from this giant computation, which 145 00:06:13,210 --> 00:06:14,990 was like the very end of his presentation, 146 00:06:14,990 --> 00:06:15,950 because for some reason people don't 147 00:06:15,950 --> 00:06:17,610 like to show the graphics first. 148 00:06:17,610 --> 00:06:19,399 They like to tell you all the words first. 149 00:06:19,399 --> 00:06:20,940 In any case, he showed me this thing. 150 00:06:20,940 --> 00:06:23,990 And it's like a little hook or something. 151 00:06:23,990 --> 00:06:25,460 It was really stupid looking. 152 00:06:25,460 --> 00:06:26,740 Oh, my goodness. 153 00:06:26,740 --> 00:06:27,740 Can't believe it. 154 00:06:27,740 --> 00:06:29,180 But no, this guy's final result is 155 00:06:29,180 --> 00:06:30,650 going to be much more exciting. 156 00:06:30,650 --> 00:06:31,750 So he's got these people, and he's 157 00:06:31,750 --> 00:06:33,240 like, well, this isn't realistic. 158 00:06:33,240 --> 00:06:35,630 In a real city, there are cars. 159 00:06:35,630 --> 00:06:38,470 So you've got to only walk on the crosswalks. 160 00:06:38,470 --> 00:06:41,840 And you've got to avoid certain things. 161 00:06:41,840 --> 00:06:44,550 Maybe you form lanes of traffic on these crosswalks kind 162 00:06:44,550 --> 00:06:45,400 of automatically. 163 00:06:45,400 --> 00:06:46,530 Oh, now he's getting more. 164 00:06:46,530 --> 00:06:49,220 He's like, OK, I've got too much time on my hands. 165 00:06:49,220 --> 00:06:52,034 I better implement stop lights. 166 00:06:52,034 --> 00:06:53,450 But it's still not that realistic, 167 00:06:53,450 --> 00:06:55,720 because what if people get hit by cars? 168 00:06:55,720 --> 00:06:57,910 There are no cars to hit people, or to almost 169 00:06:57,910 --> 00:06:59,430 hit them, or to scare them and get 170 00:06:59,430 --> 00:07:00,790 them to jump out of the way. 171 00:07:00,790 --> 00:07:05,730 So now we've got a 3D flyover, because the only thing 172 00:07:05,730 --> 00:07:07,940 cooler than having a 3D environment 173 00:07:07,940 --> 00:07:11,080 is a slow pan and zoom. 174 00:07:11,080 --> 00:07:12,980 So that's what he's sort of doing here. 175 00:07:12,980 --> 00:07:15,310 And he puts the cars in. 176 00:07:15,310 --> 00:07:16,830 Obviously, he has excellent taste. 177 00:07:16,830 --> 00:07:19,870 All the cars are from 1970. 178 00:07:19,870 --> 00:07:21,660 And I guess there's jaywalking. 179 00:07:21,660 --> 00:07:22,160 Oh, right. 180 00:07:22,160 --> 00:07:26,460 This is like a chemical evacuation or something, 181 00:07:26,460 --> 00:07:29,210 so all these people are covered in yellow stuff. 182 00:07:29,210 --> 00:07:30,600 And they're running away. 183 00:07:30,600 --> 00:07:34,900 And that's supposed to be really useful for planning evacuations 184 00:07:34,900 --> 00:07:36,580 and such. 185 00:07:36,580 --> 00:07:37,080 Yeah. 186 00:07:37,080 --> 00:07:39,290 And everybody else is just like, OK, 187 00:07:39,290 --> 00:07:43,320 I'm going to worry about that three, two, one, now. 188 00:07:43,320 --> 00:07:47,810 And then the other people start running away, too. 189 00:07:47,810 --> 00:07:49,650 They have really bad reaction time. 190 00:07:49,650 --> 00:07:52,840 And then this is like, people are walking in the street, 191 00:07:52,840 --> 00:07:54,950 and how it's messing up traffic. 192 00:07:54,950 --> 00:07:56,840 And it's like, wow, this traffic is 193 00:07:56,840 --> 00:07:59,640 almost as bad as New York City traffic. 194 00:07:59,640 --> 00:08:01,010 Almost as bad. 195 00:08:01,010 --> 00:08:02,900 And then, I mean, what else can this guy 196 00:08:02,900 --> 00:08:04,950 do after he's done this many things? 197 00:08:04,950 --> 00:08:07,055 Well, the last thing that he has is aliens. 198 00:08:07,055 --> 00:08:08,910 [LAUGHTER] 199 00:08:08,910 --> 00:08:10,920 PROFESSOR: So there you go. 200 00:08:10,920 --> 00:08:13,300 Just to show that everybody likes 201 00:08:13,300 --> 00:08:17,040 to have a little bit of fun with pathing and navigation. 202 00:08:17,040 --> 00:08:19,820 So let's talk a little bit about the things 203 00:08:19,820 --> 00:08:22,430 that we saw in those videos. 204 00:08:22,430 --> 00:08:24,720 and how they apply to battlecode. 205 00:08:24,720 --> 00:08:27,160 So there's a whole question of centralized 206 00:08:27,160 --> 00:08:28,800 versus decentralized control. 207 00:08:28,800 --> 00:08:31,086 And in the ones that we saw, they weren't centralized. 208 00:08:31,086 --> 00:08:32,460 So I'm going to show you examples 209 00:08:32,460 --> 00:08:34,980 in battlecode of both of those. 210 00:08:34,980 --> 00:08:38,299 Now, those can have impacts on whether there's 211 00:08:38,299 --> 00:08:41,620 a radio attack possible, whether your strategy's going 212 00:08:41,620 --> 00:08:43,990 to be vulnerable to that. 213 00:08:43,990 --> 00:08:46,880 Whether it's like a map dependent strategy, 214 00:08:46,880 --> 00:08:50,030 because maybe on a centralized controller, 215 00:08:50,030 --> 00:08:51,940 it works really well if it's a tiny map. 216 00:08:51,940 --> 00:08:53,440 But maybe if it's a huge map, you've 217 00:08:53,440 --> 00:08:56,060 got to start having multiple swarms that are independent. 218 00:08:56,060 --> 00:09:00,060 And talking about distributing information 219 00:09:00,060 --> 00:09:03,380 is another thing to worry about it. 220 00:09:03,380 --> 00:09:07,110 So let's consider that in the boyds model, which 221 00:09:07,110 --> 00:09:10,520 is supposed to sound like birds if you have a Brooklyn accent, 222 00:09:10,520 --> 00:09:15,460 they considered several aspects for computing the next position 223 00:09:15,460 --> 00:09:18,550 for each actor in the swarm. 224 00:09:18,550 --> 00:09:22,110 The separation of each one to its neighbors. 225 00:09:22,110 --> 00:09:25,750 The pushing together of each one, which they call cohesion, 226 00:09:25,750 --> 00:09:27,720 because the smarter you sound, the more 227 00:09:27,720 --> 00:09:31,430 Ph.D. Money and grant money you can make. 228 00:09:31,430 --> 00:09:34,367 They talk about alignment so that everybody's 229 00:09:34,367 --> 00:09:35,450 facing the same direction. 230 00:09:35,450 --> 00:09:37,180 Now, that's somewhat different this year 231 00:09:37,180 --> 00:09:39,780 than it has been in past battlecode years. 232 00:09:39,780 --> 00:09:43,220 And then I guess they don't talk too much about it, 233 00:09:43,220 --> 00:09:49,090 but they considered the later effects of group splitting 234 00:09:49,090 --> 00:09:53,100 and lane creation, which we saw today. 235 00:09:53,100 --> 00:09:54,930 So let's see here. 236 00:09:54,930 --> 00:09:57,420 I showed some examples of these things. 237 00:09:57,420 --> 00:09:59,660 Alignment this year is worth noting 238 00:09:59,660 --> 00:10:05,450 that there used to be a method where you could take the robot 239 00:10:05,450 --> 00:10:07,210 info and do dot direction. 240 00:10:07,210 --> 00:10:10,650 You could get the direction of any robot that you can see. 241 00:10:10,650 --> 00:10:13,140 Now, in this year's battlecode, there's no direction. 242 00:10:13,140 --> 00:10:14,640 So what are you going to do? 243 00:10:14,640 --> 00:10:16,350 So let's see here. 244 00:10:16,350 --> 00:10:18,760 You can get the distances for separation and cohesion. 245 00:10:18,760 --> 00:10:20,520 I mean, these are just a fancy way 246 00:10:20,520 --> 00:10:23,200 of just saying there's like a spring between you 247 00:10:23,200 --> 00:10:23,870 and the others. 248 00:10:23,870 --> 00:10:28,130 And this one is just saying that you're headed the right way. 249 00:10:28,130 --> 00:10:30,446 There's really almost nothing complicated to it. 250 00:10:30,446 --> 00:10:32,820 And we're going to end up seeing some pretty neat looking 251 00:10:32,820 --> 00:10:35,780 behavior from very simple rules. 252 00:10:35,780 --> 00:10:37,900 So yeah, let's talk about how you're 253 00:10:37,900 --> 00:10:40,570 going to know that you're facing the right direction. 254 00:10:40,570 --> 00:10:42,690 I mean, you could check all the neighbors. 255 00:10:42,690 --> 00:10:46,210 Let's see here, face the right direction. 256 00:10:46,210 --> 00:10:48,690 You could check all the neighbors 257 00:10:48,690 --> 00:10:50,700 against all the other ones. 258 00:10:50,700 --> 00:10:54,120 So you'd be checking to see if robot 259 00:10:54,120 --> 00:10:57,150 ID number 97 was from this position, and then that one. 260 00:10:57,150 --> 00:10:59,290 And then you would try to find where he was, 261 00:10:59,290 --> 00:11:01,210 and correlate that, and get the direction. 262 00:11:01,210 --> 00:11:03,910 And then take an average for all the robots that you can see. 263 00:11:03,910 --> 00:11:06,140 That would be really computationally expensive. 264 00:11:06,140 --> 00:11:08,410 Another option is to say, all right, 265 00:11:08,410 --> 00:11:12,950 take average of all allied robots. 266 00:11:12,950 --> 00:11:16,500 Or all within a range. 267 00:11:16,500 --> 00:11:20,700 And then see how that average moves. 268 00:11:20,700 --> 00:11:22,280 So that's like an implicit direction 269 00:11:22,280 --> 00:11:25,520 for the group of allied robots. 270 00:11:25,520 --> 00:11:28,500 And then an individual robot, by doing that, 271 00:11:28,500 --> 00:11:30,030 could see where all of them are. 272 00:11:30,030 --> 00:11:32,430 Another option is just to radio broadcast 273 00:11:32,430 --> 00:11:35,720 so that somebody somewhere is deciding what direction to go. 274 00:11:35,720 --> 00:11:38,650 Or maybe all of them vote on the direction that they want to go, 275 00:11:38,650 --> 00:11:40,608 because maybe some of them are close to enemies 276 00:11:40,608 --> 00:11:42,260 and other ones are standing on mines. 277 00:11:42,260 --> 00:11:44,600 And maybe they want to put it up to a vote 278 00:11:44,600 --> 00:11:46,180 so that they can wait for 50 turns 279 00:11:46,180 --> 00:11:48,750 before finding out which direction they're 280 00:11:48,750 --> 00:11:51,639 going to go, and end up going in the wrong direction anyway. 281 00:11:51,639 --> 00:11:53,430 Or they could have a recount, and anything. 282 00:11:53,430 --> 00:11:54,800 It could be really fun. 283 00:11:54,800 --> 00:11:58,710 You could do like a whole political simulation. 284 00:11:58,710 --> 00:12:01,970 So here are some considerations when 285 00:12:01,970 --> 00:12:05,140 you're talking about central control versus the group mind. 286 00:12:05,140 --> 00:12:09,070 Where the central controller, you'd need a leader. 287 00:12:09,070 --> 00:12:12,510 And so leaders have to have elections, 288 00:12:12,510 --> 00:12:17,640 and they also can die, and sometimes they get lost. 289 00:12:17,640 --> 00:12:20,400 So those are things to worry about when you have a leader. 290 00:12:20,400 --> 00:12:23,670 That means that the headquarters is a good choice. 291 00:12:26,640 --> 00:12:29,700 And so if you can do all of your computations in one place, 292 00:12:29,700 --> 00:12:31,380 that's much more efficient. 293 00:12:35,020 --> 00:12:37,710 Imagine if you had to-- every robot 294 00:12:37,710 --> 00:12:39,170 has all the same information. 295 00:12:39,170 --> 00:12:41,519 But if all of them make the decisions, 296 00:12:41,519 --> 00:12:43,310 then they all have to do a lot of thinking. 297 00:12:43,310 --> 00:12:46,900 And in this game, if you use up 10,000 byte codes, 298 00:12:46,900 --> 00:12:49,500 each of those robots is going to have twice the power upkeep. 299 00:12:49,500 --> 00:12:51,380 It's going to be pretty significant. 300 00:12:51,380 --> 00:12:56,610 So you could have the leader broadcast all kinds of things. 301 00:12:56,610 --> 00:13:00,371 And later on we're going to talk about some more little details 302 00:13:00,371 --> 00:13:02,870 of what the leader can broadcast besides just what direction 303 00:13:02,870 --> 00:13:06,490 you're going in that can really save you a lot of trouble. 304 00:13:06,490 --> 00:13:09,430 If you have a group mind, it's a little different. 305 00:13:09,430 --> 00:13:12,510 You can have a better site range, 306 00:13:12,510 --> 00:13:14,330 which is to say that in previous years 307 00:13:14,330 --> 00:13:16,465 you were limited to just one robot site range. 308 00:13:16,465 --> 00:13:18,090 So having a group mind sort of gave you 309 00:13:18,090 --> 00:13:21,109 more access to the edges of your cloud. 310 00:13:21,109 --> 00:13:23,150 And you could also make it so that the front guys 311 00:13:23,150 --> 00:13:23,990 are leading. 312 00:13:23,990 --> 00:13:26,600 Which would be really useful so that you 313 00:13:26,600 --> 00:13:28,360 could have them be the first ones to note. 314 00:13:28,360 --> 00:13:30,760 This year it's not so important. 315 00:13:30,760 --> 00:13:32,821 But in like a real flock of birds or something 316 00:13:32,821 --> 00:13:34,570 you might develop after this, it would be. 317 00:13:34,570 --> 00:13:37,801 You can also broadcast of the enemy locations in a group 318 00:13:37,801 --> 00:13:38,300 mind. 319 00:13:38,300 --> 00:13:40,596 There's no reason why a group mind can't use broadcast. 320 00:13:40,596 --> 00:13:43,220 It's just a question of whether you expect to receive something 321 00:13:43,220 --> 00:13:44,860 from a single entity, or whether you 322 00:13:44,860 --> 00:13:47,020 expect to integrate a bunch of broadcasts 323 00:13:47,020 --> 00:13:49,210 from a lot of entities. 324 00:13:49,210 --> 00:13:51,540 Broadcasting is becoming cheaper and cheaper 325 00:13:51,540 --> 00:13:55,734 now that the read cost has been decreased from the 0.01 326 00:13:55,734 --> 00:13:58,559 to 0.003. 327 00:13:58,559 --> 00:14:00,350 We've also increased the number of channels 328 00:14:00,350 --> 00:14:02,940 in the latest release so that your broadcasts are 329 00:14:02,940 --> 00:14:05,170 more secure against radio attacks. 330 00:14:05,170 --> 00:14:07,240 At least those spanning attacks. 331 00:14:07,240 --> 00:14:09,800 It is worth mentioning that you should 332 00:14:09,800 --> 00:14:12,567 be moving your channel somehow. 333 00:14:12,567 --> 00:14:14,900 Come up with your own algorithm for shifting the channel 334 00:14:14,900 --> 00:14:15,880 that you're using. 335 00:14:15,880 --> 00:14:18,850 Something, for example, that uses the clock round number 336 00:14:18,850 --> 00:14:21,422 so that you could always be looking in a different place, 337 00:14:21,422 --> 00:14:23,130 and the enemy won't locate which channels 338 00:14:23,130 --> 00:14:25,150 you're using on the radio. 339 00:14:25,150 --> 00:14:27,360 Which is to say, which frequencies. 340 00:14:27,360 --> 00:14:32,510 So you might also want some other features. 341 00:14:32,510 --> 00:14:36,280 So these boyds things with their separation and such. 342 00:14:36,280 --> 00:14:40,260 What other features do you want that aren't in boyds? 343 00:14:40,260 --> 00:14:42,630 So you might want some in and out motion 344 00:14:42,630 --> 00:14:46,240 so that everybody takes a uniform amount of damage. 345 00:14:46,240 --> 00:14:48,220 You might want some cycling behavior. 346 00:14:48,220 --> 00:14:52,600 You might want to heal the weak by going back to the med bays. 347 00:14:52,600 --> 00:14:57,310 You might want to apply shields at shield generators. 348 00:14:57,310 --> 00:15:00,520 Those are encampments that you could build. 349 00:15:00,520 --> 00:15:03,675 And you might want to make sure that each robot knows 350 00:15:03,675 --> 00:15:04,550 the size of the pack. 351 00:15:04,550 --> 00:15:08,350 And if each one only has so much information, especially 352 00:15:08,350 --> 00:15:11,180 about the enemy, then they need to be able to get around. 353 00:15:11,180 --> 00:15:15,180 I mean, this year it's not so much of a problem again. 354 00:15:15,180 --> 00:15:16,240 So let's see here. 355 00:15:16,240 --> 00:15:17,980 There's sort of an interesting trade 356 00:15:17,980 --> 00:15:21,106 off here when you think about the density of a group. 357 00:15:21,106 --> 00:15:23,480 But we're doing too much talking and not enough watching. 358 00:15:23,480 --> 00:15:25,700 Let's watch an example. 359 00:15:25,700 --> 00:15:27,600 So I have some players here. 360 00:15:27,600 --> 00:15:32,200 And swarm one, I'm just going to pick any old map here. 361 00:15:32,200 --> 00:15:33,970 Let's go to chunky. 362 00:15:33,970 --> 00:15:38,090 Chunky is a map I made which has just these big chunks of mines. 363 00:15:38,090 --> 00:15:40,930 So here you can see, I've got my swarm one player. 364 00:15:40,930 --> 00:15:42,360 It's very simple. 365 00:15:42,360 --> 00:15:45,306 It's quite close to the other players that I showed you. 366 00:15:45,306 --> 00:15:47,430 It's not that exciting, because the robots are just 367 00:15:47,430 --> 00:15:49,930 sort of-- they rush at one another. 368 00:15:49,930 --> 00:15:51,980 They come together in the middle. 369 00:15:51,980 --> 00:15:53,660 They go toward one another. 370 00:15:53,660 --> 00:15:55,800 There's not that much swarm-like behavior. 371 00:15:55,800 --> 00:15:57,300 And when they come together, they're 372 00:15:57,300 --> 00:15:59,490 not really doing anything that intelligent. 373 00:15:59,490 --> 00:16:01,730 Like at this moment, neither side 374 00:16:01,730 --> 00:16:05,500 is really being that smart about what to do with the other. 375 00:16:05,500 --> 00:16:07,440 Here I'm going to do it slightly differently. 376 00:16:07,440 --> 00:16:10,790 I'm going to have the robots, instead of just choosing 377 00:16:10,790 --> 00:16:15,030 a rally point at random at the very beginning of the game, 378 00:16:15,030 --> 00:16:18,220 and having each robot compute it individually, here 379 00:16:18,220 --> 00:16:20,080 in swarm one, I'm going to show how 380 00:16:20,080 --> 00:16:22,960 in swarm two, which is this code, 381 00:16:22,960 --> 00:16:25,680 we've included the ability for the headquarters 382 00:16:25,680 --> 00:16:28,450 to tell the robots where to go. 383 00:16:28,450 --> 00:16:30,820 So you could see-- let's see here, 384 00:16:30,820 --> 00:16:32,600 let's change the font size so that you 385 00:16:32,600 --> 00:16:36,510 can see what I'm saying and follow along in the code. 386 00:16:36,510 --> 00:16:39,550 Font 16, OK. 387 00:16:43,000 --> 00:16:46,480 The headquarter code here is what the headquarters is doing. 388 00:16:46,480 --> 00:16:48,440 So it does some spawning soldiers. 389 00:16:48,440 --> 00:16:51,350 And I've got a nice code documentation here. 390 00:16:51,350 --> 00:16:53,090 And it moves the rally point from time 391 00:16:53,090 --> 00:16:55,965 to time, which is to say that at round greater than 500, 392 00:16:55,965 --> 00:17:00,180 it just sets the rally point to the enemy headquarter location. 393 00:17:00,180 --> 00:17:02,410 And it messages allies about where to go. 394 00:17:02,410 --> 00:17:04,609 So first it gets the channel from my function 395 00:17:04,609 --> 00:17:05,859 called getChannel. 396 00:17:05,859 --> 00:17:11,050 And when I do that, I say that if I'm team b, 397 00:17:11,050 --> 00:17:12,569 I'm going to have this multiplier. 398 00:17:12,569 --> 00:17:14,910 If I'm team a, I'm going to have this multiplier. 399 00:17:14,910 --> 00:17:17,280 So that when I calculate the channel, 400 00:17:17,280 --> 00:17:21,630 I do the clock round number times the multiplier, 401 00:17:21,630 --> 00:17:24,589 modulo the game constants, broadcast max channels. 402 00:17:24,589 --> 00:17:27,200 So that means that the channel that I'm broadcasting on 403 00:17:27,200 --> 00:17:29,650 is continually rotating, but because it's just 404 00:17:29,650 --> 00:17:33,339 based on my team and the clock round number, that 405 00:17:33,339 --> 00:17:35,630 means that every robot can still read off that channel. 406 00:17:35,630 --> 00:17:37,650 Still knows where to look for that channel. 407 00:17:37,650 --> 00:17:40,350 And rotating frequencies is actually a common practice 408 00:17:40,350 --> 00:17:42,590 in modern military communications. 409 00:17:42,590 --> 00:17:45,980 After all, it might not have occurred to you 410 00:17:45,980 --> 00:17:50,440 that in the modern military, they don't just flip open 411 00:17:50,440 --> 00:17:54,400 their cell phones and then say, hey General Saxony, 412 00:17:54,400 --> 00:17:57,350 do you want to sort of attack tonight? 413 00:17:57,350 --> 00:18:00,560 And the general goes, yeah, maybe. 414 00:18:00,560 --> 00:18:01,590 I might. 415 00:18:01,590 --> 00:18:02,260 I'm not sure. 416 00:18:02,260 --> 00:18:04,374 Maybe I'll send you an email. 417 00:18:04,374 --> 00:18:05,790 They often use radio, because it's 418 00:18:05,790 --> 00:18:08,090 there's not internet connection out there 419 00:18:08,090 --> 00:18:10,110 in the middle of nowhere. 420 00:18:10,110 --> 00:18:12,094 And they have these rotating radio frequencies. 421 00:18:12,094 --> 00:18:14,010 So yeah, that's a good thing that you'll have. 422 00:18:14,010 --> 00:18:16,468 So once you've got the channel, you need to have a message. 423 00:18:16,468 --> 00:18:19,220 So here I've written the message builder 424 00:18:19,220 --> 00:18:21,880 that converts a map location to an integer. 425 00:18:21,880 --> 00:18:23,850 So you can see that function here. 426 00:18:23,850 --> 00:18:26,650 All I do is I multiply the x value by 1,000 427 00:18:26,650 --> 00:18:28,120 and I add the y value. 428 00:18:28,120 --> 00:18:31,740 So then both x and y values are included. 429 00:18:31,740 --> 00:18:33,550 Finally, on that unpacking side, I 430 00:18:33,550 --> 00:18:36,190 use this function to turn the integer back 431 00:18:36,190 --> 00:18:37,560 into a map location. 432 00:18:37,560 --> 00:18:39,850 It makes life easier. 433 00:18:39,850 --> 00:18:42,930 So then at the robot side, you can see the result. 434 00:18:42,930 --> 00:18:47,270 So we're going to show swarm one versus swarm two. 435 00:18:47,270 --> 00:18:48,990 Swarm two has two advantages. 436 00:18:48,990 --> 00:18:50,860 So here swarm two is in blue. 437 00:18:50,860 --> 00:18:53,590 And swarm two has two advantages, the first of which 438 00:18:53,590 --> 00:18:58,550 is that it receives the messages from the headquarters. 439 00:18:58,550 --> 00:19:01,490 So it'll go attack at round 500, rather than 440 00:19:01,490 --> 00:19:04,430 the round that these guys are attacking, which is round 200. 441 00:19:04,430 --> 00:19:06,304 So I guess it has sort of an advantage there. 442 00:19:06,304 --> 00:19:09,850 And second advantage is, it doesn't defuse mines in combat. 443 00:19:09,850 --> 00:19:11,940 Some of you may be familiar with World 444 00:19:11,940 --> 00:19:13,370 of Warcraft or those type games. 445 00:19:13,370 --> 00:19:16,660 Defusing mines in combat is like looting in combat. 446 00:19:16,660 --> 00:19:17,840 It's definitely a no-no. 447 00:19:17,840 --> 00:19:20,970 You don't want to-- that's not how to be a team player. 448 00:19:20,970 --> 00:19:23,440 You could see the result is that just because you aren't 449 00:19:23,440 --> 00:19:26,320 defusing mines in combat where the other team was, 450 00:19:26,320 --> 00:19:28,990 you end up with almost your whole army remaining. 451 00:19:28,990 --> 00:19:30,190 What a huge difference. 452 00:19:30,190 --> 00:19:31,820 And then quickly at round 500, you 453 00:19:31,820 --> 00:19:35,360 can see that these guys are successfully receiving a goal. 454 00:19:35,360 --> 00:19:39,450 And here in size 0.001 font, you can 455 00:19:39,450 --> 00:19:41,810 see that it knows its current location. 456 00:19:41,810 --> 00:19:43,620 And it has a goal location which has 457 00:19:43,620 --> 00:19:46,110 been broadcast from this guy. 458 00:19:46,110 --> 00:19:47,880 So there you can see a little example, 459 00:19:47,880 --> 00:19:51,310 but that's not as exciting as it might be. 460 00:19:51,310 --> 00:19:54,320 Let's consider adding some distance tolerance 461 00:19:54,320 --> 00:19:56,210 in go to location. 462 00:19:56,210 --> 00:20:00,900 So let's do that so that when they go to a location, 463 00:20:00,900 --> 00:20:03,400 they don't just keep bobbling around in there. 464 00:20:03,400 --> 00:20:05,540 So that they can actually start to get work done. 465 00:20:05,540 --> 00:20:07,110 So here, they're going to location. 466 00:20:07,110 --> 00:20:08,750 And then they just calm down. 467 00:20:08,750 --> 00:20:11,810 And they take their spot, and they sit there. 468 00:20:11,810 --> 00:20:12,800 Really nice. 469 00:20:12,800 --> 00:20:14,264 And if they're on a certain tile, 470 00:20:14,264 --> 00:20:15,430 I even have they lay a mine. 471 00:20:15,430 --> 00:20:17,360 So this is a neato thing that I thought 472 00:20:17,360 --> 00:20:22,000 of is if you lay mines not in a fully dense pattern, 473 00:20:22,000 --> 00:20:26,270 then when the enemy attacks, you have the opportunity 474 00:20:26,270 --> 00:20:28,620 to sort of whittle them down. 475 00:20:28,620 --> 00:20:30,430 Because you might have this situation. 476 00:20:30,430 --> 00:20:32,380 It's kind of hard to see on this map. 477 00:20:32,380 --> 00:20:34,680 I might take a screenshot and then work on it. 478 00:20:34,680 --> 00:20:36,970 So let's say that we've got these mines here, 479 00:20:36,970 --> 00:20:41,470 and that we intend to use them in a really clever way. 480 00:20:41,470 --> 00:20:42,090 Yeah. 481 00:20:42,090 --> 00:20:43,410 So let's go here. 482 00:20:47,120 --> 00:20:49,310 Super leet. 483 00:20:49,310 --> 00:20:49,930 Super leet. 484 00:20:54,790 --> 00:20:57,585 So maybe the enemy is coming this way. 485 00:20:57,585 --> 00:20:59,210 Now, if they come here, they can either 486 00:20:59,210 --> 00:21:01,130 start to defuse the mines, and they'll 487 00:21:01,130 --> 00:21:05,050 be just waiting on that corner, or they can infiltrate inside. 488 00:21:05,050 --> 00:21:07,140 Because it doesn't really present a giant obstacle 489 00:21:07,140 --> 00:21:07,940 to them. 490 00:21:07,940 --> 00:21:09,810 And once they're in here, I'm going 491 00:21:09,810 --> 00:21:13,050 to have a big advantage because I can confront them 492 00:21:13,050 --> 00:21:16,000 with a lot more area. 493 00:21:16,000 --> 00:21:18,730 Because they're all so sparsely laid out. 494 00:21:18,730 --> 00:21:20,880 So I think this will work really well. 495 00:21:20,880 --> 00:21:22,380 And if they want to retreat, there's 496 00:21:22,380 --> 00:21:24,380 definitely no way that's going to work for them. 497 00:21:24,380 --> 00:21:26,929 Because they can't do any real cycling in this configuration. 498 00:21:26,929 --> 00:21:28,720 I think it's going to totally mess them up. 499 00:21:31,260 --> 00:21:34,310 So here in this one, I've got these guys who are cleverly 500 00:21:34,310 --> 00:21:40,810 not-- they're not going to defuse mines in combat. 501 00:21:40,810 --> 00:21:44,050 And they'll even sort of back up and fight over the mines. 502 00:21:44,050 --> 00:21:47,570 So here they're backing up to the mines. 503 00:21:47,570 --> 00:21:52,680 And they're trying to bring the fight back to home. 504 00:21:52,680 --> 00:21:57,100 Let's show it with swarm one versus swarm three, 505 00:21:57,100 --> 00:22:00,610 because then they won't both have that part. 506 00:22:00,610 --> 00:22:01,180 Oh, wait. 507 00:22:01,180 --> 00:22:02,560 That was pretty one-sided. 508 00:22:02,560 --> 00:22:03,060 Right. 509 00:22:03,060 --> 00:22:04,480 So this is something that happens. 510 00:22:04,480 --> 00:22:07,690 So here the enemy is going to show up 511 00:22:07,690 --> 00:22:11,170 and I'm going to retreat off the minefield. 512 00:22:11,170 --> 00:22:13,115 So then they're sort of busy, and I come back. 513 00:22:13,115 --> 00:22:14,910 And then I retreat a little bit more. 514 00:22:14,910 --> 00:22:17,100 And they sort of start defusing and they 515 00:22:17,100 --> 00:22:18,250 think that's a good idea. 516 00:22:18,250 --> 00:22:21,580 And then I sort of go this back and forth type motion. 517 00:22:21,580 --> 00:22:24,290 And that kind of thing can help to string out 518 00:22:24,290 --> 00:22:25,266 the enemies in a line. 519 00:22:25,266 --> 00:22:26,390 Give me a little advantage. 520 00:22:26,390 --> 00:22:32,030 But even still, it's not looking that much like swarming. 521 00:22:32,030 --> 00:22:34,520 Now, I want to make the point that a lot of these maps 522 00:22:34,520 --> 00:22:39,420 are absolutely filled with these neutral mines, 523 00:22:39,420 --> 00:22:40,710 especially to begin with. 524 00:22:40,710 --> 00:22:42,016 In this map. 525 00:22:42,016 --> 00:22:43,890 there's so many neutral mines to get through. 526 00:22:43,890 --> 00:22:46,265 If you were really intelligent, you could take this path. 527 00:22:46,265 --> 00:22:48,540 And I'll show an example later of how 528 00:22:48,540 --> 00:22:51,560 you could write a player that really efficiently paths 529 00:22:51,560 --> 00:22:54,570 through this space for a whole mess of troops. 530 00:22:54,570 --> 00:22:57,320 So here I'm retreating past my little minefield. 531 00:22:57,320 --> 00:22:59,830 And then I'm sort of bopping on forward again. 532 00:22:59,830 --> 00:23:01,900 And he's sort of poking the dragon here. 533 00:23:01,900 --> 00:23:03,470 He's making me irritated. 534 00:23:03,470 --> 00:23:07,081 And so then-- oh, I'm just going to kill him. 535 00:23:07,081 --> 00:23:07,580 Hmm. 536 00:23:07,580 --> 00:23:09,954 But the killing him was less effective than it might have 537 00:23:09,954 --> 00:23:12,670 been because a lot of my guys got stuck back there. 538 00:23:12,670 --> 00:23:14,940 And they didn't know what to do because I told them, 539 00:23:14,940 --> 00:23:17,062 please don't defuse mines in combat. 540 00:23:17,062 --> 00:23:18,520 And it was like combat because they 541 00:23:18,520 --> 00:23:20,760 were going to attack the enemy headquarters. 542 00:23:20,760 --> 00:23:22,540 But nevertheless, these guys got stuck. 543 00:23:22,540 --> 00:23:23,885 So what am I going to do? 544 00:23:23,885 --> 00:23:25,260 Well, here's an alternative where 545 00:23:25,260 --> 00:23:29,290 you could say each guy has a certain amount of patience. 546 00:23:29,290 --> 00:23:31,280 And if he's stuck in one spot, then he's 547 00:23:31,280 --> 00:23:35,390 going to go ahead and defuse those mines in combat. 548 00:23:35,390 --> 00:23:37,870 So here, once again, this pulling back and going forward 549 00:23:37,870 --> 00:23:41,230 strategy is very effective against an equally sized enemy. 550 00:23:41,230 --> 00:23:43,590 These minefields are a wonderful defensive advantage 551 00:23:43,590 --> 00:23:45,930 that you should definitely use. 552 00:23:45,930 --> 00:23:49,310 So then here, when these guys get annoyed, 553 00:23:49,310 --> 00:23:50,874 they can start digging through. 554 00:23:50,874 --> 00:23:53,290 And eventually, they'll make it through to the other side. 555 00:23:53,290 --> 00:23:56,840 Which will be pretty useful in that case. 556 00:23:56,840 --> 00:24:00,730 Let's do another example versus basic player. 557 00:24:00,730 --> 00:24:04,590 I think this example demonstrates that tunneling 558 00:24:04,590 --> 00:24:06,225 effect a little bit better. 559 00:24:06,225 --> 00:24:08,600 Now, basic player is building all kinds of useful things, 560 00:24:08,600 --> 00:24:10,480 like suppliers and generators. 561 00:24:10,480 --> 00:24:12,712 And that's going to make him especially powerful. 562 00:24:12,712 --> 00:24:14,670 So it's going to be-- no, actually, I beat him. 563 00:24:14,670 --> 00:24:17,490 [LAUGHTER] 564 00:24:17,490 --> 00:24:19,290 PROFESSOR: So that's a really good example. 565 00:24:19,290 --> 00:24:23,370 Let's move on, and I'm going to try to beat swarm four. 566 00:24:23,370 --> 00:24:25,550 So swarm four was like-- well, maybe 567 00:24:25,550 --> 00:24:27,345 I'll continue beating swarm one. 568 00:24:27,345 --> 00:24:28,720 What I'm going to do is I'm going 569 00:24:28,720 --> 00:24:32,120 to use guided swarm, which is a new player that I made. 570 00:24:32,120 --> 00:24:35,340 So this guided swarm's really neat. 571 00:24:35,340 --> 00:24:37,250 This is a lot more like birds. 572 00:24:37,250 --> 00:24:43,930 And the guided swarm's goal, his goal is to be a little bit more 573 00:24:43,930 --> 00:24:45,810 puffy. 574 00:24:45,810 --> 00:24:47,020 Yeah, that's him up there. 575 00:24:47,020 --> 00:24:47,519 Look at him. 576 00:24:47,519 --> 00:24:48,850 He's like all cloud like. 577 00:24:48,850 --> 00:24:51,380 And he's keeping it real. 578 00:24:51,380 --> 00:24:52,960 What a guy. 579 00:24:52,960 --> 00:24:55,980 So you can see here that the guided swarm's kind of OK, 580 00:24:55,980 --> 00:24:59,590 but he's so spread out that he doesn't do well in combat. 581 00:24:59,590 --> 00:25:02,240 What can we do to make this guided swarm better? 582 00:25:02,240 --> 00:25:05,950 What can we do-- I think one thing that works really well 583 00:25:05,950 --> 00:25:09,660 is to put him on a map that's better for him. 584 00:25:09,660 --> 00:25:11,160 So I'm going to put him on this one. 585 00:25:11,160 --> 00:25:13,200 Now he's a bit farther away from the enemy. 586 00:25:13,200 --> 00:25:15,200 And my hope is that he'll have time 587 00:25:15,200 --> 00:25:16,850 to produce enough units that he'll 588 00:25:16,850 --> 00:25:18,610 start laying a big minefield. 589 00:25:18,610 --> 00:25:21,441 Yes, I think that will help him out significantly. 590 00:25:21,441 --> 00:25:21,940 Oh, come on. 591 00:25:21,940 --> 00:25:23,710 Please lay that minefield. 592 00:25:23,710 --> 00:25:25,620 Please lay that minefield. 593 00:25:25,620 --> 00:25:28,544 Oh, he didn't have time to lay the minefield. 594 00:25:28,544 --> 00:25:30,460 I think what I'll do is I'll tell him to build 595 00:25:30,460 --> 00:25:32,824 the minefield just a little bit earlier. 596 00:25:32,824 --> 00:25:34,240 I'm going to make this-- right now 597 00:25:34,240 --> 00:25:36,960 I've got it-- ooh, don't let me change the wrong code. 598 00:25:36,960 --> 00:25:38,147 It's so easy to do that. 599 00:25:38,147 --> 00:25:40,730 You think robot player got Java is the code you're working on, 600 00:25:40,730 --> 00:25:42,194 and it is, but you're wrong. 601 00:25:42,194 --> 00:25:45,040 [LAUGHTER] 602 00:25:45,040 --> 00:25:47,580 So I was working on guided swarm one, 603 00:25:47,580 --> 00:25:54,010 and I want the headquarters code to start building these robots. 604 00:25:54,010 --> 00:25:54,880 Oh, yeah. 605 00:25:54,880 --> 00:25:56,910 I want him to research pickaxe. 606 00:25:56,910 --> 00:25:58,560 And once he's researched pickaxe, 607 00:25:58,560 --> 00:26:01,850 I told him to tell the other guys on channel plus 1. 608 00:26:01,850 --> 00:26:04,390 So here you can use your get channel function 609 00:26:04,390 --> 00:26:05,890 and then add one, and now you've got 610 00:26:05,890 --> 00:26:08,710 sort of a set of channels you can use. 611 00:26:08,710 --> 00:26:11,490 So I want him to tell the others to please start laying mines 612 00:26:11,490 --> 00:26:14,190 as soon as I have the pickaxe upgrade. 613 00:26:14,190 --> 00:26:15,180 All right. 614 00:26:15,180 --> 00:26:17,260 So that's going to happen. 615 00:26:17,260 --> 00:26:21,080 I'll just make it at this point, and hopefully that 616 00:26:21,080 --> 00:26:22,630 will give him enough time to do it. 617 00:26:27,210 --> 00:26:27,710 Yeah. 618 00:26:27,710 --> 00:26:30,020 So now he's going to build fewer allied units 619 00:26:30,020 --> 00:26:31,790 before he starts researching. 620 00:26:31,790 --> 00:26:34,510 Gosh, this is a tiny map. 621 00:26:34,510 --> 00:26:38,460 If you can see this accurately, you don't need glasses. 622 00:26:38,460 --> 00:26:39,941 Yes, that's probably true. 623 00:26:39,941 --> 00:26:40,440 Ah, right. 624 00:26:40,440 --> 00:26:41,648 So they started laying mines. 625 00:26:41,648 --> 00:26:43,030 And look at that pattern. 626 00:26:43,030 --> 00:26:44,580 Look at the pattern they used. 627 00:26:44,580 --> 00:26:45,640 Oh, my goodness. 628 00:26:45,640 --> 00:26:47,520 They must be somewhat skilled. 629 00:26:47,520 --> 00:26:48,630 Can't believe that. 630 00:26:48,630 --> 00:26:49,440 Ah, ooh. 631 00:26:49,440 --> 00:26:50,746 [LAUGHTER] 632 00:26:50,746 --> 00:26:52,120 PROFESSOR: But you see the point. 633 00:26:52,120 --> 00:26:55,140 The point that I made was that I found a really neat way 634 00:26:55,140 --> 00:26:57,330 to make them lay mines in the right pattern. 635 00:26:57,330 --> 00:26:59,120 Now, maybe you can't really see that well. 636 00:26:59,120 --> 00:27:01,920 So I'm going to open up good fashioned Mathematica. 637 00:27:01,920 --> 00:27:03,820 Not that. 638 00:27:03,820 --> 00:27:05,705 Good old fashioned-- not that. 639 00:27:05,705 --> 00:27:07,080 Good old fashioned-- there we go. 640 00:27:07,080 --> 00:27:07,780 Mathematica. 641 00:27:07,780 --> 00:27:11,230 So you can see that this arrangement, this disposition 642 00:27:11,230 --> 00:27:14,680 of mine positions, which is like over one, up two-- I've 643 00:27:14,680 --> 00:27:17,430 got to zoom in a little bit. 644 00:27:17,430 --> 00:27:19,630 Yeah, if you go over one, up two, over one, up two, 645 00:27:19,630 --> 00:27:22,330 this arrangement is going to totally fill space. 646 00:27:22,330 --> 00:27:24,922 So this is where I've colored all the adjacent ones in. 647 00:27:24,922 --> 00:27:26,880 And this is going to mean that if you lay mines 648 00:27:26,880 --> 00:27:29,590 at these centers, and you have the pickaxe upgrade, 649 00:27:29,590 --> 00:27:31,100 then you will be fully tiling space. 650 00:27:31,100 --> 00:27:32,300 Really useful. 651 00:27:32,300 --> 00:27:35,430 And here I'm going to give away the trick. 652 00:27:35,430 --> 00:27:40,150 You'll be on the right spot if mod of 2 plus your x val, 653 00:27:40,150 --> 00:27:44,230 plus 1 times your y val equals zero. 654 00:27:44,230 --> 00:27:48,480 If mod, this number 5-- see if I change this to like a 7, 655 00:27:48,480 --> 00:27:49,780 then the whole pattern changes. 656 00:27:49,780 --> 00:27:52,400 And you can investigate different patterns 657 00:27:52,400 --> 00:27:55,314 by playing around with it. 658 00:27:55,314 --> 00:27:57,230 And these patterns may have different effects, 659 00:27:57,230 --> 00:27:59,810 depending on your upgrades and the positioning of your mines. 660 00:27:59,810 --> 00:28:02,110 And it made me get kind of a neat idea. 661 00:28:02,110 --> 00:28:04,340 So this is fully dense. 662 00:28:04,340 --> 00:28:06,670 And you could do partly dense, which is really simple. 663 00:28:06,670 --> 00:28:09,870 You could just do mod i plus j, where i and j are your x and y 664 00:28:09,870 --> 00:28:10,370 values. 665 00:28:10,370 --> 00:28:11,750 You just do mod 2. 666 00:28:11,750 --> 00:28:15,140 And if that mod 2 is equal to 1, then that'll 667 00:28:15,140 --> 00:28:16,182 get you every other tile. 668 00:28:16,182 --> 00:28:17,764 So no matter where you are on the map, 669 00:28:17,764 --> 00:28:19,980 you don't have to start comparing to your allied tile 670 00:28:19,980 --> 00:28:20,830 locations. 671 00:28:20,830 --> 00:28:22,390 You don't have to start doing a whole bunch of really 672 00:28:22,390 --> 00:28:23,348 complicated operations. 673 00:28:23,348 --> 00:28:26,980 Just say, if my robot is on this nice tile, 674 00:28:26,980 --> 00:28:29,370 then go ahead and lay a mine. 675 00:28:29,370 --> 00:28:30,330 Really nice. 676 00:28:30,330 --> 00:28:32,680 And here's an interesting alternative. 677 00:28:32,680 --> 00:28:36,011 So this one I slightly farther spaced apart than the one 678 00:28:36,011 --> 00:28:36,510 above. 679 00:28:36,510 --> 00:28:39,220 This is sort of like knights in chess, where they can move up 680 00:28:39,220 --> 00:28:43,240 and up and up, or they can move over and over and over. 681 00:28:43,240 --> 00:28:46,660 Well here, I've gone and done it a little bit farther apart. 682 00:28:46,660 --> 00:28:49,650 And the result is this neato looking structure. 683 00:28:49,650 --> 00:28:52,590 So it's like the one we did before, 684 00:28:52,590 --> 00:28:55,480 where we had only done a checkerboard pattern. 685 00:28:55,480 --> 00:28:58,430 Only now, we have a lot fewer mines to lay, 686 00:28:58,430 --> 00:29:01,200 and we still get sort of this interpenetrated mix. 687 00:29:01,200 --> 00:29:04,040 This can be really useful for fooling the enemy team. 688 00:29:04,040 --> 00:29:09,080 The formula for this system is 3x plus 1y. 689 00:29:09,080 --> 00:29:11,020 And as long as you mod that with 8, 690 00:29:11,020 --> 00:29:13,350 you'll get the answer you're looking for. 691 00:29:13,350 --> 00:29:15,310 Now, this is sort of an interesting system. 692 00:29:15,310 --> 00:29:18,810 If I change this to 1, and I change this to 5, 693 00:29:18,810 --> 00:29:23,040 I get the same result but sort of mirror image. 694 00:29:23,040 --> 00:29:25,640 Just playing around with this kind of problem 695 00:29:25,640 --> 00:29:29,200 can be quite enlightening if you're not 696 00:29:29,200 --> 00:29:33,630 the kind of person who instantly sees how these systems work. 697 00:29:33,630 --> 00:29:37,577 So let's do some summaries, and then 698 00:29:37,577 --> 00:29:39,160 at the end of the summaries, I'm going 699 00:29:39,160 --> 00:29:42,410 to show you a really awesome player. 700 00:29:42,410 --> 00:29:45,120 A really amazing version of this thing that 701 00:29:45,120 --> 00:29:47,067 has the headquarters telling it where to go. 702 00:29:47,067 --> 00:29:49,150 So this is going to be at the very end of lecture, 703 00:29:49,150 --> 00:29:50,066 I'm going to show you. 704 00:29:50,066 --> 00:29:51,450 It's the same as this player that 705 00:29:51,450 --> 00:29:54,130 just lost this match, this one up here, 706 00:29:54,130 --> 00:29:56,740 only instead of being dumb when the enemy arrives, 707 00:29:56,740 --> 00:29:58,970 it's going to be smart about where it puts itself 708 00:29:58,970 --> 00:30:00,110 with respect to the enemy. 709 00:30:00,110 --> 00:30:02,200 Which is to say that it's going to avoid 710 00:30:02,200 --> 00:30:04,620 the enemy unless the number of nearby allies 711 00:30:04,620 --> 00:30:06,360 is a really high number. 712 00:30:06,360 --> 00:30:08,890 And at the same time, the central headquarters 713 00:30:08,890 --> 00:30:10,930 is going to tell it to capture encampments 714 00:30:10,930 --> 00:30:13,630 and to build suppliers and generators on them. 715 00:30:13,630 --> 00:30:15,610 So you're going to start to have a player that, 716 00:30:15,610 --> 00:30:18,670 just from few little pieces, is starting to do everything 717 00:30:18,670 --> 00:30:21,630 it needs to do to start winning matches. 718 00:30:21,630 --> 00:30:23,360 So I'll show that at the very end 719 00:30:23,360 --> 00:30:25,605 after I summarize some of things that I've done, 720 00:30:25,605 --> 00:30:27,980 and some of the things that I think you ought to try out. 721 00:30:27,980 --> 00:30:29,780 Because I can put this code together 722 00:30:29,780 --> 00:30:31,370 in a certain amount of time, but I 723 00:30:31,370 --> 00:30:33,480 can't try every possible combination. 724 00:30:33,480 --> 00:30:36,460 So let's go straight on over to here, 725 00:30:36,460 --> 00:30:39,130 and I want to just talk about two categories. 726 00:30:39,130 --> 00:30:42,300 Let's talk about the shape of your system, which 727 00:30:42,300 --> 00:30:44,210 is to say the cloud. 728 00:30:44,210 --> 00:30:47,970 Let's talk about how you achieve the shape. 729 00:30:47,970 --> 00:30:52,960 And you can achieve it either using a headquarters, 730 00:30:52,960 --> 00:30:54,710 and I'll talk about all the amazing things 731 00:30:54,710 --> 00:30:56,293 that you can have the headquarter tell 732 00:30:56,293 --> 00:30:58,180 the group that you might not have thought of. 733 00:30:58,180 --> 00:31:03,880 And you can achieve it using this group mind. 734 00:31:03,880 --> 00:31:07,330 So let's do the group mind first, 735 00:31:07,330 --> 00:31:09,920 where you could check the neighbors 736 00:31:09,920 --> 00:31:13,080 and go to the area with the fewest. 737 00:31:13,080 --> 00:31:14,490 I sent around some code. 738 00:31:14,490 --> 00:31:16,600 I don't know how many of you used it. 739 00:31:16,600 --> 00:31:17,860 And it looked like this. 740 00:31:17,860 --> 00:31:22,520 Let me show you my lecture three robot player release. 741 00:31:22,520 --> 00:31:27,410 It's not incredibly good code, but you can see the point. 742 00:31:27,410 --> 00:31:32,640 So when these guys get close to one another, 743 00:31:32,640 --> 00:31:34,730 each one has this list. 744 00:31:34,730 --> 00:31:36,950 And this list shows the number of adjacent enemy 745 00:31:36,950 --> 00:31:37,780 and allied units. 746 00:31:37,780 --> 00:31:41,620 So that list is absolutely gosh darn tiny. 747 00:31:41,620 --> 00:31:44,770 So I'm going to go ahead and do a fancy way of zooming in. 748 00:31:44,770 --> 00:31:45,510 Oh, my goodness. 749 00:31:45,510 --> 00:31:46,970 That's even less legible. 750 00:31:46,970 --> 00:31:52,670 That says 22, 21, 2, 0, 0, 1, 12, 23, me 12. 751 00:31:52,670 --> 00:31:56,490 So me 12 means that I have two allies adjacent 752 00:31:56,490 --> 00:31:58,150 and one enemy adjacent. 753 00:31:58,150 --> 00:32:01,700 And adjacent this number, these are eight different numbers 754 00:32:01,700 --> 00:32:07,160 indicating north, northeast, east, southeast, 755 00:32:07,160 --> 00:32:10,880 and so on, around the clock directions. 756 00:32:10,880 --> 00:32:13,420 Although not with 12, but with eight. 757 00:32:13,420 --> 00:32:14,620 Yeah. 758 00:32:14,620 --> 00:32:17,040 And it has this many enemies and this many allies. 759 00:32:17,040 --> 00:32:19,600 And so I've written the code for you that will do this. 760 00:32:19,600 --> 00:32:21,370 And so the robot can sort of start 761 00:32:21,370 --> 00:32:23,820 to make decisions about who is adjacent to it. 762 00:32:23,820 --> 00:32:26,200 All you've got to do is start sorting 763 00:32:26,200 --> 00:32:28,350 how good it is to be next to allies or enemies. 764 00:32:28,350 --> 00:32:29,920 Like maybe it's really good to be 765 00:32:29,920 --> 00:32:32,980 next to a lot of allies and very few enemies. 766 00:32:32,980 --> 00:32:34,880 Otherwise you want to be close to few allies 767 00:32:34,880 --> 00:32:35,838 so that you spread out. 768 00:32:35,838 --> 00:32:39,920 There are a lot of things that you can build on that. 769 00:32:39,920 --> 00:32:42,564 So that's why I included that code. 770 00:32:42,564 --> 00:32:45,230 So you could check neighbors and go to the area with the fewest. 771 00:32:45,230 --> 00:32:47,800 You could compare to neighbor repulsion. 772 00:32:47,800 --> 00:32:52,830 So the repulsion is accomplished in the following way. 773 00:32:52,830 --> 00:32:57,320 So I've written this code here in guided swarm. 774 00:32:57,320 --> 00:33:00,999 And here's where you are repelling from the enemies. 775 00:33:00,999 --> 00:33:02,540 So it isn't just one way of doing it. 776 00:33:02,540 --> 00:33:03,870 A lot of ways of doing it. 777 00:33:03,870 --> 00:33:06,090 But I've called this function freeGo, 778 00:33:06,090 --> 00:33:09,180 and it lets you sort of freely float 779 00:33:09,180 --> 00:33:13,047 among your various alternatives of places to go. 780 00:33:13,047 --> 00:33:14,880 What it does is it says, all right, here I'm 781 00:33:14,880 --> 00:33:16,890 starting at my location. 782 00:33:16,890 --> 00:33:19,520 I'll get a direction to the target location, 783 00:33:19,520 --> 00:33:22,090 which is like the waypoint. 784 00:33:22,090 --> 00:33:24,370 And now I'm going to apply a target weight, 785 00:33:24,370 --> 00:33:26,980 because maybe I really want to get there if I'm far away. 786 00:33:26,980 --> 00:33:29,530 But if I'm kind of close, I don't really care. 787 00:33:29,530 --> 00:33:31,835 So now I have this function called target weight, where 788 00:33:31,835 --> 00:33:34,230 if my distance squared is greater than 100, 789 00:33:34,230 --> 00:33:35,352 I'll call the weighting 5. 790 00:33:35,352 --> 00:33:37,060 If my distance squared is greater than 9, 791 00:33:37,060 --> 00:33:38,250 I'll call the weighting 2. 792 00:33:38,250 --> 00:33:41,520 And if I'm really close, then I'll call the weighting 1. 793 00:33:41,520 --> 00:33:44,580 So that's sort of giving me this spring-like behavior 794 00:33:44,580 --> 00:33:46,240 to get to where I want to go. 795 00:33:46,240 --> 00:33:48,926 And it's going to give me this gassy behavior. 796 00:33:48,926 --> 00:33:51,050 So what I'll do is I'll make a goal location, which 797 00:33:51,050 --> 00:33:53,060 is not the same as the target. 798 00:33:53,060 --> 00:33:56,822 So that goal location, I'm going to just add to my location 799 00:33:56,822 --> 00:33:58,030 this direction to the target. 800 00:33:58,030 --> 00:34:02,570 So let's do it on Paint to give an example. 801 00:34:02,570 --> 00:34:06,600 Because saying words is not always incredibly clear. 802 00:34:06,600 --> 00:34:08,739 So here's me. 803 00:34:08,739 --> 00:34:10,379 Here's my waypoint. 804 00:34:13,060 --> 00:34:16,290 And maybe here is the closest ally. 805 00:34:16,290 --> 00:34:20,739 So what I'm going to do is I'm going to repel from the ally, 806 00:34:20,739 --> 00:34:22,480 and I'm going to attract to the waypoint. 807 00:34:22,480 --> 00:34:24,938 Which means I'm going to end up having a bunch of guys that 808 00:34:24,938 --> 00:34:27,260 are having competing requirements. 809 00:34:27,260 --> 00:34:30,210 Competing requirements is like everything 810 00:34:30,210 --> 00:34:33,310 in these kinds of dynamic systems. 811 00:34:33,310 --> 00:34:35,380 Because in the end, you'll want to expect 812 00:34:35,380 --> 00:34:37,989 them to find a balance between these competing things. 813 00:34:37,989 --> 00:34:40,962 Because frankly, they want to do things that are inconsistent. 814 00:34:40,962 --> 00:34:42,670 They want to be at the waypoint, but they 815 00:34:42,670 --> 00:34:44,295 don't want to be next to their friends. 816 00:34:44,295 --> 00:34:47,594 So that automatically means that they can't be satisfied, 817 00:34:47,594 --> 00:34:48,760 like a lot of people I know. 818 00:34:51,699 --> 00:34:55,380 So you could see here the repulsion term. 819 00:34:55,380 --> 00:34:59,436 So if there are allies, then it will locate the closest ally 820 00:34:59,436 --> 00:35:00,810 using this function that I wrote. 821 00:35:00,810 --> 00:35:01,800 Very simple. 822 00:35:01,800 --> 00:35:05,110 And then it will add to the goal location negative 3 823 00:35:05,110 --> 00:35:06,800 of the direction to the closest ally. 824 00:35:06,800 --> 00:35:08,170 so what the heck does that mean? 825 00:35:08,170 --> 00:35:10,375 That's just saying repel. 826 00:35:10,375 --> 00:35:14,330 So my goal location started here. 827 00:35:14,330 --> 00:35:18,240 And then I moved it toward the waypoint some amount. 828 00:35:18,240 --> 00:35:20,420 And it would be more or less, depending 829 00:35:20,420 --> 00:35:23,890 on where the waypoint was with respect to me. 830 00:35:23,890 --> 00:35:26,310 And now I'm going to take the ally direction, which 831 00:35:26,310 --> 00:35:29,910 is this direction, and I'm going to subtract that from this. 832 00:35:29,910 --> 00:35:31,610 So now I'm going away from the ally 833 00:35:31,610 --> 00:35:35,120 and toward the waypoint, which gets me this x. 834 00:35:35,120 --> 00:35:39,510 So in the final analysis, this is my new goal location, 835 00:35:39,510 --> 00:35:43,380 which is the sum of a bunch of weighted added directions. 836 00:35:43,380 --> 00:35:45,040 And now I'm going to go that way, which 837 00:35:45,040 --> 00:35:47,130 is going to get me both toward the waypoint 838 00:35:47,130 --> 00:35:48,610 and away from my ally. 839 00:35:48,610 --> 00:35:53,040 I mean, on a grid, this direction 840 00:35:53,040 --> 00:35:55,640 may have been quite close to or the same as 841 00:35:55,640 --> 00:35:58,020 the direction directly to the waypoint. 842 00:35:58,020 --> 00:36:00,970 But when you keep doing it over and over, 843 00:36:00,970 --> 00:36:04,020 those little edge cases where a small difference makes you 844 00:36:04,020 --> 00:36:08,530 go one way or the other start to become significant. 845 00:36:08,530 --> 00:36:11,810 And so you can do it just simply like this, where you only 846 00:36:11,810 --> 00:36:15,080 care about where the ally that's closest is. 847 00:36:15,080 --> 00:36:17,710 And you only care about the weighting 848 00:36:17,710 --> 00:36:20,970 of where you're going. 849 00:36:20,970 --> 00:36:22,549 But wait just a second. 850 00:36:22,549 --> 00:36:24,340 There are so many things you can add to it, 851 00:36:24,340 --> 00:36:28,110 and that I did add when I wrote my guided swarm two, 852 00:36:28,110 --> 00:36:29,540 which is going to end the lecture. 853 00:36:29,540 --> 00:36:36,030 So let's do all the things that you can repel or attract. 854 00:36:36,030 --> 00:36:36,940 There's enemies. 855 00:36:36,940 --> 00:36:39,630 And you repel or attract to them based on how many there are. 856 00:36:39,630 --> 00:36:41,060 There's mines . 857 00:36:41,060 --> 00:36:42,649 And if they're yours, do you want 858 00:36:42,649 --> 00:36:43,940 to be right next to your mines? 859 00:36:43,940 --> 00:36:45,210 Do you want to be behind them? 860 00:36:45,210 --> 00:36:47,202 Do you want to be sort of in a clump of them? 861 00:36:47,202 --> 00:36:48,660 Do want to keep laying mi-- I mean, 862 00:36:48,660 --> 00:36:50,580 if you're in a laying mines mode, 863 00:36:50,580 --> 00:36:52,660 then you don't really want to stand on a mine, 864 00:36:52,660 --> 00:36:54,870 because then you can't lay one. 865 00:36:54,870 --> 00:36:56,390 You're on one already. 866 00:36:56,390 --> 00:36:59,999 So [INAUDIBLE] on your current goals. 867 00:36:59,999 --> 00:37:01,790 So you could imagine making the following-- 868 00:37:01,790 --> 00:37:02,990 this would be so cool. 869 00:37:02,990 --> 00:37:04,750 Somebody in this room needs to do this. 870 00:37:04,750 --> 00:37:07,835 I was going to do it for today but ran out of time. 871 00:37:07,835 --> 00:37:08,710 You do the following. 872 00:37:08,710 --> 00:37:11,290 So here's what always happens when I write players, 873 00:37:11,290 --> 00:37:13,710 is I've got a center, and people start 874 00:37:13,710 --> 00:37:15,720 laying mines around the center. 875 00:37:15,720 --> 00:37:17,120 I think you saw this today, where 876 00:37:17,120 --> 00:37:18,860 they were laying these mines. 877 00:37:18,860 --> 00:37:21,750 And the mines reached a certain amount, 878 00:37:21,750 --> 00:37:25,110 and the robots were only out to here. 879 00:37:25,110 --> 00:37:26,940 And so that was it. 880 00:37:26,940 --> 00:37:28,380 I didn't get any more mines. 881 00:37:28,380 --> 00:37:29,910 But here's what you could do. 882 00:37:29,910 --> 00:37:32,500 You could say, have the headquarters, 883 00:37:32,500 --> 00:37:35,150 which might be, say, down here. 884 00:37:35,150 --> 00:37:38,130 Have it say, if-- let's do this. 885 00:37:38,130 --> 00:37:38,880 Oh, my goodness. 886 00:37:38,880 --> 00:37:40,010 Watch this. 887 00:37:40,010 --> 00:37:40,879 Oh, uh, uh. 888 00:37:40,879 --> 00:37:41,670 It's going to work. 889 00:37:41,670 --> 00:37:43,290 It's going to work. 890 00:37:43,290 --> 00:37:45,770 Headquarters. 891 00:37:45,770 --> 00:37:52,000 If there are a lot of mines near the rally point-- and it 892 00:37:52,000 --> 00:37:53,600 can do this very easily. 893 00:37:53,600 --> 00:37:55,000 You know how to do it? 894 00:37:55,000 --> 00:37:57,220 There's a really, really handy function. 895 00:37:57,220 --> 00:37:58,730 Don't do the following. 896 00:37:58,730 --> 00:38:01,140 Here's years what you were probably thinking. 897 00:38:01,140 --> 00:38:05,510 What you might have done is sense all the allied mines, 898 00:38:05,510 --> 00:38:07,464 or whatever the function name is, and then 899 00:38:07,464 --> 00:38:09,380 parse through that list and find the ones that 900 00:38:09,380 --> 00:38:10,260 are close the waypoint. 901 00:38:10,260 --> 00:38:11,380 You don't have to do that. 902 00:38:11,380 --> 00:38:12,950 You don't have to do that at all. 903 00:38:12,950 --> 00:38:16,930 You can see here in the documentation under Robot 904 00:38:16,930 --> 00:38:19,830 Controller, there's a method that really helps. 905 00:38:19,830 --> 00:38:23,410 There's senseMineLocations and it 906 00:38:23,410 --> 00:38:28,050 will let you specify a center, a radius, and a team. 907 00:38:28,050 --> 00:38:29,860 So let's put that on here. 908 00:38:29,860 --> 00:38:31,940 So you definitely want to be using this 909 00:38:31,940 --> 00:38:35,050 so that all you've got to do is have the headquarters. 910 00:38:35,050 --> 00:38:36,940 And why would you use the headquarters? 911 00:38:36,940 --> 00:38:39,273 Just so that it doesn't have to be done again and again. 912 00:38:39,273 --> 00:38:42,930 So the headquarters is going say, how many mines are there 913 00:38:42,930 --> 00:38:49,170 when this x is the center, and I'm looking within some radius? 914 00:38:49,170 --> 00:38:51,650 And you could just expand the radius turn by turn 915 00:38:51,650 --> 00:38:55,210 to see how many mines there are until it starts to drop Off 916 00:38:55,210 --> 00:38:57,760 or you could just like set it at a given radius, 917 00:38:57,760 --> 00:38:59,640 or the previous radius. 918 00:38:59,640 --> 00:39:00,226 So yeah. 919 00:39:00,226 --> 00:39:01,100 Let's do it that way. 920 00:39:01,100 --> 00:39:04,040 And you would say, how many of my mines are in this circle? 921 00:39:04,040 --> 00:39:08,649 And so you'd say, if there are full mines in the circle-- 922 00:39:08,649 --> 00:39:10,940 and you can do that pretty easily because the circle is 923 00:39:10,940 --> 00:39:13,290 defined by a radius squared, right? 924 00:39:13,290 --> 00:39:18,300 So expected mines is like pi r squared, right? 925 00:39:18,300 --> 00:39:19,420 That's a number of tiles. 926 00:39:19,420 --> 00:39:22,770 But r squared we already have, and pi as an integer 927 00:39:22,770 --> 00:39:24,580 is equal to 3. 928 00:39:24,580 --> 00:39:27,800 And so we can just say the number of expected mines 929 00:39:27,800 --> 00:39:31,040 equals 3 times the radius squared. 930 00:39:31,040 --> 00:39:33,990 And so that's also nice, because it's a little bit less than pi. 931 00:39:33,990 --> 00:39:37,360 And so if you're like mostly filled of mines in that circle, 932 00:39:37,360 --> 00:39:43,110 then-- so if the detected mines is 933 00:39:43,110 --> 00:39:47,830 greater than or equal to expected mines in a full area, 934 00:39:47,830 --> 00:39:50,665 then expand the mine radius. 935 00:39:50,665 --> 00:39:51,920 And you might say, well, wait. 936 00:39:51,920 --> 00:39:53,730 How am I expanding the mine radius? 937 00:39:53,730 --> 00:39:54,480 Well, here you go. 938 00:39:54,480 --> 00:39:55,410 Here you go. 939 00:39:55,410 --> 00:39:58,770 Right now, the function looks like this 940 00:39:58,770 --> 00:40:00,710 for the repulsion and attraction. 941 00:40:00,710 --> 00:40:03,330 It looks like the following. 942 00:40:03,330 --> 00:40:04,660 Oh, I'm going to use this. 943 00:40:04,660 --> 00:40:05,390 Yeah. 944 00:40:05,390 --> 00:40:06,220 Like that. 945 00:40:06,220 --> 00:40:09,340 So if this is the distance x from center, 946 00:40:09,340 --> 00:40:11,600 and this is the repulsive force-- 947 00:40:11,600 --> 00:40:12,890 or I think we were attracting. 948 00:40:12,890 --> 00:40:14,620 Yeah, we were attracting to the center. 949 00:40:14,620 --> 00:40:17,560 The attractive force was greater the farther 950 00:40:17,560 --> 00:40:21,860 you got from the center. 951 00:40:21,860 --> 00:40:23,720 But you could imagine-- So that's going 952 00:40:23,720 --> 00:40:25,500 to push everybody toward the middle. 953 00:40:25,500 --> 00:40:27,160 But you don't have to do that. 954 00:40:27,160 --> 00:40:30,210 You could just as easily have the headquarters-- 955 00:40:30,210 --> 00:40:33,450 the headquarters could be telling everybody 956 00:40:33,450 --> 00:40:36,140 by message systems what this looks like. 957 00:40:36,140 --> 00:40:38,390 And they could very well tell them 958 00:40:38,390 --> 00:40:40,240 to make it a little bit more like this. 959 00:40:40,240 --> 00:40:44,670 So let's say that you already put mines out to this range. 960 00:40:44,670 --> 00:40:47,510 So you've already put mines here and you've 961 00:40:47,510 --> 00:40:49,060 detected them using the headquarters. 962 00:40:49,060 --> 00:40:51,420 So now you want everybody to show up here. 963 00:40:51,420 --> 00:40:53,020 Well, you could very simply do that. 964 00:40:53,020 --> 00:40:56,770 All you've got to do is make the forces look like this. 965 00:40:56,770 --> 00:40:57,709 Oh, is that right? 966 00:40:57,709 --> 00:40:59,000 No, we would want-- Yeah, yeah. 967 00:40:59,000 --> 00:41:00,040 Well, that's the energy. 968 00:41:00,040 --> 00:41:01,520 And the force is this. 969 00:41:01,520 --> 00:41:03,110 The attractive force is this. 970 00:41:03,110 --> 00:41:05,130 So this is exactly a spring. 971 00:41:05,130 --> 00:41:07,070 That's a spring from physics. 972 00:41:07,070 --> 00:41:10,000 And that will make them go toward it if they are inside, 973 00:41:10,000 --> 00:41:12,480 because they will go opposite the direction of this vector 974 00:41:12,480 --> 00:41:14,460 from the origin. 975 00:41:14,460 --> 00:41:16,940 And they'll make it go away if they 976 00:41:16,940 --> 00:41:20,082 are in the other direction, and you get the idea. 977 00:41:20,082 --> 00:41:21,790 So that's a pretty neat idea, because you 978 00:41:21,790 --> 00:41:24,000 could have them spread out in a circle 979 00:41:24,000 --> 00:41:27,450 and maintain that sort of positional authority, 980 00:41:27,450 --> 00:41:28,890 as it were. 981 00:41:28,890 --> 00:41:30,650 Very, very cool. 982 00:41:30,650 --> 00:41:34,220 We are also going to talk about some other awesome things 983 00:41:34,220 --> 00:41:37,070 the headquarter can tell them, even 984 00:41:37,070 --> 00:41:39,120 though our mouths are watering. 985 00:41:39,120 --> 00:41:41,100 Check the neighbors, OK. 986 00:41:41,100 --> 00:41:42,220 We can avoid this. 987 00:41:42,220 --> 00:41:44,180 We can avoid mines. 988 00:41:44,180 --> 00:41:45,400 We can avoid the enemy. 989 00:41:45,400 --> 00:41:48,200 We can do those things. 990 00:41:48,200 --> 00:41:49,350 There's no more direction. 991 00:41:49,350 --> 00:41:50,590 We've talked about that. 992 00:41:50,590 --> 00:41:52,740 So now let's go back a little bit 993 00:41:52,740 --> 00:41:54,370 and talk about how the headquarters can 994 00:41:54,370 --> 00:41:57,670 help you achieve a given shape. 995 00:41:57,670 --> 00:42:03,660 The headquarters can signal when the enemy has artillery. 996 00:42:03,660 --> 00:42:06,040 Now, how's the headquarters going to know? 997 00:42:06,040 --> 00:42:08,730 Well, it could receive the message 998 00:42:08,730 --> 00:42:10,540 from somebody else that notices his hit 999 00:42:10,540 --> 00:42:12,550 points have dropped by 20 or 40. 1000 00:42:12,550 --> 00:42:15,240 Or it could just locate an artillery. 1001 00:42:15,240 --> 00:42:17,472 Like if you actually physically walk past one, 1002 00:42:17,472 --> 00:42:19,430 then you could say there is an artillery there. 1003 00:42:19,430 --> 00:42:21,737 I should start repelling my other units. 1004 00:42:21,737 --> 00:42:24,070 They should start spreading out, because if they are all 1005 00:42:24,070 --> 00:42:26,600 clumped together, they're going to take a lot more damage. 1006 00:42:26,600 --> 00:42:29,220 They're going to take, instead of 40 damage for just one hit, 1007 00:42:29,220 --> 00:42:31,532 they're going to take eight splash damage as well. 1008 00:42:31,532 --> 00:42:32,990 And so that's going to end up being 1009 00:42:32,990 --> 00:42:35,270 an additional five times worse. 1010 00:42:35,270 --> 00:42:36,420 Yeah. 1011 00:42:36,420 --> 00:42:38,950 Well, it's going to be four times worse. 1012 00:42:38,950 --> 00:42:42,897 Five times as bad, as it were. 1013 00:42:42,897 --> 00:42:43,980 That's definitely no good. 1014 00:42:43,980 --> 00:42:46,330 So yeah, I mean, that's how you're 1015 00:42:46,330 --> 00:42:51,384 changing the shape of your cloud using the communication 1016 00:42:51,384 --> 00:42:53,050 that you're giving from the headquarters 1017 00:42:53,050 --> 00:42:55,100 or from somewhere else. 1018 00:42:55,100 --> 00:42:56,340 So you could do that. 1019 00:42:56,340 --> 00:43:00,370 You can say, when the group-- and you 1020 00:43:00,370 --> 00:43:04,070 could say like average position-- has arrived 1021 00:43:04,070 --> 00:43:07,540 at a waypoint, like at a waypoint that the headquarters 1022 00:43:07,540 --> 00:43:11,580 has specified, then go to the next one. 1023 00:43:11,580 --> 00:43:15,010 And right there you can start to fill the whole map that way. 1024 00:43:15,010 --> 00:43:16,690 Now, this is a really crazy trick 1025 00:43:16,690 --> 00:43:18,730 that I think is the bee's knees. 1026 00:43:18,730 --> 00:43:21,750 And it's just going to make the difference between amazing code 1027 00:43:21,750 --> 00:43:22,740 and non-amazing code. 1028 00:43:22,740 --> 00:43:25,760 So everybody is going to have had this situation. 1029 00:43:25,760 --> 00:43:27,930 And I've had this situation for a long time, 1030 00:43:27,930 --> 00:43:29,910 but I very rarely-- in fact, I've 1031 00:43:29,910 --> 00:43:32,369 never come up with a solution until just recently. 1032 00:43:32,369 --> 00:43:33,410 And it was the following. 1033 00:43:33,410 --> 00:43:34,910 OK, so here's me. 1034 00:43:34,910 --> 00:43:38,350 Here's me and here's the goal. 1035 00:43:38,350 --> 00:43:40,200 OK I, want to go from one to the other. 1036 00:43:40,200 --> 00:43:41,720 And a lot of times what happens is 1037 00:43:41,720 --> 00:43:43,450 I've got a large group of people, 1038 00:43:43,450 --> 00:43:44,810 and they end up splatting. 1039 00:43:44,810 --> 00:43:46,880 They just splat, and then they trickle. 1040 00:43:46,880 --> 00:43:50,380 Like this is a little thin line of trickled units. 1041 00:43:50,380 --> 00:43:52,400 And everybody else is just splatting there, 1042 00:43:52,400 --> 00:43:53,525 and they're really unhappy. 1043 00:43:56,320 --> 00:43:58,870 Yeah, it's no good. 1044 00:43:58,870 --> 00:44:01,325 I think this guy here has gone to sleep. 1045 00:44:04,200 --> 00:44:05,940 I mean, this guy started to tunnel. 1046 00:44:05,940 --> 00:44:07,800 And so he's like mining in there. 1047 00:44:07,800 --> 00:44:11,480 And then when these guys arrived, he's like, I'm tired, 1048 00:44:11,480 --> 00:44:13,340 I'm going on a workers strike. 1049 00:44:13,340 --> 00:44:14,710 So I mean, it's just terrible. 1050 00:44:14,710 --> 00:44:17,410 So here's an alternative to that that 1051 00:44:17,410 --> 00:44:19,869 may make the difference between winning and losing. 1052 00:44:19,869 --> 00:44:21,660 This may just become the dominant strategy. 1053 00:44:21,660 --> 00:44:24,200 I couldn't be more infatuated with my idea. 1054 00:44:24,200 --> 00:44:25,886 And it works like this. 1055 00:44:25,886 --> 00:44:28,660 It works like this, where I'd say, OK. 1056 00:44:28,660 --> 00:44:29,930 I'm headquarters. 1057 00:44:29,930 --> 00:44:31,720 I'm headquarters back here. 1058 00:44:31,720 --> 00:44:33,780 And I'm telling them what to do. 1059 00:44:33,780 --> 00:44:36,694 All I've got it do is look here, here, 1060 00:44:36,694 --> 00:44:38,610 and here, and I can use the senseNeutralMines. 1061 00:44:41,204 --> 00:44:42,870 I'll use the senseNeutralMines, and I'll 1062 00:44:42,870 --> 00:44:44,430 put these as the centers. 1063 00:44:44,430 --> 00:44:47,710 One, two, three, four. 1064 00:44:47,710 --> 00:44:48,950 OK, five. 1065 00:44:48,950 --> 00:44:51,590 And these are the directions that the whole swarm 1066 00:44:51,590 --> 00:44:52,250 could move. 1067 00:44:52,250 --> 00:44:54,920 And I'll say, OK, this has seven mines and this has two. 1068 00:44:54,920 --> 00:44:55,980 No, this isn't realistic. 1069 00:44:55,980 --> 00:44:56,870 They all have zero. 1070 00:44:56,870 --> 00:44:58,140 OK, they all have zero. 1071 00:44:58,140 --> 00:44:58,640 Right? 1072 00:44:58,640 --> 00:45:02,857 But then once I move down a little bit-- come on Paint, 1073 00:45:02,857 --> 00:45:03,440 come on Paint. 1074 00:45:03,440 --> 00:45:04,240 Help me out here. 1075 00:45:04,240 --> 00:45:04,420 OK. 1076 00:45:04,420 --> 00:45:06,210 Now I moved down a little bit, and now 1077 00:45:06,210 --> 00:45:08,020 some directions really look bad. 1078 00:45:08,020 --> 00:45:10,020 So what I can do is tell the whole swarm 1079 00:45:10,020 --> 00:45:13,500 to follow a waypoint set that looks like a giant robot. 1080 00:45:13,500 --> 00:45:15,670 Not like a gundam, no. 1081 00:45:15,670 --> 00:45:17,600 Like one unit of robot. 1082 00:45:17,600 --> 00:45:20,040 So the whole swarm becomes one big thing 1083 00:45:20,040 --> 00:45:22,040 that can all path around the object, 1084 00:45:22,040 --> 00:45:24,390 because I've down sampled the terrain. 1085 00:45:24,390 --> 00:45:26,610 This down sampling idea can extend 1086 00:45:26,610 --> 00:45:30,330 to full search and pathing algorithms. 1087 00:45:30,330 --> 00:45:32,920 So you'd split it up like this or so, something like this. 1088 00:45:32,920 --> 00:45:34,670 They can be overlapping or non-overlapping 1089 00:45:34,670 --> 00:45:36,000 down sample boxes. 1090 00:45:36,000 --> 00:45:38,170 You can use blur or other features 1091 00:45:38,170 --> 00:45:41,180 as standard concepts in computer science. 1092 00:45:41,180 --> 00:45:42,780 So that you can start to do pathing 1093 00:45:42,780 --> 00:45:44,440 on a much simpler matrix. 1094 00:45:44,440 --> 00:45:47,211 And this can get you to your enemy like leagues 1095 00:45:47,211 --> 00:45:48,710 faster than you would otherwise get. 1096 00:45:48,710 --> 00:45:51,544 And if you use a heuristic, then it doesn't even matter. 1097 00:45:51,544 --> 00:45:53,210 Let's say there's like a few mines here. 1098 00:45:53,210 --> 00:45:55,770 Well, maybe you'll just barrel right on through. 1099 00:45:55,770 --> 00:45:58,630 If you can just compare to the amount of mines 1100 00:45:58,630 --> 00:46:01,350 that you're going to find here versus here, 1101 00:46:01,350 --> 00:46:03,330 what better way to make that comparison 1102 00:46:03,330 --> 00:46:06,130 than to count mines in a giant area like this? 1103 00:46:06,130 --> 00:46:09,090 And these giant areas are going to be so computationally simple 1104 00:46:09,090 --> 00:46:11,700 for you to compute, because it's just one function call. 1105 00:46:11,700 --> 00:46:14,610 And I believe that function call only costs you like $100. 1106 00:46:14,610 --> 00:46:17,140 And by dollars, I mean byte codes. 1107 00:46:17,140 --> 00:46:21,490 So this has been a summary of a bunch of types of swarm, 1108 00:46:21,490 --> 00:46:23,630 but it hasn't been a complete summary yet, has it? 1109 00:46:23,630 --> 00:46:25,970 Because I told you I was going to show you that amazing code 1110 00:46:25,970 --> 00:46:26,580 that I wrote. 1111 00:46:26,580 --> 00:46:30,180 And this time I may or may not be being facetious. 1112 00:46:30,180 --> 00:46:34,540 And that amazing code where I've made this guided swarm two, 1113 00:46:34,540 --> 00:46:37,390 and I'm going to play it against a basic player on maybe 1114 00:46:37,390 --> 00:46:38,720 a couple of maps. 1115 00:46:38,720 --> 00:46:42,790 Basic player is not horrible, I guess. 1116 00:46:42,790 --> 00:46:44,490 I don't really know how good or bad 1117 00:46:44,490 --> 00:46:46,510 we are expecting to claim that it is. 1118 00:46:46,510 --> 00:46:48,890 But let's go ahead and show this match. 1119 00:46:48,890 --> 00:46:52,860 So here I've got guided swarm in red. 1120 00:46:52,860 --> 00:46:54,270 And he's starting out by building 1121 00:46:54,270 --> 00:46:57,234 a checkerboard pattern of mines. 1122 00:46:57,234 --> 00:46:59,650 And what he's going to do is when he encounters the enemy, 1123 00:46:59,650 --> 00:47:02,219 he's sometimes going to just rush straight at the enemy. 1124 00:47:02,219 --> 00:47:04,510 Other times he's going to sort of back up and then only 1125 00:47:04,510 --> 00:47:06,560 fight at the right time. 1126 00:47:06,560 --> 00:47:10,311 In this example, it looks like he was destroy-- oh. 1127 00:47:10,311 --> 00:47:12,560 Well, the enemy built artillery right next to my base. 1128 00:47:12,560 --> 00:47:13,268 It doesn't count. 1129 00:47:13,268 --> 00:47:15,750 [LAUGHTER] 1130 00:47:15,750 --> 00:47:16,500 PROFESSOR: OK, OK. 1131 00:47:16,500 --> 00:47:18,920 This one, here I am down in the bottom left. 1132 00:47:18,920 --> 00:47:20,850 I'm going to get ready to research pickaxe. 1133 00:47:20,850 --> 00:47:22,456 I'm going to do it. 1134 00:47:22,456 --> 00:47:23,830 And then when I research pickaxe, 1135 00:47:23,830 --> 00:47:25,497 their mining pattern is going to change. 1136 00:47:25,497 --> 00:47:27,038 They're going to spread out, I think. 1137 00:47:27,038 --> 00:47:28,870 Or maybe-- I might not have implemented it. 1138 00:47:28,870 --> 00:47:30,400 Well in any case, it's there. 1139 00:47:30,400 --> 00:47:34,150 It sort of exists in my mind that I'll do that sometime. 1140 00:47:34,150 --> 00:47:37,190 So what I'll do is when they arrive here, 1141 00:47:37,190 --> 00:47:38,560 I'll totally mess them up. 1142 00:47:38,560 --> 00:47:39,620 They're going to show up. 1143 00:47:39,620 --> 00:47:41,300 I'll back them up just a little bit. 1144 00:47:41,300 --> 00:47:43,040 And then they're going to be on my mines 1145 00:47:43,040 --> 00:47:45,123 and they're going to have nothing to say about it. 1146 00:47:45,123 --> 00:47:48,960 They're going to just-- they're going to-- oh, so there I go. 1147 00:47:48,960 --> 00:47:49,460 There I go. 1148 00:47:49,460 --> 00:47:51,080 I'm starting up to move out. 1149 00:47:51,080 --> 00:47:53,210 I'm starting to continue to build mines. 1150 00:47:53,210 --> 00:47:55,872 And I'm going forward. 1151 00:47:55,872 --> 00:47:58,455 I don't know that-- I think he doesn't have really any robots. 1152 00:48:01,510 --> 00:48:02,200 Yeah. 1153 00:48:02,200 --> 00:48:03,690 Yeah, super effective. 1154 00:48:03,690 --> 00:48:04,850 Oh my goodness. 1155 00:48:04,850 --> 00:48:06,120 That was fantastic. 1156 00:48:06,120 --> 00:48:08,260 I'm actually going to do-- I wonder 1157 00:48:08,260 --> 00:48:10,460 if it is working as I was expecting. 1158 00:48:10,460 --> 00:48:12,115 So in this one, I'm going across. 1159 00:48:12,115 --> 00:48:15,960 And when the enemy shows, what I'm hoping is-- oop. 1160 00:48:15,960 --> 00:48:16,830 It already ended. 1161 00:48:16,830 --> 00:48:17,360 Yes. 1162 00:48:17,360 --> 00:48:19,840 I'm hoping to sort of back up just a little bit, 1163 00:48:19,840 --> 00:48:22,420 and then take them on. 1164 00:48:22,420 --> 00:48:24,282 No, it looks like I just run straight in. 1165 00:48:24,282 --> 00:48:25,637 [LAUGHTER] 1166 00:48:25,637 --> 00:48:27,720 PROFESSOR: Well in any case, I sort of spread out. 1167 00:48:27,720 --> 00:48:29,240 I made this neat little pattern. 1168 00:48:29,240 --> 00:48:31,210 I'm starting to take these encampments. 1169 00:48:31,210 --> 00:48:32,250 It's getting done. 1170 00:48:32,250 --> 00:48:33,100 I'm doing it up. 1171 00:48:33,100 --> 00:48:34,520 Making it happen. 1172 00:48:34,520 --> 00:48:35,620 I take the other side. 1173 00:48:35,620 --> 00:48:37,289 I take more encampments. 1174 00:48:37,289 --> 00:48:39,330 And then I just sort of-- because these are like, 1175 00:48:39,330 --> 00:48:42,250 now I've got better production than he has. 1176 00:48:42,250 --> 00:48:44,511 I'm going to cast these games this well 1177 00:48:44,511 --> 00:48:45,510 when we have the finals. 1178 00:48:45,510 --> 00:48:46,562 It's going to be great. 1179 00:48:49,264 --> 00:48:50,180 I'm making more units. 1180 00:48:50,180 --> 00:48:51,030 Oh, look at this. 1181 00:48:51,030 --> 00:48:52,490 Do you see this like micro? 1182 00:48:52,490 --> 00:48:55,802 I'm backing up a little bit, letting them do it. 1183 00:48:55,802 --> 00:48:57,260 I'm do some micro here, making sure 1184 00:48:57,260 --> 00:48:59,599 that I outnumber the enemy before I go in. 1185 00:48:59,599 --> 00:49:01,640 I'm not keeping it so spread out as I was before. 1186 00:49:01,640 --> 00:49:03,556 Some guys are doing some important philosophy. 1187 00:49:03,556 --> 00:49:05,180 [LAUGHTER] 1188 00:49:05,180 --> 00:49:07,100 PROFESSOR: And those philosophical results 1189 00:49:07,100 --> 00:49:08,930 just very well may make the difference 1190 00:49:08,930 --> 00:49:12,350 between our salvation as a species and not. 1191 00:49:12,350 --> 00:49:15,540 Thank you very much for attending this swarm lecture. 1192 00:49:15,540 --> 00:49:17,040 Next lecture will be about strategy. 1193 00:49:17,040 --> 00:49:19,890 And I hope you enjoy the Indian food.