Files @ 0cb3fbe06b5d
Branch filter:

Location: OneEye/src/tests/testGo.py

Laman
Go, Engine: some tests and numerous bugfixes
from unittest import TestCase

from go.core import isLegalPosition, Go


class TestLegal(TestCase):
	def testLegal(self):
		board=[
			[0,0,0,0,0],
			[1,1,1,1,1],
			[-1,-1,0,1,0],
			[0,0,0,-1,-1],
			[0,-1,0,-1,0]
		]
		self.assertTrue(isLegalPosition(board))

	def testIllegal(self):
		board=[
			[0,1,0,0,0],
			[1,-1,1,0,0],
			[0,1,0,0,0],
			[0,0,0,0,0],
			[0,0,0,0,0]
		]
		self.assertFalse(isLegalPosition(board))


class TestMove(TestCase):
	def testCapture(self):
		g=Go(3)
		g.load([
			[0,1,0],
			[1,-1,0],
			[0,1,0]
		])
		g.toMove=1
		g.doMove(1,1,2)
		self.assertEqual(g.board,[
			[0,1,0],
			[1,0,1],
			[0,1,0]
		])

		g._helper.clear()
		for row in g._helper._board:
			for x in row:
				self.assertEqual(x,0)