Skip to content

Commit

Permalink
correct tactic convert function
Browse files Browse the repository at this point in the history
  • Loading branch information
anttisalonen committed May 1, 2010
1 parent ca50bd5 commit ba5c2ed
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Gen.hs
Expand Up @@ -4,6 +4,7 @@ where

import Control.Monad.State(modify)
import Data.Word
import Data.Bits

import Data.Binary

Expand Down Expand Up @@ -73,16 +74,15 @@ plPosToTactic :: [Int] -> Gen.Tactic
plPosToTactic ps = \b -> plpoint (ballrectangle b) ps

ballrectangle :: (Float, Float) -> Int
ballrectangle (bx, by) = v
where v = y * 5 + x
x = clamp 0 4 $ floor $ (1 - bx) * 5
ballrectangle (bx, by) = y * 5 + x
where x = clamp 0 4 $ floor $ (1 - bx) * 5
y = clamp 0 6 $ floor $ by * 7

plpoint :: Int -> [Int] -> FRange
plpoint br ts =
let pn = ts !! (min 34 br)
xp = pn `mod` 15
yp = pn `div` 16
xp = pn `shiftR` 4
yp = pn .&. 0x0F
x = 1 - fromIntegral xp * (1/15)
y = fromIntegral yp * (1/16)
in (x, y)
Expand Down

0 comments on commit ba5c2ed

Please sign in to comment.