 Rwyf yn dda. Rwyf yn gweithio'r rôl y ddrwy. Rwyf yn gofyni a'r k exceptional arfer y maes o'r un i'r newydd a'r myfyrwyr. Pngwrs, oedd y maes. F collective I am Stephen, ac mae'n golygedd i'r rôl at y myfyrwyr yn gyfrydio'r newydd i'r newydd. Yn y gall, mae'n bwrw i. So in December I gained a lightning tour that was three minutes in which it was about how to solve minesweeper. I was very kindly invited to come here and give a longer version. 15 minutes. And I thought, yeah, that's fine. No problem. Can do. The last talk I did was actually quite late on details. Instead of just explaining how to do it, we'll actually explain how to implement it instead of just how to use solviles. So, here goes. Things are going to get very, very weird. So just bear with me. My name's Sergeant Sweep. My name is both a literatess and a pun for comedic effects. Okay, so the year is 2030. The world has been ravaged by war and turned to ruins. Starting in the USA, every country on Earth started planning landslides. Three months ago, we started the cleanup efforts. Trying to clean up after World War I. Three. World War III. It's not 1960. The year is 2030. It's all over the place. I've seen these robots for the cleanup efforts. It's 2030. Everything's automated. But there was one task that our robots couldn't do. Mine's sweeping. Also, one of the robots exploded from sheer confusion. The one robot that's left is called Davy, and he'll make the appearance later. So now it's going to be you, our new army recruits. You've come in to hell by with the cleanup, because the robots can't do it. We've got humans to do it. It's good to see your names irrelevant. Your mission to sweep mines. And you're training on the job. That's the point where we swap a laptop. You can check in army school. That's a power cable. You are a new recruits, and we are going to teach you how to sweep mines. So hands up, who has played minesweeper before? Training is mandatory. You won't be getting out of it like that. This is how minesweeper works. Every cell can contain either a mine, or it can be clear. If it is clear, it will contain a number from 0 to 8, telling you how many mines you're surrounding it. For example, this one says that those two cells contain exactly one mine. The blank ones are zeros, which you can... Yeah, they're zeros. So, the screw is the middle. For example, this says that those three cells must contain exactly three mines. Of course, that means that all of them must be mines. And we can flag it. We can see that here in the target section. Three cells, three mines, that's right. We can flag it. If we flag that, now this two is satisfied. It says that it needs two mines next to it, and it already has two. So we can satisfy that. We can clear around that constraint. And we can do that. And we can just repeat this. So now this one is already satisfied. This one's already satisfied. And there's only one way to satisfy this two. That's basic training. And this is where the audience participation can sit. So if anyone sees four chocolates, what we can clear off like here. And you're going to put your hands up, and then Gavir is going to run at you. Take your pick, Gavir. Bottom left. Bottom left, too. Well, look, I actually got this. Look, CSS, Transform and everything. Oh! So cell 28. What's happening in the future, please? Currently, there's one of these red chocolates. There you go. Do shout out to Gavir, please, because we've got combos and they're going to have to be really huge. Anyone else? What else do you clear now using what I've just told you about clearing and flagging? Show the numbers. Show the numbers. Thank you. I've spent hours on that. Push four. 44. So 44. This one down here can clear this because of this constraint. Yes. So because that one is already satisfied, we can clear it. Any more? This one's pretty easy. Show the numbers. Yep. I'm going to remember a wrench 18. Number 18. I haven't taught you how to do that. Anyone else? Yes, you can. You can clear it because of this one. This one is already satisfied so you can clear around there. Does anyone see anywhere else that we can clear now? No, because there is no other place to be cleared. That means that it's time for advanced trading. That's because we actually, instead of looking at any of these individual constraints, we need to look at how to constraints are correct. For example, this constraint says that any of those two cells must be a mine. One of the two cells must be a mine. This constraint says that one of those three cells must be a mine. But we know because of the orange constraint that it's one of the two on the left. So if that's subtraction, essentially, we can say that that cell on the right can't be a mine because the mine must be one of the two on the left. In a very general term, we can do subtraction any time you have one constraint which is a subset of another. And you can see that, actually, Davy there has been repertless and his job is now to automatically clear things with a trivial. So because of that subtraction, we knew there wasn't a mine there, Davy has helpfully cleared it for us. And then we can just proceed using the things that we've learnt in the pack. But subtraction is hard and you are only recruits. So we're going to have a little bit more training. In this situation, again, we're going to apply the same rule that we have before where this one says there is a mine in one of these two, this one says there's a mine in one of these three. Subtract and we can clear that one. But actually, we can try and apply it here and we end up with a new constraint. It's not something that we can clear off like immediately. So because there's one mine here and there's two, so, yeah, there's one mine in these two which means that there's one mine in these three in order to satisfy the two. We can't do anything with that yet, but if we subtract this one again and we subtract both of these ones from the two, we can say that there can't be everything in that corner. There is one other place that we can do subtraction here which is on these two cells. They produce constraints by one of the subset of another and we can subtract to clear these bottom three cells. Then we can repeat this by finding constraints which overlap and eventually work through the board. So, pay attention. Actually, we've just seen something else. These cells are lines through them. Davy has got an upgrade. Davy's got another one to clear things that he sees as a trivial, and he's also going to highlight cells that can be cleared or flagged. So, no more topics are going out for telling you where I can clear or flagged things. We can process these through with Davy's help and clear the ones that we need. So, let's go back to yours. Does anyone see anywhere we can do some subtraction? We want two constraints that are overlapping. Can I have cell 80 again then? Cell 80. So, let's do some straightening doing that based on. The two ones at the top. These two. So, you want to subtract those from each other, and that will produce not cell 18. Cell 32 can be cleared. Cell 18 is a mind in my opinion. No, we can't say that. Two top ones. There could be a mind either of these two and it would satisfy both of these. Have a chocolate! Who's next? Anywhere else we can subtract. Someone else! Run, Gavir! Don't give the microphone to this someone! We've got... Right, where do we subtract? I don't know. OK, this one. Does anyone see any other cell which would create a constraint which is a subset of this one? The one in the middle. That. This one? Yeah. Yeah. Pick a number. 1930, 347. 19, 33, 47. Yes! Because we subtract these constraints from each other. There must be a mind here, so there can't be one in any of these three cells. We subtract these two constraints, one minus one is zero, there can't be any minds in these. Good job! Have a chocolate! Right! I forgot that one! Someone from this side! Anywhere else that we can subtract two constraints. One of them is that one. A cell that produces a constraint to the subset of that orange box. The one above it? The one above it. I really need to start doing it. Pick a number! Oh, God! Number 19. So this one. So neither of those is a subset because they only overlap. We need one constraint which is entirely contained within the other. The one that I had in mind was this one. So this one says that those two cells must contain one and that's entirely contained within the orange section. If we subtract those, then we actually have the four says there are four minds in its constraint and the one says there's one there which means that the remaining three cells must all be minds and we can mark them like that. Are we kind of generally following? Yeah? So, I have your twenty-five one more that we can do and then we'll go back to you. So this three, there are four cells there and it says there's one mind because it's already got two of them. So we know that exactly one of these four cells is a mind. The constraint created by this one is a subset of the orange one. That means that we could do subtraction. In this case it makes sense to because that blue constraint also contains exactly one mind which means that the bit that is only orange here but not overlapping bit contains zero minds. If we subtract, you see, it's going to create two cells of zero minds and it's been cleared automatically for us because we know that it can be cleared. So, Davy is broken temporarily and we've just turned it back on. We can see that this one is clearable because that one is already satisfied and then all of these are satisfied. We've hit some zeroes and automatically cleared those. So, I reckon that some of you now are going to be able to tell me where we've been subtracted. So pick two cells with overlapping constraint. Where one constraint is a subset of another. Ten and twenty-four, yes. So this one says that those two must contain one mind and this one says that those three must contain one mind. If we subtract, we can clear that one. Davy will tell us that we can clear this one because there are only two places for those minds and then we can clear this one because they're already satisfied. So, is there any or else that we can clear? Can anyone see anywhere when we have two overlapping and two one constraint a subset of another? Yes. Next to that three, you have that two that there needs to be a bond either in seventy-one or seventy-two, so fifty-six and seventy are not a bond. Seventy-one or seventy-two, so fifty-six. Fifty-six and seventy you can clear. That sounds like something I haven't taught you yet. Yes, you will come round to that. So, you're actually back on. This is something that we can't do yet. There is no subtraction we can do here because there are no two constraints though one is an actual subset of another. However, there are some more advanced techniques so this is a technique that I'm calling reduction. That's what we call it in the army. Yes, Bron. What about clicking wildly and then saying it's just hunkering? What are you saying? We're in the military now. A military protocol says that you can't just go randomly walking across a minefield. In fact, no matter how hard I click this, it won't let me die and you must use the B-strains because let's work on this, right? That's right. This says that these three cells must contain exactly two miles. However, that also says that any two of those three cells have to have between one and two miles because the cell that isn't inside those two can either be a mine or a baryism. If the one that we exclude is a mine then there'd be one in these two. Let's say if this one was a mine then there would be one mine in these two. If it wasn't a mine then there'd be two in these two. So, we can do that for any of these three cells. If we click reduce it will create three new constraints down here. One that says there is one to two miles in these two one that says there's one to two miles in these two and one that says there's one to two miles in these two. If you're thinking about it that now allows us to do some more subtraction. For example, previously this two didn't wasn't a subset of the one but by removing one of the cells in the constraint giving us that little bit of uncertainty we can now subtract it from the one. So, there is one to two miles inside this orange constraint and there's exactly one inside the blue constraint so we know there can't be two in the orange constraint and we know that there isn't any here at all because they're all inside the orange constraint and subtracting it will show us that and let us clear that one set. We can then just go back to our normal subtraction. We can do the two in that section there's only one in the orange constraint and we can go back to our normal clearing. There you go, success! But there are even more complicated constraints. Sorry, even more complicated set up such as this one. This is actually a commonly given example as to why mine is sweeper is empty at least but we can kind of solve it here mostly because we're humans. This two, if we reduce it and take this constraint we can subtract from the corner two which says these five cells have two in them but we know that these orange have one to two in them. Subtract that, we get a new constraint which says these three have zero to one cells zero to one lines and then we can do the same on the other side reduce this constraint, take the bottom one and subtract that from our new one and we can actually say that that corner cannot be a mine because we know at least one line is in the two above it and at least one line is in the two to the left of it. That satisfies between the corner and that's a solve that and from here we can just work our way around with basic clearing and flagging, no subtraction required. There is one other button that I have here which is merge and I'll briefly explain that to you. Essentially, sometimes we can end up with constraints down here which constrain the same cells but with different upper and lower bounds. If we have two constraints which constrain the same cells but one has a higher lower bound and one has a lower upper bound we can merge those together and take the highest lower bound and the lowest upper bound. For example, if we reduce this one and take that one, these two and then we reduce this one, sorry this is a little bit complicated but it does come in handy. So we can then subtract these two and we can say as we have before that this contains between zero and one lines. Obviously that means that these two also can take between zero and one lines which is this constraint but now these two constraints are both constraining the same two cells. One says there's between one and two lines and one says there's between zero and one lines. But both are close to be true but can only be true that there is exactly one line and in fact we can merge it and get a constraint that says there's one line. I'm not sure you're going to need that but you might do depending on how you solve this next bit. Going back to the things that we've just learned take a moment and take a breath. Have a look at this and see if we can see anywhere that we can use reductions and subtraction to solve this. Hands up again. I've got a lot of chocolate to give away. Yes, cells. Here we go. 74. 74, yes. Why? Which constraint are you basing that on? I'm basing it on cell 72. So these two. So there's already one. Yep. So if we reduce the two, sorry, reduce the two we turn those on. So if we reduce the two and take the right most two cells and that says there's between zero and one cells in there which doesn't tell us anything about this other than that there are zero to one cells in there as well. So we can't be too sure because the two already has one bomb next to it then all we can say is that there is one line here meaning there's between zero and one here because it might be here then when we subtract we just end up saying again there's zero to one. It's zero line. This one here? Yeah, that one doesn't have a line. Because there is one that's two. Right, yes. We've just done this the wrong way. So this one subtract, this one is what we wanted. This one says that these two cells must contain one line. This one says that these five cells must contain one line. Obviously the only place of mind could be isn't the orange and we subtract. That was my bad in interpreting instructions wrongly. What we follow through with is clearing flag. I think we can end up clearing all of this. Good job. Anything else that we could do? Can I have cell 18, please? Cell 18? You still can't say anything about cell 18. You can't say anything about cell 18. She wants your designs. No, it's literally impossible. I haven't coded the functionality of just collecting a cell. I made this. We'll get that. Cell 97, please. Cell 97. OK, so cell 97 is quite a mess. Should have seen that one coming. One of the things that we looked at quite a bit before was looking at these ones and twos that overlap. So I'm going to throw it out of that straight away that we can reduce this two and just take the two left of the cells. So we know that there are between one and two but mind is orange section. If we subtract from one we can say that there is zero nine inside the green because there is a minimum of one, a maximum of one and we know that there's at least one, so yes. We can know that there aren't any minds there. If we layer that, it allows us to follow through with these very basic clearing and subtracting until we get stuck again. But there are still some other places that we could add clear and some subtraction that we do. I'm not... You don't even need directions here. So you've seen this before. Can anyone see anywhere where we have two overlapping constraints? One is a subset of a number. Yep, numbers, here we go. 81, 82. 81, 82. Yes, so these two overlap, they're not quite subtraction but we can reduce the three, we can take the two right-nose cells and then we can subtract those two cells from the two and that's going to tell us that there's between one and two minds inside those three right-nose ones. Do we see anywhere else that we can go from there? 91, 92. 91, 92. So that's... Do you mean these two? Yeah, one, four, three. Yeah, so if we reduce the four that we want, yep, take the two right-nose cells from there and then subtract that from the three which is actually one and that can clear that set. Good job, I've been really forgetting about these. You just need a shot, have you? Yes. You can get out one as well. Good job, right. So we've managed to clear that three. Where else can we do now? That's actually opened up some new possibilities for us. Here are the numbers. Next to that four, it can clear that 61. 61, is this one here? Yes, and I think it's the same because of this. Because of these ones, yeah. So the one that says that these two must contain one, mine and the four, it has three of its forms already so this L shape contains one, mine. If we subtract those, we can clear that one. That one cell. Yeah, you can just keep going. Anywhere else that we see? That three just opened up another chain thing. The three opens up. So can you keep the numbers? Yep, here are the numbers. 75 is not the mine, right? Because of that three that just appeared. So it's because of the same rule. 75 is not the mine. What else are you combining here? Which two constraints? The constraints of the four lines are 45 and 69. Yes, these two. Fantastic. So yes, the three has two of its lines already. We know that it must be satisfied by those two cells and we can clear that up. We can keep going. We're not stuck, yes. Three of the four here are the numbers. 74 and 75. 74 and 75 are, yes. So if we take these to you, yes. So the four says that three of those four cells are the nine and the one says that two of those three cells are the nine. There's only one cell left and it must be a nine. Now we can mark it. We can definitely keep going still. Tuft some off. I've got six bags of pombex. Fantastic. You're going to find somewhere that you can subtract. That's great. There you go. Yes. There you go. Right, yes. Right. Did we see anywhere else? Anywhere else we could subtract? Yes. Yes, there we go. 26 is clear. Are you doing this based on these two? No. 26 is clear. Are you doing this based on these two? Yes. No. These are both just because of the ones. So if we reduced that to three, and that would give us, we actually can't, we won't let us, because it's still defining meaningful information. Most of the things that it reduced to would just mean this cell is either a mine or not a mine, which isn't something that we can reason about. Because we know that anyway, that's kind of just a base rule to go. Or is that, am I missing something? I'm missing something. Another number. Another number is yes. 76 and 77. 76 and 77. These two constraints, do you want me to reduce the four? We can't reduce the four. We can't reduce either of these. Where? Right, I'm going to click this button. What it has done is it's changed this to show the remaining number of bombs rather than the current number. Where can we sell? Sell 83. 83 is over here. And how are we doing this? Which constraints? 68 has got one mine next week already. We've got a change to show us the remaining number. That's way three. But you want me to, yeah, can we do this? Hang on. Right, so yeah, there we go. 93 and 78. 93 and 78. Can we subtract it from each other? No? Right. What I'm looking at is this number. 73 is 78. 93 is 78. 93 is 78. 93 is 78. 93 is 78. 93 is 78. Can we subtract it from each other? No? What I'm looking at is this, no, sorry, these two. This three says that these three cells must contain two mines. But this three also says that these two must contain two mines. That helps to solve that one. And then we can hopefully just follow these through with clearing and flagging. That was a bit of a pain. And here actually, one of the constraints that we produced earlier by reduction, let's just say that that one's clear. Because the two we said were one here, we know there was one, so this one couldn't be a mine. And we can follow these all the way up. And in fact, we can follow basically everything all the way up. It just leaves this section. I'm just going to come out right now and say that this is actually impossible to solve currently. You can't say there's two options here. The mine could be there, and it could be there, and it could be there. Or there could be one here and one here. But actually, we know the total number of mines because the bodies and the espionage parts have totaled the number of mines. And this is your final part of training. Let's do it. Jesus Christ. I'm going to warn you before. I don't want to trouble you. Have you got any more corn trucks? There you go. Right, so, looking at the fact that we now have a total of mines, this board has six mines. We can use that like any other constraint. We know that there are three mines in this section, so we can subtract these two constraints. There's a few constraints. There are seven cells in three mines. We can do the same on the other side and get down to the fact that there are now no mines in either of those top two cores. Because we know that there are six, and we recounted for all six. After that, we can just follow these through. And this is solvable with the subtraction overlap as subtraction and reduction stuff that we talked about earlier. So, if we now know the total number of mines, right, does anyone see what we can do with this? Here are your cell numbers. It's worth a chocolate. Sixty. Sixty. You can subtract this constraint. We have this constraint with five and this constraint here is a subset of that. Yeah? Right in that moment constraint, there are two mines in the orange. We can now say that in that remaining orange constraint there is one mine. We can do the same back up here. And we can subtract and we can answer that there are no mines in that top section. Because, as I said before, there are two options. There are either two mines or three mines. We know that there are only two mines, so we can just accept that solution. We can then follow it through and we have solved this mine field. So, you said that there are only two mines. We said that there was no way of knowing and there isn't. Until we got to the very end and we counted for all the other mines. So, well done all your crew. You have successfully cleared your first minefield. There are only 14 more to go today. And then you'll be able to return home to your wives and families. Thank you very much for listening. Have some more chocolates. This is not going right. Don't do it. Don't do what? Do the chocolates. Right, there you go. Right. That was how to sell a minefield from Polydeumio Time. The answer is use humans and not computers. My name is Stephen Waterman. You can read the code for this on github at Stephen Waterman. I've got a website, StephenWaterman.uk. There we go, even better. Yeah. A company told me about what just happened. I hope you enjoyed it and I hope you have a good rest of the evening. Thank you very much.