1 / 6

In the following slides, I will first show an ordinary algorithm to count mines in a mine field.

Count Mines. In the following slides, I will first show an ordinary algorithm to count mines in a mine field. I will use a 3*4 board as illustration, which can be easily scaled up to a bigger board of any size based on the same principle.

eloise
Download Presentation

In the following slides, I will first show an ordinary algorithm to count mines in a mine field.

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Count Mines • In the following slides, I will first show an ordinary algorithm to count mines in a mine field. • I will use a 3*4 board as illustration, which can be easily scaled up to a bigger board of any size based on the same principle. • After that, I will illustrate an improved algorithm and please think carefully. CG1101 (AY2012/13 Semester 1) 1

  2. Ordinary algo. to count mines #1 Case 1 (inner cell) 3*4 mine board score board CG1101 (AY2012/13 Semester 1) 2

  3. Ordinary algo. to count mines #2 Case 2 (boundary cell) 3*4 mine board score board CG1101 (AY2012/13 Semester 1) 3

  4. Ordinary algo. to count mines #3 Case 3 (corner cell) 3*4 mine board score board CG1101 (AY2012/13 Semester 1) 4

  5. Enlarged 5*7 mine board with outer frame of all 0 Improved algo. illustration Original 3*4 mine board CG1101 (AY2012/13 Semester 1) 5

  6. Count Mines • Got it? • Ok, you may get the idea, then how to implement it? • That’s your task  • Hint: you will need to do some major change to the given skeleton if you want to apply the improved algorithm to lab#4 ex5. • Overall, a better algorithm will make your program easier to write and debug. • Therefore, for complex problems, spend some time to thinking about the algorithm before coding! CG1101 (AY2012/13 Semester 1) 6

More Related