Skip to content

Commit

Permalink
Fix order of numbers in state in Grid.prototype.getState
Browse files Browse the repository at this point in the history
  • Loading branch information
triciatricia committed Mar 16, 2014
1 parent dfa6cc3 commit 22f724b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions js/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ Grid.prototype.getState = function() {
var offset = stateY * this.size + stateX;

if (offset < Grid.CELLS_PER_STATE) {
state1 += (val * Math.pow(Grid.MAX_CELL_VAL, offset));
state2 += (val * Math.pow(Grid.MAX_CELL_VAL, offset));
} else {
state2 += (val * Math.pow(Grid.MAX_CELL_VAL, offset - Grid.CELLS_PER_STATE));
state1 += (val * Math.pow(Grid.MAX_CELL_VAL, offset - Grid.CELLS_PER_STATE));
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions js/__tests__/gridTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('getState', function() {
[null, null, null, null],
[2, null, null, null]
],
expected: [0x00000000, 0x10000000]
expected: [0x10000000, 0x00000000]
},
{
cells: [
Expand All @@ -46,7 +46,7 @@ describe('getState', function() {
[null, null, null, null],
[null, null, 2, null]
],
expected: [0x10000003, 0x00000000]
expected: [0x00000000, 0x10000003]
},
{
cells: [
Expand All @@ -55,7 +55,7 @@ describe('getState', function() {
[null, null, null, null],
[null, 4, 4, 8]
],
expected: [0x2000300b, 0x00022000]
expected: [0x00022000, 0x2000300b]
}
].forEach(function(testInput) {
it('tests ' + testInput.cells, function() {
Expand All @@ -71,4 +71,4 @@ describe('getState', function() {
expect(grid.getState()).toEqual(testInput.expected);
});
});
});
});

0 comments on commit 22f724b

Please sign in to comment.