Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
CodeT5+ model Fine-Tuned to the commit messages generation task.
|
| 8 |
+
|
| 9 |
+
### Example of usage via HF api:
|
| 10 |
+
Paste into the text field code modifications in the given commit. For example:
|
| 11 |
+
```Haskell
|
| 12 |
+
Filename: src/Game.hs
|
| 13 |
+
Status: modified
|
| 14 |
+
Additions: 21
|
| 15 |
+
Deletions: 8
|
| 16 |
+
Total changes: 29
|
| 17 |
+
Code changes:
|
| 18 |
+
@@ -24,7 +24,8 @@ data Man =
|
| 19 |
+
, speedY :: Float
|
| 20 |
+
, posX :: Float
|
| 21 |
+
, posY :: Float
|
| 22 |
+
- } deriving (Show)
|
| 23 |
+
+ }
|
| 24 |
+
+ deriving (Show)
|
| 25 |
+
|
| 26 |
+
-- We need to store game state
|
| 27 |
+
data Game =
|
| 28 |
+
@@ -51,6 +52,9 @@ windowSizeY = 700
|
| 29 |
+
manSize :: Float
|
| 30 |
+
manSize = 16
|
| 31 |
+
|
| 32 |
+
+topGrassSize :: Float
|
| 33 |
+
+topGrassSize = 22
|
| 34 |
+
+
|
| 35 |
+
grassSize :: Float
|
| 36 |
+
grassSize = 150
|
| 37 |
+
|
| 38 |
+
@@ -61,7 +65,7 @@ skyWidth :: Float
|
| 39 |
+
skyWidth = 2048
|
| 40 |
+
|
| 41 |
+
bottomBorder :: Float
|
| 42 |
+
-bottomBorder = - windowSizeY / 2 + grassSize
|
| 43 |
+
+bottomBorder = -windowSizeY / 2 + grassSize
|
| 44 |
+
|
| 45 |
+
obstacleWidth :: Float
|
| 46 |
+
obstacleWidth = 30
|
| 47 |
+
@@ -70,7 +74,7 @@ obstacleHeight :: Float
|
| 48 |
+
obstacleHeight = 100
|
| 49 |
+
|
| 50 |
+
obstacleY :: Float
|
| 51 |
+
-obstacleY = bottomBorder + obstacleHeight / 2 - 22 -- | 22 accounts for top-most layer of grass
|
| 52 |
+
+obstacleY = bottomBorder + obstacleHeight / 2 - topGrassSize -- | 22 accounts for top-most layer of grass
|
| 53 |
+
|
| 54 |
+
obstaclePic :: Picture
|
| 55 |
+
obstaclePic = color red $ rectangleSolid obstacleWidth obstacleHeight
|
| 56 |
+
@@ -82,7 +86,7 @@ initTranslateGrassX :: Float
|
| 57 |
+
initTranslateGrassX = grassWidth / 2 - windowSizeX / 2 -- starting from the left border of the picture
|
| 58 |
+
|
| 59 |
+
initTranslateGrassY :: Float
|
| 60 |
+
-initTranslateGrassY = - windowSizeY / 2 + grassSize / 2
|
| 61 |
+
+initTranslateGrassY = -windowSizeY / 2 + grassSize / 2
|
| 62 |
+
|
| 63 |
+
initTranslateSky :: Float
|
| 64 |
+
initTranslateSky = skyWidth / 2 - windowSizeX / 2 -- starting from the left border of the picture
|
| 65 |
+
@@ -99,10 +103,14 @@ getSprite name = "sprites/" ++ name ++ ".bmp"
|
| 66 |
+
-- manPic :: Picture
|
| 67 |
+
manPic :: Picture
|
| 68 |
+
manPic = unsafePerformIO . loadBMP . getSprite $ "man"
|
| 69 |
+
--- manPic = color black $ rectangleSolid manSize manSize
|
| 70 |
+
|
| 71 |
+
+-- manPic = color black $ rectangleSolid manSize manSize
|
| 72 |
+
grassPic :: Picture
|
| 73 |
+
-grassPic = translate 0 initTranslateGrassY (unsafePerformIO . loadBMP . getSprite $ "grass")
|
| 74 |
+
+grassPic =
|
| 75 |
+
+ translate
|
| 76 |
+
+ 0
|
| 77 |
+
+ initTranslateGrassY
|
| 78 |
+
+ (unsafePerformIO . loadBMP . getSprite $ "grass")
|
| 79 |
+
|
| 80 |
+
skyPic :: Picture
|
| 81 |
+
skyPic = unsafePerformIO . loadBMP . getSprite $ "sky"
|
| 82 |
+
@@ -152,14 +160,18 @@ checkCrush game =
|
| 83 |
+
obstaclePosX = head (obstacles game) + obstaclesTranslation game
|
| 84 |
+
in (playerPosX + manSize / 2) >= (obstaclePosX - obstacleWidth / 2) &&
|
| 85 |
+
playerPosX <= (obstaclePosX + obstacleWidth / 2) &&
|
| 86 |
+
- playerPosY <= (obstacleY + obstacleHeight - 22) -- | See obstacleY to understand what 22 is
|
| 87 |
+
+ playerPosY <= (obstacleY + obstacleHeight / 2 + topGrassSize)
|
| 88 |
+
|
| 89 |
+
updateGameSate :: Game -> GameState
|
| 90 |
+
updateGameSate game
|
| 91 |
+
| gameState game == Over = Over
|
| 92 |
+
| checkCrush game = Over
|
| 93 |
+
| otherwise = gameState game
|
| 94 |
+
|
| 95 |
+
+
|
| 96 |
+
+accelerate :: Float
|
| 97 |
+
+accelerate = 0.001
|
| 98 |
+
+
|
| 99 |
+
updateGame :: Float -> Game -> Game
|
| 100 |
+
updateGame seconds game =
|
| 101 |
+
game
|
| 102 |
+
@@ -169,6 +181,7 @@ updateGame seconds game =
|
| 103 |
+
, obstacles = nextObstacles
|
| 104 |
+
, obstaclesTranslation = nextObstaclesTranslation
|
| 105 |
+
, gameState = updateGameSate game
|
| 106 |
+
+ , gameSpeed = gameSpeed game + accelerate
|
| 107 |
+
}
|
| 108 |
+
where
|
| 109 |
+
nextManPosY
|
| 110 |
+
@@ -185,7 +198,7 @@ updateGame seconds game =
|
| 111 |
+
| otherwise = backgrounds game
|
| 112 |
+
nextObstaclesTranslation
|
| 113 |
+
| obstaclesTranslation game <
|
| 114 |
+
- -windowSizeX / 2 - 100 - head (obstacles game) = 0
|
| 115 |
+
+ -windowSizeX / 2 - head (obstacles game) = 0
|
| 116 |
+
| otherwise = obstaclesTranslation game - gameSpeed game
|
| 117 |
+
nextObstacles
|
| 118 |
+
| nextObstaclesTranslation == 0 = drop 1 $ obstacles game
|
| 119 |
+
```
|
| 120 |
+
|
| 121 |
+
True commit message is: **acceleration added**
|
| 122 |
+
|