{"push_id":1362684944,"size":1,"distinct_size":1,"ref":"refs/heads/master","head":"d9b2e0d6c89cfff64f823ee8993c3208e61767bf","before":"ff14fd67d3089f6fcf04fe306b9dedc05d2d97f5","commits":[{"sha":"d9b2e0d6c89cfff64f823ee8993c3208e61767bf","author":{"name":"Grace Fu","email":"bdc5c71ecba03cf9b25f01648534975aee1624d6@gmail.com"},"message":"Implement pysweeper with random mine generation (will add hash-random stuff later)\n\nDiff with minsweeper.py:\n\n```\n*** mods/pysweeper.py\t2016-10-22 23:58:50.000000000 +0800\n--- mods/minesweeper.py\t2016-10-22 23:59:18.000000000 +0800\n***************\n*** 2,10 ****\n\n  import random\n\n! game_mode_name = \"Pysweeper\"\n\n! class Pysweeper:\n      hooks = {}\n      required_events = [\n          (\"pysweep\", \"<F2>\"),\n--- 2,10 ----\n\n  import random\n\n! game_mode_name = \"Minesweeper\"\n\n! class Minesweeper:\n      hooks = {}\n      required_events = [\n          (\"pysweep\", \"<F2>\"),\n***************\n*** 42,48 ****\n\n      def modsloaded(self, hn, e):\n          self.gamemodeselector = self.pysweep.mods[\"GameModeSelector\"]\n!         self.gamemodeselector.register_game_mode(game_mode_name, priority=0, default=True)\n\n          self.gamedisplay = self.pysweep.mods[\"GameDisplay\"]\n\n--- 42,48 ----\n\n      def modsloaded(self, hn, e):\n          self.gamemodeselector = self.pysweep.mods[\"GameModeSelector\"]\n!         self.gamemodeselector.register_game_mode(game_mode_name, priority=1, default=True)\n\n          self.gamedisplay = self.pysweep.mods[\"GameDisplay\"]\n\n***************\n*** 128,145 ****\n\n          self.state = \"started\"\n          self.timer.start_timer()\n!         # Just set the current cell to determined so no mines can be generated there,\n!         # then let the rest of the click handler do the job\n!         self.determined.append((row, col))\n!         self.notdetermined.remove((row, col))\n\n      def lose_game(self, row, col):\n          # Blast at row, col\n          width, height = self.gamedisplay.size\n\n          self.timer.stop_timer()\n-         # Determine all tiles\n-         self.determine_all_tiles()\n          # Display all mines\n          for (minerow, minecol) in self.mines:\n              if (minerow, minecol) not in self.flagged:\n--- 128,153 ----\n\n          self.state = \"started\"\n          self.timer.start_timer()\n!         # for now let's just generate all mines on game start.\n!         while self.mines_generated < self.num_mines:\n!             row_ = int(random.random() * height)\n!             col_ = int(random.random() * width)\n!             if (row_, col_) not in self.mines and (row_, col_) != (row, col):\n!                 self.mines.append((row_, col_))\n!                 self.notmines.remove((row_, col_))\n!                 self.mines_generated += 1\n!         # determine all the cells\n!         self.notdetermined = []\n!         for row_ in range(height):\n!             for col_ in range(width):\n!                 self.determined.append((row_, col_))\n!\n\n      def lose_game(self, row, col):\n          # Blast at row, col\n          width, height = self.gamedisplay.size\n\n          self.timer.stop_timer()\n          # Display all mines\n          for (minerow, minecol) in self.mines:\n              if (minerow, minecol) not in self.flagged:\n***************\n*** 157,165 ****\n          width, height = self.gamedisplay.size\n\n          self.timer.stop_timer()\n-         # Determine all tiles just in case there was a huge chunk of\n-         # undetermined but guaranteed mines in a corner\n-         self.determine_all_tiles()\n          for (minerow, minecol) in self.mines:\n              self.gamedisplay.set_tile_flag(minerow, minecol)\n          self.gamedisplay.set_face_cool()\n--- 165,170 ----\n***************\n*** 189,197 ****\n          if self.state == \"notstarted\":\n              self.start_game(row, col)\n\n-         # Determine the tiles around it before doing anything else\n-         self.determine_around_tile(row, col)\n-\n          self.opened.append((row, col))\n          self.notopened.remove((row, col))\n\n--- 194,199 ----\n***************\n*** 215,248 ****\n              # we've opened everything :D (without blowing up)\n              self.win_game()\n\n-     def determine_all_tiles(self):\n-         width, height = self.gamedisplay.size\n-\n-         for row in range(height):\n-             for col in range(width):\n-                 self.determine_tile(row, col)\n-\n-     def determine_around_tile(self, row, col):\n-         for drow in range(-1, 2):\n-             for dcol in range(-1, 2):\n-                 row_, col_ = row + drow, col + dcol\n-                 self.determine_tile(row_, col_)\n-\n-     def determine_tile(self, row, col):\n-         width, height = self.gamedisplay.size\n-         if (not (0 <= row < height and 0 <= col < width) or\n-                 (row, col) in self.determined):\n-             return\n-\n-         numspaces = len(self.notdetermined)\n-         nummines = self.num_mines - len(self.mines)\n-         ismine = self.rng.random(nummines, numspaces)\n-\n-         self.determined.append((row, col))\n-         self.notdetermined.remove((row, col))\n-         if ismine:\n-             self.mines.append((row, col))\n-\n      def num_mines_around(self, row, col):\n          number = 0\n          for (minerow, minecol) in self.mines:\n--- 217,222 ----\n***************\n*** 297,300 ****\n      def on_mouse_move(self, hn, e):\n          pass # TODO: This will feed into the rng!\n\n! mods = {\"Pysweeper\": Pysweeper}\n--- 271,274 ----\n      def on_mouse_move(self, hn, e):\n          pass # TODO: This will feed into the rng!\n\n! mods = {\"Minesweeper\": Minesweeper}\n```","distinct":true,"url":"https://api.github.com/repos/thomastanck/pysweeper/commits/d9b2e0d6c89cfff64f823ee8993c3208e61767bf"}]}
{"actor":{"display_login":"thomastanck"}}