Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jxm262/2048-scala
2048 implementation in Scala
https://github.com/jxm262/2048-scala
Last synced: 19 days ago
JSON representation
2048 implementation in Scala
- Host: GitHub
- URL: https://github.com/jxm262/2048-scala
- Owner: jxm262
- License: apache-2.0
- Created: 2014-07-09T17:50:17.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-12-16T18:41:00.000Z (almost 10 years ago)
- Last Synced: 2023-08-21T11:26:03.847Z (about 1 year ago)
- Language: Scala
- Size: 742 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
2048 implemented in Scala
=========================I've added 3 levels of difficulty to the original 2048 game (easy | medium | hard)
## Try it out here!
http://jmaat.me/2048-Scala
Please note, this is NOT a good example of scala code :) Just something I was playing around with while on an airplane ride back from a conference in Denver. I tweaked it a bunch, but it's most likely missing a bunch of unit tests, could use refactoring, etc..
The basic idea is to make a call to a REST service which calculates the entire game board in 1 step.
For example
a grid board like -1, 2, 3, 4
1, 2, 7, 8
9, 7, 4, 5
8, 5, 4, 3Move up, will call the service as -
[POST] 2048-Scala/move
data: {
direction: "up",
nums: [1,2,3,4,1,2,7,8,9,7,4,5,8,5,4,3]
mode: "easy"
}And return the resulting list after transposing and summing any matching sibling cell (on upwards motion), then insert a random 2 in an open spot.
returns
[2,4,3,4,,9,7,7,8,8,5,8,5,0,2,0,3]And I use Jquery to reset the board -
2, 4, 3, 4
9, 7, 7, 8
8, 5, 8, 5
0, 2, 0, 3