| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This is a derivative and the iOS version of the game 2048. In the very unlikely case that you don't know what it is, you can check it out here.
Made just for fun! You can find it on the App Store.
An AI is added, thanks to DJBen! Tap "Hint" to show hint (e.g. Move left/right/up/down); tap "Auto Run" to run AI automatically. Check it out in the AI branch. You can also check out this demo video on YouTube.
Thanks to ov3y's Javascript version that gave me (DJBen, that is) inspiration.
Currently the searching depth is 2 and it fails sometimes. You can increase the number to 3 or more by changing the return value of - (NSInteger)maximumSearchingDepth in M2GlobalState+AI.h.
Ideally, the AI should search from 0 depth to infinity and have a time out, it records the current best move when finish searching the current depth and stops immediately when timed out and return the best move so far. However, I have a little bit of trouble when dealing with NSOperationQueue so I didn't do it this way. Now the AI only searches at the specified -maximumSearchingDepth.
Since it is a derivative of the original 2048, it is not the same. More explicitly, it has the following additions:
This version of 2048 is built using SpriteKit, the new 2-D game engine Apple introduced to iOS 7. As a result, it requires iOS 7 to run. On the other hand, this app has the following two great properties:
You should be able to download the source, and build and run without problem. However, please note that you may not want to run it in the simulator unless you don't have an Apple Developer account. SpriteKit does use OpenGL, and simulating that using CPU will cause your computer to take off.
First off, the best thing about the code is that it's pretty well documented. Most methods have the Apple-style documentation, which means that you can triple-click on the method name to get its documentation.
The code started to resemble the structure of the original 2048. So for example, it has a game manager, a board class, a tile class, etc. I at least tried to stick to MVC as much as possible. Here is a brief summary to get you started:
If you'd like to contribute, great! That's more than welcome. If you do make improvements to it, remember to put yourself in the "About 2048" page to get yourself credit.
If you'd like to fork and make your own version, that's also great! Feel free to tinker with it however you'd like. It may not be a terribly good idea to change the font, add some ads, and submit to Apple, though.
2048 for iOS is licenced under the MIT license.
If you find the source code somewhat useful, all I ask is to download it from the App Store, so I know that someone has seen it. Relax: It is free; it does not have any ads or weird stuff; it does not send you push notifications to ask you to go back and play it.
You may also consider to donate to the maker of the original 2048 if you'd like, of course. (:
| Back | FazBrowse Home | New Git URL |