Placeholder Image

字幕列表 影片播放

  • The following content is provided under a Creative

  • Commons license.

  • Your support will help MIT OpenCourseWare

  • continue to offer high quality educational resources for free.

  • To make a donation or to view additional materials

  • from hundreds of MIT courses, visit MIT OpenCourseWare

  • at ocw.mit.edu.

  • INSTRUCTOR: So today, we start on project 4, which is,

  • as you know, the big project.

  • And Helen is going to do a walkthrough of the project,

  • and the code, and the organization,

  • because this is a pretty big sized project.

  • It's got about 4,500 lines of code.

  • And it's not code that is kind of like simple code.

  • It's all content-bearing code.

  • So I think having a bit of an orientation to it,

  • more than we give for the other codes that you work,

  • on which are pretty small, this will be great.

  • So, Helen, take it away.

  • HELEN XU: Hi, everyone.

  • Can you hear me?

  • Awesome, so today we're going to be doing the walkthrough

  • for the final project.

  • You can look at the code and clone it publicly here.

  • And please remember to fill up your team's by 7:00 PM today,

  • so we can populate the list and get your repos.

  • Yeah, and if there are any issues accessing this,

  • just let me know.

  • Or put it on Piazza and then we can fix it.

  • So we just had a game of Lesierchess.

  • But in case you missed it, we'll go

  • into more details about what the game actually does.

  • So first, we're going to go through the game rules.

  • So you saw that there are these pieces.

  • There's these triangles.

  • And there's kings.

  • So the triangles are pawns.

  • And the kings, they look like crowns.

  • And there are two teams.

  • There's orange and lavender, or tangerine and lavender.

  • And each side starts out with seven pawns and one king.

  • And this is the starting position.

  • So you can see like the kings are in the corner.

  • And they're just lined up like in the middle.

  • And each piece has four orientations.

  • So you can see that the pawn is up, down, left, right.

  • And then the king is also like that.

  • And in general, the game starts with tangerine moving first.

  • And then the play alternates between the two players.

  • Each piece moves the same, whether it's king or pawn.

  • And each turn has two parts.

  • So you saw the demo.

  • But you move first.

  • When you pick one of your pieces, and you move first.

  • And then at the end, your King has to fire the laser.

  • And the laser reflects off the long edge of the pawn.

  • And they'll kill the pawn if it shoots the short edges.

  • And one side wins when the king gets shot,

  • or when the opposing king gets shot, whether by themselves

  • or by your own king.

  • And so I talked a little about moving.

  • And at the beginning of each turn, the player to move

  • chooses a piece to move.

  • And you can move your King or any of your pawns.

  • And there are two types of moves.

  • There's basic moves, and swat moves.

  • And basic moves are just, basically, shifts or rotations.

  • So in the example, you can rotate 90, 180, or 270 degrees.

  • So in the top, row you just rotate.

  • This is the example of moving a pawn.

  • So you rotate your pawn.

  • Or you can move to an empty adjacent square.

  • So those are the bottom two rows.

  • And there are eight adjacent squares in this example.

  • So there are eight shifts.

  • But there would be less than eight

  • if you were, for example, like at the edge of the board.

  • And on a move, you can either shift or rotate.

  • But you can't do both.

  • There are also these swap loops.

  • So if you're adjacent to an opposing piece,

  • you can switch with them.

  • And then you have to make another basic move

  • after that, that is not a swap.

  • So, basically, you can either--

  • and it has to be with that same piece

  • that you just swapped with.

  • So you just either shift or rotate.

  • Is everyone good on the rules?

  • Just a couple more things.

  • So there's this Ko rule, which is

  • from Go, which ensures that the game makes progress.

  • So it makes a move illegal if it undoes the opponent's most

  • recent move by just moving back to where you just were.

  • So this is an example.

  • Let's say you're tangerine.

  • And you swapped with the purple one right next to you.

  • And then you shifted left and bottom.

  • And so lavender can return by swapping back

  • with your orange piece, and shifting again.

  • But this is actually, illegal because now

  • you just got to your original position.

  • So you're not allowed to just keep cycling back and forth.

  • And so a draw occurs if there have been 50 moves by each side

  • without a pawn being zapped, the same position

  • repeats itself by the side on move,

  • or the two players agree to a draw.

  • So just kind of like in chess, a chess clock

  • limits the amount of time the players have to make a move.

  • So you can't just keep competing indefinitely.

  • When it's your moves, your clock counts down.

  • When it's your opponent's moves, your clock stops.

  • So it's not counting your time.

  • And we used Fisher time control.

  • There's a picture of Bobby Fisher, who

  • made it, up which used an initial time budget and a time

  • increment.

  • So in this example, there's fis60 and 0.5,

  • which means that, in the beginning,

  • each player has 60 seconds.

  • And you get to use the 60 seconds however you want.

  • And when you end your move, you get 0.5 extra seconds.

  • But the 60 and 0.5 could be anything.

  • That's just an example.

  • So we'll go into an example of how you actually

  • play this game.

  • For a king to zap the enemy king,

  • it risks opening itself to counter-attack.

  • So look at this example.

  • And how can tangerine zap the lavender pawn in F5,

  • by moving one of its pieces?

  • AUDIENCE: [INAUDIBLE]

  • HELEN XU: Move C4.

  • AUDIENCE: Tangerine, that's lavender.

  • HELEN XU: You're tangerine in this example.

  • And you're trying to zap the one on F5.

  • Yep?

  • AUDIENCE: You move the tangerine piece at E22 to F1.

  • HELEN XU: E2 to F1.

  • Oh, sorry, by zap, it means shoot the backside.

  • That would shoot the long side.

  • Good point.

  • Yeah, so you're trying to kill the piece on F5.

  • AUDIENCE: [INAUDIBLE]

  • HELEN XU: Yeah, exactly.

  • So in this, you can move C2 to B1, as you just said.

  • And then you draw the path.

  • And you can see that you've just killed--

  • or if you're tangerine, you've just killed the piece at F5.

  • Now, how can lavender counter?

  • By counter, we mean lavender can win

  • the game from this position.

  • AUDIENCE: Is it A4 to A3?

  • HELEN XU: A4 to A3.

  • No, I don't think so.

  • Yep?

  • AUDIENCE: [INAUDIBLE]

  • HELEN XU: Sorry, what?

  • King, like the orange one?

  • Oh, the lavender one.

  • You're trying to shoot the orange king.

  • Oh, yes, you're right.

  • You can, actually.

  • Yes, good, that's not the one that we had,

  • but apparently there are two ways.

  • Good.

  • So if you notice you could also--

  • that's another way to get that path.

  • But you can also move one of the pawns.

  • Cool, so this is just pointing out

  • one of the subtleties of the game, which is you