Can I Code Minesweeper in One Hour?

Поділитися
Вставка
  • Опубліковано 22 жов 2024

КОМЕНТАРІ • 151

  • @TechWithTim
    @TechWithTim  2 роки тому +56

    What should I challenge myself to code next? Let me know!

  • @matt-xq1xv
    @matt-xq1xv 2 роки тому +116

    Not only does he teach you how to code. He teaches basic theory and how to break down problems like a programmer. Tim, this is why you're at the top bro. Great video.

  • @JanBrugg
    @JanBrugg 2 роки тому +70

    Tim, just as a side note:
    I think the positions of the bombs are determined after your first click, since your first click should always uncover a safe field

    • @TechWithTim
      @TechWithTim  2 роки тому +32

      Good note! I am clearly not a very experienced minesweeper player lol

    • @dalevanderzee4086
      @dalevanderzee4086 2 роки тому +21

      In original minesweeper, it is possible on first click to click on a bomb, so keeping with tradition I would say code your bombs before your first click

    • @kenhaley4
      @kenhaley4 2 роки тому +1

      I agree with Dale--it is possible to click on a bomp at the get-go. Also, I don't think the original minesweeper has a limit on the number of flags.

    • @candyxxv5834
      @candyxxv5834 2 роки тому +1

      @@dalevanderzee4086 bruh I’m coding a full minesweeper for a school project and I spent like hours trying to have the board fill after the first click…

  • @craigbates178
    @craigbates178 2 роки тому +26

    Would love to see this seen through final debug, optimization, adding animation, etc.

  • @nikitabronx5728
    @nikitabronx5728 2 роки тому +9

    Thanks, Tim. I started to learn Python a week ago. You're motivating me!

  • @krishnans2006
    @krishnans2006 2 роки тому +3

    I really enjoyed this - watching you code a real project and following your journey was really cool! This reminds me of those old 12-hour livestreams you used to do - would definitely love to see more of these types of videos!

  • @fustigate8933
    @fustigate8933 2 роки тому +9

    Thanks for the tutorials Tim, the pygame videos were also very exciting!

  • @devangkhatri4772
    @devangkhatri4772 2 роки тому +1

    Would really love to see the continuation video tim , big up for this much progress though!

  • @bibekbasnet3750
    @bibekbasnet3750 2 роки тому +1

    Thank you Tim ! I am following your programming expert course and so far I am loving it ! I really hope to build crazy stuffs like you using python someday

  • @jessicabidon9903
    @jessicabidon9903 2 роки тому +1

    The adjacent tiles should only be revealed if you click a tile with 0 adjacent mines (or if you double click a revealed tile). So the uncover function can be done really simply with recursion, by adding a check if the field value is 0 and then uncovering that tile's neighbors.

  • @mrlax3946
    @mrlax3946 2 роки тому +1

    Great work Tim! definitely wrap up this project and I'd say explain a bit about how you implemented DFS algorithm to expand when you click as I believe that the most challenging part of the project is implementing that correctly.

  • @St0rytell3r
    @St0rytell3r 2 роки тому

    Love it. Minesweeper is such a fun coding challenge. Sudoku, wordle, solitaire, they're all great ways to mess around and develop. Keep doing what you're doing.
    -Stan

  • @Nevim469
    @Nevim469 2 роки тому +3

    Had lot of fun watching this video, looking forward for more videos like this! :)

  • @karthikp6266
    @karthikp6266 2 роки тому +2

    This kinda videos are motivating us and inspiring us to learn coding 🤩, thank u bro 👍

  • @Tcrunz
    @Tcrunz 2 роки тому

    Thanks for the vid!
    Maybe a fun sequel to these would be to show us how you would refactor it into perfectly polished, distributable code?

  • @andrewanastasiades6819
    @andrewanastasiades6819 2 роки тому +3

    Tim you are an amazing coder and a terrible mine sweeper XD thanks for the vid!

  • @ilikelamps1126
    @ilikelamps1126 2 роки тому +11

    The video idea reminds me of The Coding Train! Keep up the great work.

  • @tcgvsocg1458
    @tcgvsocg1458 2 роки тому +1

    i really like the..."ok maybe more difficult game that hard that its look..."
    THE BEST UA-camR EVER !!!!thx a lot tim

  • @ianyourgod
    @ianyourgod 2 роки тому

    I've been trying to learn object oriented programming in python, and this is really fun to watch!

  • @gavin4056
    @gavin4056 8 місяців тому

    I made a minesweeper game for my ap computer science class in highschool, still one of my most memorable projects. It definetly took longer than an hour though lol.

  • @seaphor665
    @seaphor665 2 роки тому +1

    Yes, please complete this video, and then do a video of how you would do it correctly if you had more time.

  • @starsky51
    @starsky51 2 роки тому +2

    I really enjoyed this - great format! It feels like one of the six hour marathon videos but with a more structured approach. I also like Tim's coding style - I often get stuck trying to make ugly concise code. Tim videos remind me to keep my code readable!

  • @nkish
    @nkish 2 роки тому +1

    When playing the game at 56:35, you are forgetting the numbers represent the number of bombs in adjacent cells _including on the diagonal_!

  • @starblockstudios
    @starblockstudios 2 роки тому +5

    Anybody else realise that when he replaced all "MINES" with "BOMBS" at 34:50 he changed the window caption to "BOMBSweeper"? Lol, great video though

  • @pravachanpatra4012
    @pravachanpatra4012 2 роки тому +3

    Tim can make a social media clone, chat app, Pygame golf game, etc

  • @bloodaikanswalke
    @bloodaikanswalke Рік тому

    Very awesome tutorial, though I WOULD have wished if you were able to finish the challenge in another video, if possible. I know this is an old video, but it would still be awesome. My own opinion.

  • @MrMattie725
    @MrMattie725 2 роки тому +9

    I love how you can code Minesweeper but are really bad at the game itself :D (And that's putting it mildly)

    • @TechWithTim
      @TechWithTim  2 роки тому +3

      Haha agreed. I never really played it.

  • @tomborjigen2284
    @tomborjigen2284 8 місяців тому

    I love whenever Tim goes "WOW"

  • @igon388
    @igon388 2 роки тому

    Lol the bug right at the end, I wondered if that would ever show itself. Also the ability to just flag uncovered tiles and recover them was pretty funny I thought

  • @Grigoriy457
    @Grigoriy457 2 роки тому +3

    Hi Tim!
    What plugin did you use (32:10)?

  • @chrisdanny5180
    @chrisdanny5180 2 роки тому

    Your talent is something else

  • @MuhammadAbidSiddique
    @MuhammadAbidSiddique 2 роки тому +1

    This is a great tutorial.
    Can you please break it down for beginners? If possible.

  • @brookestephen
    @brookestephen 2 місяці тому +1

    set board boundaries and max bombs
    randomize the placement of bombs, append to a list of the form ["row.col"] - ensure same board square is only used once
    determine the bomb counts touching each board square , save in a separate dictionary of the form ["row.col", count]
    set the board & squares, naming each square in the form "row.col", setting each image to BLANK
    set right click and left click event listeners for each board square
    wait for user input:
    LEFT CLICK
    - if no touching bombs, expand selection until board boundaries and until first square touching bombs using recursion!
    - if selection is a bomb, you LOSE!
    RIGHT CLICK
    - keep flags and ? in separate lists of the form ["row.col"]
    - if board square BLANK, set image to FLAG, and if all bombs have been flagged, you WIN!
    - if board square FLAG, set image to ?
    - if board square ?, set image to BLANK

  • @ameerhamzakhan8054
    @ameerhamzakhan8054 2 роки тому +1

    It would be awesome if you could code a 8 puzzle or 15 puzzle game next

  • @Xlore127
    @Xlore127 2 роки тому

    I get invalid color argument when using "white" or "black" as definitions and have to use the RGB values. How are you able to just use the word?

  • @tcgvsocg1458
    @tcgvsocg1458 2 роки тому

    thx a lot tim for this huge thx to you continue

  • @teprox7690
    @teprox7690 Рік тому

    when are this live coding challenges will come back ?

  • @davidardo4466
    @davidardo4466 2 роки тому

    Is mathematics important in programming or not? Can you do better when math is bad
    Please answer me

  • @victorsamuelalojadoyuricha1775

    are you interested in making a no guessing mode for minesweeper?

  • @lavycube3521
    @lavycube3521 2 роки тому

    An idea for another coding challenge - Bulls And Cows game + solver.

  • @brandsmp
    @brandsmp 2 роки тому +1

    Please create a top down shooter game in pygame, a classic arcade game

  • @NanoSharkDev
    @NanoSharkDev 2 роки тому

    i would like to see the full game programimg

  • @AriehAnkri
    @AriehAnkri 2 роки тому

    You can use event.key, event.pos, event.button instead of pygame.key.get_pressed()
    it is more clear that is from the specific event

  • @nikos4677
    @nikos4677 2 роки тому

    omg i learned how to play mine sweaper yesterday and this video was uploaded yesterday

  • @duyha2454
    @duyha2454 Рік тому

    Thank you

  • @unknownman5296
    @unknownman5296 2 роки тому

    Please make more video like this

  • @marcrindermann9482
    @marcrindermann9482 2 роки тому

    it would have been useful to know how the game is played :D anyway, nice video

  • @hotlemonadesauce2042
    @hotlemonadesauce2042 2 роки тому +2

    Hey tim, what would you suggest web dev with django or web dev in the classic method?

    • @johannes8144
      @johannes8144 2 роки тому

      First you should get your basics done (html, css, js) then write something with an external api and get a feel for it, then you could start outsourcing your logic to your backend. Which could be something like django.

  • @purplemosasaurus5987
    @purplemosasaurus5987 2 роки тому

    How is Tabnine guessing the majority of lines of your code?

  • @JRom_19
    @JRom_19 2 роки тому +1

    I'm attempting to follow along with what you're doing in this video but when trying to just run the blank window, as you do around 6 minutes into the video, I get an error saying:
    pygame.error: video system not initialized
    Any help with this would be appreciated. I've been looking online for a solution but havent been able to fix this exact issue.
    Thanks

    • @TechWithTim
      @TechWithTim  2 роки тому +1

      Type Pygame.init() right after u import it

    • @JRom_19
      @JRom_19 2 роки тому

      @@TechWithTim It's in there.
      I have the first two lines of code
      1 import pygame
      2 pygame.init()

    • @JRom_19
      @JRom_19 2 роки тому +1

      @@TechWithTim I fixed it. Just started over and it worked the second time. I must have just had some other error in the syntax somewhere else.
      Thanks, Tim! love the content as usual.

  • @taloan9699
    @taloan9699 2 роки тому

    13:45 hmmm... i wonder what you were about to type subconsciously...

  • @apfelmuse3426
    @apfelmuse3426 2 роки тому

    Hi Tim, what auto completion are you using?

    • @vask5500
      @vask5500 2 роки тому

      I think kite or tabnine

  • @codingcassowary6391
    @codingcassowary6391 2 роки тому

    What a great project and tutorial! I believe that more often than not people learn so much more from a project like this, especially when they can see it being developed from scratch so they can follow along on a second screen, than by reading some formal book on how to code. 💻 >>> 📖

  • @godwinsojan6205
    @godwinsojan6205 2 роки тому

    this is a good stuff 😀. can you make a course about unity game engine plz
    it help me a lot

  • @rusov1040
    @rusov1040 Рік тому

    Sometimes on my first click bombs are being uncovered. Does anyone have a solution? (Great video BTW :))

  • @diegonti
    @diegonti 2 роки тому +1

    Which autocompleater does he use?

  • @davifraga1290
    @davifraga1290 2 роки тому

    where is the github of this project?

  • @MinhTechie
    @MinhTechie 2 роки тому

    Hi Tim, I wonder if I can feature my channel on yours. I can make some videos about really cool animations in React Native 😉

  • @mikoajkahl9451
    @mikoajkahl9451 2 роки тому +1

    Great video but you really have to practice playing minesweeper haha !

  • @Zellaaaaaaaaaaa
    @Zellaaaaaaaaaaa 2 роки тому

    Nice video!

  • @PerfectmindAMV
    @PerfectmindAMV 2 роки тому +1

    how to make web 3.0 website in python 🙂

  • @RajveerSingh-rk9bg
    @RajveerSingh-rk9bg 2 роки тому

    please make a zombie hunter game

  • @Fabik11
    @Fabik11 2 роки тому

    Do it in java next time. Great video overall!

  • @sazzadrahman2189
    @sazzadrahman2189 2 роки тому

    Make a bot which replies in facebook messenger with some quick replies or buttons.

  • @JelloTalks
    @JelloTalks 2 роки тому

    Bro codes minesweeper in an hour, while I take an hour to center a div

  • @autobot1281
    @autobot1281 2 роки тому

    Tim I am stuck with the basics of python
    Please help me please please thank you so much

    • @johannes8144
      @johannes8144 2 роки тому

      First program your own tic-tac-toe game, in the console. That should not be too hard, then refactor your code using more functions, less nesting etc. and maybe try programm paradigms like OOP. If you finished it, you could start implementing an algorithm to play against you, or you could focus on design, and implement it in pygame with a GUI. If you finished that, you could try to build an even more complex game, like connectFour or Monopoly, stick to your things that worked on your tic-tac-toe game, and you will get it done. Some tips: At all cost separate your IO from your logic → implement functions to read from the console and don't do it in your main logic code. Send a person your code on discord servers and ask for feedback. And most importantly keep focused, and don't spend your time watching UA-cam videos, of people programming, get YOUR hands dirty. Hope it helps, GL :)

  • @uberwass
    @uberwass 2 роки тому

    How about Jezzball

  • @thirtyvirus7731
    @thirtyvirus7731 2 роки тому

    Its gray in us and everywhere else its grey. WEIRD. Thats probably why you forget xd

  • @UnderfundedScientist
    @UnderfundedScientist 2 роки тому

    Legendary

  • @MrTheoTugboat
    @MrTheoTugboat 2 роки тому

    I liked this.

  • @potatohater5599
    @potatohater5599 2 роки тому +1

    watching him try to play is infuriating but otherwise grate tutorial haha

  • @dylancaldwell8337
    @dylancaldwell8337 2 роки тому

    You could speed run tic tac toe against another player or computer, and give yourself like 30 minutes to do it?

  • @rubixrj7074
    @rubixrj7074 2 роки тому

    Too many magic numbers - can tell when you are adding comments to if lines.

  • @inspisiavideos8542
    @inspisiavideos8542 2 роки тому

    Hi! Please teach email preferences center templates for a contact page. I recently lost a job opportunity to work making html templates. I look for templates over youtube but couldn’t find one they like

    • @enderduck4253
      @enderduck4253 2 роки тому +1

      a) not entirely sure what you're asking for.
      b) if you aren't even able to change things in tutorials to suit your needs, which is pretty basic, then you aren't really learning. This applies not just to coding but to everything. You're not learning anything at that point, you're just mindlessly copying someone else's work. Reevaluate your learning methods and make changes, even if it makes it more challenging for you. And try to stop relying on tutorials by using documentation instead.

  • @Snorlena
    @Snorlena 2 роки тому

    My Python skill is like your mines skill lol.

  • @eazyaviation
    @eazyaviation 2 роки тому

    epuic

  • @SkyFly19853
    @SkyFly19853 2 роки тому

    That's so cool...
    ✅✅✅✅✅✅

    • @SkyFly19853
      @SkyFly19853 2 роки тому

      @J Hemphill
      Oh... I didn't know about emoji part...

  • @lichtkoni
    @lichtkoni 2 роки тому

    For the algorithm

  • @olwenyemmanuel2838
    @olwenyemmanuel2838 2 роки тому

    institution management system

  • @OBlTO-02-10
    @OBlTO-02-10 2 роки тому +1

    #

  • @natyacodes
    @natyacodes 2 роки тому

    tim will heart this :>

  • @dittery
    @dittery 2 роки тому

    i kind of feel like python is really cheaty cuz you can just use all these libraries like pygame and turtle to lay the groundwork for you instead of actually having to understand how it works

    • @nogr3369
      @nogr3369 2 роки тому +3

      No need to reinvent the wheel.

    • @dittery
      @dittery 2 роки тому +1

      @@nogr3369 i get you, but im wondering: do other languages like C++, java, javascript, etc. have these kinds of libraries? you can literally make a game so easily with python because all the dirty work is already done for you by turtle and pygame, do such tools exist for other languages? if they do, then I guess its not so bad. Im moreso worried about this because I want my experience with python to carry over to new languages hwen I eventually move on to them

    • @nogr3369
      @nogr3369 2 роки тому +2

      @@dittery I understand the concern, and it is important to understand how things work instead of just blindly using them. The problem is, sometimes those things are really complex and would take a lot of time to understand and implement on your own, making it incredibly time consuming to complete any project. Thus, libraries are a common thing in pretty much every single programming language from Python to C and the good ones will have documentation you can use to get a better understanding of how the code works.

  • @artemon121
    @artemon121 2 роки тому

    Нихуя не понятно, но очень интересно

  • @SomeoneRandom-f9o
    @SomeoneRandom-f9o 2 роки тому +2

    First view 😉

  • @mitjakomi2
    @mitjakomi2 2 роки тому

    second

  • @rami_atallah
    @rami_atallah 2 роки тому

    Nice try

  • @chikkii1601
    @chikkii1601 2 роки тому

    First comment 🥳🥳🥳🥳🥳🥳🥳

  • @rexbhargav6427
    @rexbhargav6427 2 роки тому +1

    pagal bna rhe hai ye

  • @guybrush3000
    @guybrush3000 2 роки тому

    WHY ARE YOU SO BAD AT SEEING DIAGONALS?
    Never been more frustrated at watching someone play minesweeper

  • @lumiere4460
    @lumiere4460 Рік тому

    Nice coding, but you do not know anything about Minesweeper.

  • @thewelder3538
    @thewelder3538 2 роки тому

    Wow, this is a terrible way of coding a minesweeper game. Also, I wouldn't do this as a 2D array, that's like the childish thinking way. The array should be flat.

    • @TechWithTim
      @TechWithTim  2 роки тому

      How would you represent it as a flat array? I’m curious what your method would be consisting you are far superior to me.

    • @thewelder3538
      @thewelder3538 2 роки тому

      @@TechWithTim Not superior, but I have been coding games at well known software house for, eerrm, wow, nearly 13yrs now. And yes, I am OLD. Okay, flat array... You think of a 2D array like it has an X and a Y coordinate, but that's not how it actually is. A 2D array is layed out contiguously in memory, or at least it is in C++, not sure how the Python interpreter does it. So let's say you have an 8x8 2D array... Like say, a[8][8]. What would happen if you did, and I'm not sure what the syntax is for Python, but a[8] = 1. This should be equivalent to a[1][0] = 1. So you don't treat your array like it has two dimensions, but has a contiguous length of 64. Do you see where I'm going with this?

    • @thewelder3538
      @thewelder3538 2 роки тому

      @J Hemphill I nearly died laughing at your comment. Although I have to be careful when laughing, since the company I work for was responsible for a very public lootbox controversy.

  • @nite5963
    @nite5963 2 роки тому +3

    Uncover_from_pos would’ve been good to be recursive, you just need to make sure you don’t need to uncover an already uncovered tile

  • @cristiangonzalez140
    @cristiangonzalez140 2 роки тому

    Start_time should be time.time()