-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add snake demo for Sonata board #23
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only did a quick skim, but looks good!
nix run .#clang-lint fix
1fb708b
to
cc5b7ca
Compare
aaa3569
to
3a99827
Compare
I've fixed up all the raised comments now and changed a couple things based on feedback:
From investigation the CI quality check appears to be failing because |
Just in case anybody needs it for future reference this is how I was manually triggering the CHERI PLoad capability violation: Capability<Tile *> gameCapability{gameSpace};
gameCapability.permissions() &= PermissionSet::omnipotent().without(Permission::Load);
return gameCapability[nextPosition.y][nextPosition.x] == Tile::SNAKE; |
3a99827
to
6f7d63a
Compare
6f7d63a
to
39e88f9
Compare
…nker errors Signed-off-by: AlexJones0 <[email protected]>
Signed-off-by: AlexJones0 <[email protected]>
Signed-off-by: AlexJones0 <[email protected]>
39e88f9
to
fda7ce8
Compare
Signed-off-by: Alex Jones <[email protected]>
I've implemented the Snake demo for the Sonata board to show off the CHERI capabilities.
Currently it is implemented as a fully functional game of Snake, where the snake attempting to exit the boundaries of the display will trigger a CHERI Capability violation, which is used to detect the end of the game. The bottom and right side of the screen trigger bounds violations as we try to access outside of a 2D array representing the game. The top and left side of the screen trigger tag violations due to using a negative index on an array, which is undefined behavior. The snake colliding with itself or winning the game currently just ends the game normally, without any CHERI capability violation.
The demo should be quite customisable - you can change things like the game speed, size and appearance using the constants defined near the top of the file to tweak it as you like.
Would appreciate any feedback regarding where improvements can be made in the code - I'm still quite unfamiliar with many of the features of C++.