Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private final long EMPTY_BOARD = 0x0000000000000000;
- public void foo() {
- long board = 0x0000000000000000; //empty board
- for(int x = 0; x < grid.length(); x++) { //the web applications sorts the grid by columns
- JSONArray column = grid.getJSONArray(x);
- for(int y = 0; y < column.length(); y++) {
- Object raw = column.opt(y);
- int pow = 0;
- if(raw != null && raw instanceof JSONObject) {
- JSONObject cell = (JSONObject) raw;
- pow = lb(cell.getInt("value"));
- if(pow > 15) {
- //TODO: Handle overflow
- return "overflow";
- }
- }
- int value = Integer.valueOf(Integer.toHexString(pow), 16);
- int position = x * 4 + y;
- board = board & ((EMPTY_BOARD & value) >> position);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement