|
@ -1,6 +1,8 @@ |
|
|
import Datatypes |
|
|
import Datatypes |
|
|
import VM |
|
|
import VM |
|
|
|
|
|
|
|
|
|
|
|
import qualified Datatypes.Unit as Unit |
|
|
|
|
|
|
|
|
import Data.Hashable (hash, Hashable(..)) |
|
|
import Data.Hashable (hash, Hashable(..)) |
|
|
import Data.Set (Set) |
|
|
import Data.Set (Set) |
|
|
import qualified Data.Set as Set |
|
|
import qualified Data.Set as Set |
|
@ -12,7 +14,7 @@ test f = [f (0,3) == (2,5), f (1,3) == (3, 6), f (2,3) == (3,7), f (3, 3) == (4, |
|
|
test2 :: (Cell -> Cell) -> [Bool] |
|
|
test2 :: (Cell -> Cell) -> [Bool] |
|
|
test2 f = [f (2,5) == (3,6), f (3,6) == (2, 7), f (2,7) == (1,7), f (1, 7) == (1,6), f (1, 6) == (1,5), f (1, 5) == (2, 5)] |
|
|
test2 f = [f (2,5) == (3,6), f (3,6) == (2, 7), f (2,7) == (1,7), f (1, 7) == (1,6), f (1, 6) == (1,5), f (1, 5) == (2, 5)] |
|
|
|
|
|
|
|
|
deepCheck p = quickCheckWith (stdArgs { maxSuccess = 10000 }) p |
|
|
|
|
|
|
|
|
deepCheck p = quickCheckWith (stdArgs { maxSuccess = 100000 }) p |
|
|
|
|
|
|
|
|
testTutto = do |
|
|
testTutto = do |
|
|
deepCheck (\pivot cell -> let r2 = rotateCell pivot in (r2 . r2 . r2 . r2 . r2 . r2) cell == cell) |
|
|
deepCheck (\pivot cell -> let r2 = rotateCell pivot in (r2 . r2 . r2 . r2 . r2 . r2) cell == cell) |
|
@ -32,21 +34,21 @@ testTutteRotazioni = checkForNothing [ |
|
|
testControRotazioni (5, 5) [(6,1), (8,4), (7, 8), (4,9), (1,6), (2,2), (5,5)] |
|
|
testControRotazioni (5, 5) [(6,1), (8,4), (7, 8), (4,9), (1,6), (2,2), (5,5)] |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
--testCentering = deepCheck (\up um um1 -> let b = Board 5 10 (Set.fromList []) |
|
|
|
|
|
-- u = Unit (Set.fromList (um1:um)) up |
|
|
|
|
|
-- c = centerUnit u b |
|
|
|
|
|
-- bw = 5 |
|
|
|
|
|
-- xCoords = Set.map (\(x, y) -> x) (unitMembers c) |
|
|
|
|
|
-- yCoords = Set.map (\(x, y) -> y) (unitMembers c) |
|
|
|
|
|
-- unitLeft = Set.findMin xCoords |
|
|
|
|
|
-- unitRight = Set.findMax xCoords |
|
|
|
|
|
-- unitTop = Set.findMin yCoords |
|
|
|
|
|
-- deltaLeft = unitLeft |
|
|
|
|
|
-- deltaRight = bw - unitRight - 1 |
|
|
|
|
|
-- in (deltaLeft == deltaRight || (deltaRight - deltaLeft) == 1) && unitTop == 0) |
|
|
|
|
|
|
|
|
testCentering = deepCheck (\up um um1 -> let b = Board 5 10 (Set.fromList []) |
|
|
|
|
|
u = Unit up (Set.fromList (um1:um)) |
|
|
|
|
|
c = Unit.centeredIn u b |
|
|
|
|
|
bw = 5 |
|
|
|
|
|
xCoords = Set.map (\(x, y) -> x) (Unit.members c) |
|
|
|
|
|
yCoords = Set.map (\(x, y) -> y) (Unit.members c) |
|
|
|
|
|
unitLeft = Set.findMin xCoords |
|
|
|
|
|
unitRight = Set.findMax xCoords |
|
|
|
|
|
unitTop = Set.findMin yCoords |
|
|
|
|
|
deltaLeft = unitLeft |
|
|
|
|
|
deltaRight = bw - unitRight - 1 |
|
|
|
|
|
in (deltaLeft == deltaRight || (deltaRight - deltaLeft) == 1) && unitTop == 0) |
|
|
|
|
|
|
|
|
testGame = let board = Board 5 10 (Set.fromList []) |
|
|
testGame = let board = Board 5 10 (Set.fromList []) |
|
|
unit = Unit (Set.fromList [(2, 8)]) (2, 8) |
|
|
|
|
|
|
|
|
unit = Unit (2, 8) (Set.fromList [(2, 8)]) |
|
|
game = Game board [unit] (Set.fromList [hash unit]) |
|
|
game = Game board [unit] (Set.fromList [hash unit]) |
|
|
in game |
|
|
in game |
|
|
|
|
|
|
|
|