Skip to content

Commit

Permalink
Merge pull request #18 from AleoHQ/comment-fix-improve
Browse files Browse the repository at this point in the history
Some fixes and improvements to comments.
  • Loading branch information
d0cd authored Nov 30, 2022
2 parents 63da325 + 8016139 commit b50dfe9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions battleship/imports/board.leo
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,22 @@ program board.aleo {
};
}

// Returns a new board state record that includes all the played tiles.
// Fails if r1 has been played before.
// Returns a new board state record that includes all the played tiles,
// updated with a given shot.
// Fails if the shot has been fired before.
transition update_played_tiles(
// The record of the board to update.
board: board_state,
// The u64 equivalent of a bitstring fire coordinate to send to the opponent.
shoot: u64,
) -> board_state {
// Need to make sure r1 is a valid move. Only one bit of r1 should be flipped.
// Need to make sure shoot is a valid move. Only one bit of shoot should be flipped.
let flip_bit: u64 = shoot - 1u64;
// bitwise and operation
let check_move: u64 = shoot & flip_bit;
console.assert_eq(check_move, 0u64);

// Need to make sure r1 is a valid move given the played_tiles. no bits should overlap.
// Need to make sure shoot is a valid move given the played_tiles: no bits should overlap.
let check_tiles: u64 = shoot & board.played_tiles;
console.assert_eq(check_tiles, 0u64);

Expand All @@ -92,7 +93,8 @@ program board.aleo {
};
}

// Returns a new board state record that includes all the hits and misses.
// Returns a new board state record that includes all the hits and misses,
// updated with a given hit-or-miss from a shot.
transition update_hits_and_misses(
// The record of the board to update.
board: board_state,
Expand All @@ -114,5 +116,3 @@ program board.aleo {
};
}
}


0 comments on commit b50dfe9

Please sign in to comment.