[HN Gopher] Show HN: Defrag the Game
___________________________________________________________________
Show HN: Defrag the Game
Hi, A while ago, I came across this
https://www.youtube.com/watch?v=KR3TbL3Tl6M on YouTube showing 8
hours of defragmenting a hard drive. For some reason, it inspired
me to create this small game. Have fun :)
Author : v_b
Score : 251 points
Date : 2024-09-02 11:08 UTC (11 hours ago)
(HTM) web link (defrag-game.com)
(TXT) w3m dump (defrag-game.com)
| joseferben wrote:
| fun little game, very intuitive!
| devit wrote:
| I wonder what's the complexity class of the problem of deciding
| if it is solvable in a given number of moves?
| pkstn wrote:
| What should i do here?
| v_b wrote:
| The goal is to have as less gaps between the blocks as
| possible.
|
| The High score is calculated with the following formula:
| (elapsed seconds / 4) + operations + fragmentation
|
| operation: each movement = 1 fragmentation: each gap between
| two elements = 1
|
| inverted score system (less is better)
| pkstn wrote:
| would be maybe good idea to add instructions :D
| v_b wrote:
| May I ask how old you are? Probably not from the Windows XP
| era, huh? We "old folks" know exactly what to do when it
| comes to defragging a drive.
|
| Seriously though, thanks for the suggestion! I'll
| definitely add a small link with game rules to help
| everyone out.
| iamtedd wrote:
| Ok, but I had no idea I was already choosing a position
| to write the first file. I was pulling to refresh
| constantly on Firefox mobile until I finally figured it
| out. Which is a big difference to all the other moves -
| choosing a file to move first, before choosing a position
| to write it to.
|
| Nifty game, but I almost gave up on it when I couldn't
| figure out what the hell I was supposed to do as the
| first move.
| rbonvall wrote:
| If I was you I wouldn't bother. The cool thing is not the
| game itself, it's the fact that we "old folks" just know
| what to do right away :) If you need to read
| instructions, probably you'll find the game dull anyway.
| v_b wrote:
| Exactly this was my intetion :)
|
| Thank you
| user_7832 wrote:
| Counterpoint, I'd love to have this info. I grew up long
| enough ago to know (and do) disk defrags and the game is
| very similar to tetris in how it is fun and relatively
| easy. But iirc defrags made multiple passes, and it is
| not very clear whether the blocks in game correspond to
| pieces of the same file (where line 1 & 2 should be
| together) or of different files (where it does not
| matter). It's a nice game nonetheless!
| v_b wrote:
| @user_7832 Thank you so much for your feedback! I made
| this just for fun in my spare time, and feedback like
| yours is incredibly valuable and, more importantly,
| motivating.
|
| It shows that there are people who take the time to
| provide thoughtful feedback in return for my invested
| time, which goes beyond simple comments like "this is
| stupid because I don't understand it."
|
| Thank you!
| moring wrote:
| I remember defragmentation from ca. Windows 95 times, and
| it was totally different from this game. None of the
| files shown here is actually fragmented, only the used
| space is, and for some reason you can't place a two-block
| file across a "line break".
|
| edit: I realized that the "lines" might be meant to
| represent disk cylinders in the pre-LBA era, but even
| then, a line should "wrap around" to itself instead of
| the next line.
| em-bee wrote:
| for the next level each file could have a different
| color. then multiple blocks of the same color would be
| one fragmented file. in easy mode the order of the blocks
| would not matter as long as all of one color follow each
| other, in hard mode the blocks would have to be in a
| specific order.
|
| i would also allow blocks be moved freely with the goal
| to move as little data as possible.
| dfox wrote:
| The idea behind defragmentation is to make the files
| themselves consecutive, which is not done in any way in
| this game, which makes it somehow confusing. The fact
| that DOS/Windows defrag also moves the used space to the
| beginning of the block device is mostly an implementation
| detail (and the experience with unix filesystems seems to
| indicate that it is actually better strategy to
| intentionally fragment the files by allocating the space
| almost randomly as long as the fragments are "large").
| mrgoldenbrown wrote:
| As an old folk who watched a lot of DOS and win 3.1
| defrag I could not figure out how to play. This game has
| many confusing differences from actual defragging: blocks
| can't seem to move over each other for example. And I
| think each block can move only once? It's a neat concept
| for a game but don't blame our confusion with the UX on
| lack of familiarity with the real defrag process.
| krisoft wrote:
| > We "old folks" know exactly what to do when it comes to
| defragging a drive.
|
| Has nothing to do with age. Clearly the game has a host
| of limitations which has nothing to do with actual disk
| defragging. (Can only process the blocks one at a time in
| a specified but unknown to the user order. Blocks move
| one cell at a time and can't jump over other blocks.) And
| doesn't have others which are core to disk
| defragmentation. (Sectors, and files for example.)
| RA2lover wrote:
| note gaps between the first block and first file are counted,
| and gaps longer than 4 blocks are treated as 4-block gaps,
| but only for the fragmentation display rather than actual
| scoring.
| v_b wrote:
| I didn't mention that above, but you are correct. Kudos to
| your reverse engineering skills!
| weego wrote:
| It's a fun game, my only complaint is a UX / expectation issue:
| when I've placed a block, my natural reaction is to press space
| again to "enable" the next block for moving but, as it's enable
| by default, it locks it. I've had to restart a lot because of
| that.
| apopapo wrote:
| I get terrible performance in "hard" mode (seems to be due to
| animations?)
|
| Nice educational game!
| v_b wrote:
| Haha, I never played in "hard" mode because it was too
| challenging for me. That's probably why I didn't optimize the
| performance as much in that mode. Thanks for the feedback!
| eknkc wrote:
| Is this completely in React? Just curious as this should be
| pretty easy to render.
| v_b wrote:
| It is. To be hones I played it now in "hard" and the
| peformance was absolutley fine.
|
| I know that some browsers has still issues when it comes to
| pure CSS animations as they are running on the GPU and when
| the Hardware acceleration is disabled the CPU goes
| sometimes crazy.
|
| I had the same on an animation GitHub a while ago used on
| their landing page.
| withinboredom wrote:
| Issues seem to be random, it is like the board shifts
| back and forth to the right/left until it settles,
| causing performance to tank until it settles.
| ALittleLight wrote:
| Performance seems to get worse about midway through. I
| assumed it was an intentional difficulty increase though.
| hellohello2 wrote:
| Lags for me as well on a recent Macbook pro. (Nice game though)
| r1chardnl wrote:
| Just a matter of time before Chrome pushes another JS API like
| File System API and you can actually defrag your drive from the
| browser.
| v_b wrote:
| Should already work today with your cloud storage I think
| ossobuco wrote:
| It's already there: https://developer.mozilla.org/en-
| US/docs/Web/API/File_System...
| HeatrayEnjoyer wrote:
| Why do APIs like this even exist? There's no legitimate
| reason for an HTML webpage to need this, it's just creating
| more attack surface for bad actors.
| zamadatix wrote:
| The File System API is a JavaScript API, not an HTML one,
| so it helps to think about it from that light (programs,
| not documents). The API allows tools such as photo editors,
| file converters, code editors, and the like to be given
| access to a set of files they can work on directly rather
| than needing to import and export from the browser on every
| change. If the attack surface is too much for a use case it
| can be globally denied by default in every major browser so
| you won't even get prompted.
| HeatrayEnjoyer wrote:
| JavaScript is just a feature accessory for HTML. There's
| no meaningful difference.
| zamadatix wrote:
| For whatever your preference in slicing that up is you
| can carry the "programs, not documents" reasons along.
| nox101 wrote:
| The page needs permission. That permission step is similar
| to the act of downloading a native app. Except for the fact
| that the broswer gives even less access to your system than
| a native app so it's safer than a native app. (at least on
| desktop) That file system API is super useful for cloud
| based IDEs as just one example
| miquong wrote:
| Microsoft has an elaborate VS Code demo app that uses this
| API. Click "Open Folder" to see the API in action):
| https://vscode.dev
| zamadatix wrote:
| They say "like" this one because it only provides file level
| interaction, not disk level interaction.
| marvinborner wrote:
| I wonder what the optimal strategy is, optimize for speed with
| more fragmentation and fewer operations or for less fragmentation
| but more operations and time. For 1kb, optimizing for no
| fragmentation I can't seem to get below ~80.
| v_b wrote:
| That's the formular I am using to calculate the score: (elapsed
| seconds / 4) + operations + fragmentation
| RA2lover wrote:
| Seems like there's something off about that formula. This
| should have achieved 63 points instead of 79:
| https://i.imgur.com/QGEWpgO.png
| v_b wrote:
| Actually true. Thanks, will check this one
| r1chardnl wrote:
| From the title at first I thought this was a Quake browser port
| [0]
|
| [0] https://en.wikipedia.org/wiki/DeFRaG
| sixonesixo wrote:
| that would be amazing
| pureheartlover wrote:
| I love watching defrag vids on youtube. There's still a strong
| but small community pumping out world records.
|
| A classic from about a decade ago:
| https://www.youtube.com/watch?v=RUCtMIjL-Z4
| stavros wrote:
| I spent two seconds trying to figure out how someone would
| even do competitive defragmentation, let alone why there are
| multiple people doing it.
| ponytech wrote:
| I thought the same :)
| holistio wrote:
| Fun game, but scoring seems to be a bit off. If I just smash
| space I get a score higher than when I actually solve the puzzle.
| mapimopi wrote:
| Your goal is to score lower
| holistio wrote:
| That makes total sense. I guess "best score" would be a
| better wording in that case.
| v_b wrote:
| Thanks, I have adjusted it to:
|
| Best Score: XXX
|
| (Aim for a lower score)
|
| Just refresh the page
| nox101 wrote:
| "lowest score" would be self explanatory. "Best score"
| still made me think I was doing better with a higher
| score
|
| on the other hand, it might be better to change the
| scoring system. Calculate the worst score using the
| current system. Then reverse so the score goes up as in
| displayScore = worstScore - oldWayOfCalculatingScore
| shawabawa3 wrote:
| if i just smash space i get a lower score than when i try
| playing
|
| edit: managed to get a score of 131 for getting to 0
| fragmentation in 30 seconds, i had 139 from just spamming
| space
| recursive wrote:
| It's possible to do a lot better with strategy.
| MattGaiser wrote:
| Playing a few rounds, it shows your "high score" as the lowest
| number you earned. So it seems to be more that the score is
| inverted.
| Sarkie wrote:
| Hit the spacebar = 155 points. Solve the game = 111 points.
|
| Fun idea but not great point strategy.
|
| Thanks
| v_b wrote:
| It has an inverted score system, which means less is better :-)
| iamtedd wrote:
| Where is that explained?
| v_b wrote:
| I just updated it, it shows now:
|
| Best Score: XXX
|
| (Aim for a lower score)
|
| At the end of a round. Probably not perfect but I hope OK
| for now.
| iamtedd wrote:
| So I have to blindly play a round until I finally get the
| goal explained?
| dncornholio wrote:
| The puzzle stops after you solved the first line. You won't
| become stuck after this. Would be nice if it had reproducable
| levels because I feel like this is a product of the level
| generation. It's not providing enough problems IMO.
| liamwire wrote:
| Beautiful game that's very quick to pick up, well done.
| v_b wrote:
| That's exactly what a software developer hopes for: users
| enjoying their software.
|
| Thank you ! :)
| abcd_f wrote:
| On iPhone drag-n-drop doesn't work. Long tap basically selects
| part of the gaming field and this selection is not draggable.
| Once tap is released it shows the Copy/... menu.
| mastermedo wrote:
| You need to swipe. Works on iphone 13 + chrome.
| hinkley wrote:
| I tried swiping, got nothing.
|
| I'm not sure what else someone would interpret as drag and
| drop on a touch screen. That's gonna be swiping.
| hinkley wrote:
| It's because the game ergonomics are questionable. You can only
| slide files sideways, not past other files. Your phone isn't
| broken, not is the game engine. The game rules are.
|
| I got other things I'm supposed to be doing right now so I'm
| gonna go do those.
| insane_dreamer wrote:
| it's more just dragging than drag-and-drop; slide finger to
| move the blinking in one direction; no tapping
|
| works for me with iPhone13 + Safari
| HipstaJules wrote:
| It's fun! Thanks for sharing
| chiph wrote:
| Looks like the video is no longer available.
|
| I used to love watching the defragger back in the Windows 95
| days, and later I bought copies of PerfectDisk for both home &
| work. Unfortunately Raxco closed up shop earlier this year, and
| their license server is offline[0]. So I can't run it other than
| in trial mode. And that's a shame, as it was the only product
| that could fix the fragmentation problem we had with over fifty
| thousand files in a directory tree[1].
|
| I don't know if NTFS has a version ID or if PerfectDisk will
| respect an ID higher than it was written for, but I'm nervous
| that the now-unsupported defragger might trash the internals of
| my filesystem. :(
|
| [0] 1990's style software licensing - super annoying.
|
| [1] Startup. No time to rearchitect it correctly. Usual story.
| v_b wrote:
| I fixed the link in the post, there was a M missing at the end,
| here the correct:
|
| https://www.youtube.com/watch?v=KR3TbL3Tl6M
| sarcan wrote:
| really funny, I also think scoring should be inverted and should
| be more clear
| danbruc wrote:
| This is not like defragmenting a disk at all. There are no
| sectors or clusters, I can and have to move entire files at once.
| I have to move them in some fixed order and I can only move each
| once. Files can bump into each other?!? This is extremely
| confusing if you think the game is about what the names says.
| stavros wrote:
| Yeah, this needs an explanation, I went into it thinking it was
| like defragging and it took me a while to figure out how to
| play. Fun game, though.
| pmelendez wrote:
| Quoting OP's:
|
| |> it inspired me to create this small game.
|
| It was inspiration, not a simulation nor it claimed to be
| realistic. This is the type of artistic license that game
| designers have always had at their disposal.
| danbruc wrote:
| I am not complaining about how the game works, I am just
| saying that there are no instructions, so the only thing I
| have to work with is the name and the inspiration. And if you
| know how defragmentation works, this all just makes no sense,
| why does it automatically select blocks, why can I not move
| them repeatedly and to any free space? Sure, most people do
| not know what defragmentation is and how it works, even in
| developer circles I would not expect people to know if they
| are not old enough to have worked with computers in the 90s,
| they might hear about this in one computer science lecture
| and never think about it again.
| kwhitefoot wrote:
| I'm pretty sure that there have been disk formats that only
| write files to consecutive sectors just like memory allocators
| that only return contiguous blocks of memory.
|
| Then you need frequent compaction of the space because it ends
| up full of small unallocated blocks.
|
| See https://www.geeksforgeeks.org/file-allocation-methods/
| guestbest wrote:
| This is generally my fear in creating a game in that the
| players would take the name and rules more seriously than me as
| a designer.
|
| I liked the game, btw as it captured a certain look and feel as
| well as was fun to play.
| mrgoldenbrown wrote:
| I think what happened here is that author didn't include
| instructions, the UX was not clear, and the author said if
| you are old enough to remember defrag you'll just know what
| to do. But on the Internet everyone's a pedant and many of us
| remember DOS/ windows defrag in more detail than the OP seems
| to, so there's confusion/complaining. All that is par for the
| course though and hopefully you will still make and share
| awesome games!
| IshKebab wrote:
| Well... yeah but also defragmenting isn't a game. If you want
| to make a fun game out of it you're going to need to change a
| few things.
|
| That said, I can't see how this is fun tbh.
| monitron wrote:
| It's quite a bit more "realistic" if you imagine it as a
| simulation of the "Defragment Free Space" option that at least
| some defraggers had.
| p0w3n3d wrote:
| Funny game but that's not how defragmentation works. I was
| troubled to understand how can I choose the file by it contents
| or even why can't I write to a place where there is a block below
| it...
| alliao wrote:
| slightly unrealistic but fun idea.. makes me wonder if there are
| any benefit in AI powered caching algorithm or maybe that's what
| all the cloud providers are reaping benefits from...
| boo-ga-ga wrote:
| Lovely game, great animations, everything feels smooth.
| a1o wrote:
| I actually had played a different game before here
| https://losttraindude.itch.io/zfrag
| memming wrote:
| The domain appears to be flagged as "gambling" under Cisco
| Umbrella service. (Yes, I clicked on the link at work.)
| kwhitefoot wrote:
| Surely it should have a leader board?
| vunderba wrote:
| The subtle blue color theme is great!
|
| When I was younger, we used to joke about doing the opposite,
| deliberately fragmenting every file on the drive to put them as
| far as possible from each other so that your magnetic drive would
| just THRASH.
|
| I like to make sure the actuator arm gets a good workout to feel
| the burn.
| hinkley wrote:
| > 8 hour defrag
|
| In the NT 4 era I had a defrag take almost 18 hours. I started it
| before leaving for the day and came in the next morning to find
| it an unknown percentage done. I didn't trust it would be okay to
| restart the machine so I had to leave it.
|
| That was a problem because we were running version control on
| this box. But by then everyone was bought in so we got a
| dedicated machine out of the ordeal, but that was super annoying.
|
| We even called Microsoft and got through, but it turns out on NT
| defragment happened in real mode so there isn't a lot of memory
| to buffer copied blocks. So it spends a lot of time seeking on
| the hard drive. So stupid.
| samstave wrote:
| 5200 RPM HDD? likely contributed to time seeking?
| AshamedCaptain wrote:
| > out on NT defragment happened in real mode so there isn't a
| lot of memory to buffer copied blocks
|
| NT cannot run anything in real mode after ntldr. (And even boot
| time defragmenters run way after ntldr).
| mgaunard wrote:
| I have no idea what the rules are, doesn't look like disk
| fragmentation at all.
| hobs wrote:
| Took me a second to get the rules, but a fun little unblocking
| game, good work!
| weaksauce wrote:
| not to be confused with the original defrag game mode
| https://en.wikipedia.org/wiki/DeFRaG
| khadadalek wrote:
| I played this way too long. It did take me a a game or two to
| figure out how the UI worked on desktop and what the point was,
| but after that, it's a fun little puzzle game.
|
| I like!
| v_b wrote:
| That was a bit intentional. I personally enjoy exploring games
| and figuring out how they work before developing strategies. It
| makes the game more fun for me. However, I do understand the
| feedback that if someone still doesn't get the game after one
| or two rounds, something might be off.
|
| At the very least, it's great to hear that I've won one fan!
| I'm really grateful for the time you invested in something I
| created. Thank you!
| insane_dreamer wrote:
| Fun. Feedback: the only thing I found confusing is that it's not
| clear that the first block that is blinking is a data block.
| Maybe if it started with no block selected, and the user has to
| press Enter/Space to begin the game at which point the first data
| block starts blinking. That would make it clearer.
|
| Reminds me of Sokoban.
| NelsonMinar wrote:
| There's a fun simulator of Windows defrag with sounds here:
| https://defrag98.com/
| ALittleLight wrote:
| I love it.
|
| I think it needs an undo button. It sucks being most of the way
| through the hard level when you accidentally double tap space and
| ruin your game.
|
| I also want to see score as a percentile of everyone who did it
| or as being X out of possible Y.
___________________________________________________________________
(page generated 2024-09-02 23:00 UTC)