summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2014-08-24 20:37:19 +0200
committerSébastien Dailly <sebastien@chimrod.com>2014-08-24 20:37:19 +0200
commit1625e093e32b5bb292dfbb479b29bc1b98187df3 (patch)
tree32faee58668d2edb492e653e459c07f4d7a01504
parent6c2cc134abf3f32d1d6ec172c6201f8d990c88ab (diff)
Placement correction
-rw-r--r--qml/python/game.py27
-rw-r--r--qml/python/tests/test_game.py34
-rw-r--r--qml/python/transformations.py8
-rw-r--r--rpm/qtgo.changes.in15
-rw-r--r--rpm/qtgo.spec71
5 files changed, 17 insertions, 138 deletions
diff --git a/qml/python/game.py b/qml/python/game.py
index 7a91ae7..f4cb929 100644
--- a/qml/python/game.py
+++ b/qml/python/game.py
@@ -36,23 +36,16 @@ class Game(object):
x_space = 2
y_space = 2
- if self.min_y > y_space:
- self.min_y -= y_space
-
- if self.min_x > x_space:
- self.min_x -= x_space
-
- if self.max_y < 19 - y_space:
- self.max_y += y_space
-
- if self.max_x < 19 - x_space:
- self.max_x += x_space
+ self.min_y = max(1, self.min_y - y_space)
+ self.min_x = max(1, self.min_x - x_space)
+ self.max_y = min(19, self.max_y + y_space)
+ self.max_x = min(19, self.max_x + x_space)
self.side = {
- "TOP": self.min_y != 0,
- "LEFT": self.min_x != 0,
- "RIGHT": self.max_x != 19,
- "BOTTOM": self.max_y != 19,
+ "TOP": self.min_y == 1,
+ "LEFT": self.min_x == 1,
+ "RIGHT": self.max_x == 19,
+ "BOTTOM": self.max_y == 19,
}
@@ -110,8 +103,6 @@ class Game(object):
""" This takes coordinates in SGF style (aa - qq) and returns the
corresponding integer coordinates (between 1 and 19). """
- print(x)
-
return tuple([ord(c) - 96 for c in x])
def parse_tree(self, fun, elements=None):
@@ -136,7 +127,7 @@ class Game(object):
""" Create a normalized board, translated on lower coord.
"""
- for transformation in [Translation(self), Rotation(self), Translation(self), Symmetry(self)]:
+ for transformation in [Translation(self), Rotation(self), Symmetry(self)]:
if not transformation.is_valid():
continue
diff --git a/qml/python/tests/test_game.py b/qml/python/tests/test_game.py
index de43909..737e55b 100644
--- a/qml/python/tests/test_game.py
+++ b/qml/python/tests/test_game.py
@@ -66,36 +66,10 @@ class TestBoard(unittest.TestCase):
# There is only 2 state : initial board, and 2 possibilities.
self.assertEqual(2, len(currentgame.tree))
- self.assertTrue(currentgame.side['TOP'])
- self.assertTrue(currentgame.side['LEFT'])
- self.assertFalse(currentgame.side['BOTTOM'])
- self.assertFalse(currentgame.side['RIGHT'])
+ self.assertFalse(currentgame.side['TOP'])
+ self.assertFalse(currentgame.side['LEFT'])
+ self.assertTrue(currentgame.side['BOTTOM'])
+ self.assertTrue(currentgame.side['RIGHT'])
currentgame.normalize()
- def test_level2(self):
-
- def fun(pos):
- return (0,0)
- currentgame = create_board("test2.sgf")
-
- print(currentgame.tree)
-
- currentgame.normalize()
-
- self.assertEqual(11, currentgame.min_x)
- self.assertEqual(13, currentgame.min_y)
- self.assertEqual(19, currentgame.max_x)
- self.assertEqual(19, currentgame.max_y)
-
- self.assertEqual((9, 7), currentgame.get_size())
-
- # There is only 2 state : initial board, and 2 possibilities.
- self.assertEqual(2, len(currentgame.tree))
-
- self.assertTrue(currentgame.side['TOP'])
- self.assertTrue(currentgame.side['LEFT'])
- self.assertFalse(currentgame.side['BOTTOM'])
- self.assertFalse(currentgame.side['RIGHT'])
-
- currentgame.normalize()
diff --git a/qml/python/transformations.py b/qml/python/transformations.py
index 380c30c..adf0395 100644
--- a/qml/python/transformations.py
+++ b/qml/python/transformations.py
@@ -72,10 +72,10 @@ class Rotation(object):
""" Apply the transformations on the sides.
"""
return {
- "TOP": self.board.side["RIGHT"],
- "LEFT": self.board.side["TOP"],
- "RIGHT": self.board.side["BOTTOM"],
- "BOTTOM":self.board.side["LEFT"]
+ "BOTTOM": self.board.side["RIGHT"],
+ "RIGHT": self.board.side["TOP"],
+ "LEFT": self.board.side["BOTTOM"],
+ "TOP":self.board.side["LEFT"]
}
class Symmetry(object):
diff --git a/rpm/qtgo.changes.in b/rpm/qtgo.changes.in
deleted file mode 100644
index 9e16d7f..0000000
--- a/rpm/qtgo.changes.in
+++ /dev/null
@@ -1,15 +0,0 @@
-# Rename this file as qtgo.changes to include changelog
-# entries in your RPM file.
-#
-# Add new changelog entries following the format below.
-# Add newest entries to the top of the list.
-# Separate entries from eachother with a blank line.
-
-# * date Author's Name <author's email> version-release
-# - Summary of changes
-
-* Sun Apr 13 2014 Jack Tar <jack.tar@example.com> 0.0.1-1
-- Scrubbed the deck
-- Hoisted the sails
-
-
diff --git a/rpm/qtgo.spec b/rpm/qtgo.spec
deleted file mode 100644
index 38a1466..0000000
--- a/rpm/qtgo.spec
+++ /dev/null
@@ -1,71 +0,0 @@
-#
-# Do NOT Edit the Auto-generated Part!
-# Generated by: spectacle version 0.27
-#
-
-Name: qtgo
-
-# >> macros
-# << macros
-
-%{!?qtc_qmake:%define qtc_qmake %qmake}
-%{!?qtc_qmake5:%define qtc_qmake5 %qmake5}
-%{!?qtc_make:%define qtc_make make}
-%{?qtc_builddir:%define _builddir %qtc_builddir}
-Summary: Tsumego game
-Version: 0.1
-Release: 1
-Group: Qt/Qt
-License: LICENSE
-URL: http://example.org/
-Source0: %{name}-%{version}.tar.bz2
-Source100: qtgo.yaml
-Requires: sailfishsilica-qt5 >= 0.10.9
-BuildRequires: pkgconfig(sailfishapp) >= 1.0.2
-BuildRequires: pkgconfig(Qt5Core)
-BuildRequires: pkgconfig(Qt5Qml)
-BuildRequires: pkgconfig(Qt5Quick)
-BuildRequires: desktop-file-utils
-
-%description
-Short description of my SailfishOS Application
-
-
-%prep
-%setup -q -n %{name}-%{version}
-
-# >> setup
-# << setup
-
-%build
-# >> build pre
-# << build pre
-
-%qtc_qmake5
-
-%qtc_make %{?_smp_mflags}
-
-# >> build post
-# << build post
-
-%install
-rm -rf %{buildroot}
-# >> install pre
-# << install pre
-%qmake5_install
-
-# >> install post
-# << install post
-
-desktop-file-install --delete-original \
- --dir %{buildroot}%{_datadir}/applications \
- %{buildroot}%{_datadir}/applications/*.desktop
-
-%files
-%defattr(-,root,root,-)
-%{_bindir}
-%{_datadir}/%{name}
-%{_datadir}/applications/%{name}.desktop
-%{_datadir}/icons/hicolor/86x86/apps/%{name}.png
-# >> files
-# << files