Commit e8a059af authored by lengfeld8's avatar lengfeld8
Browse files

Upload New File

parent aa20d554
import unittest
from main import Board
import numpy as np
class MyTestCase(unittest.TestCase):
def test_generate_moves(self):
board_7 = np.zeros(7*7)
board_9 = np.zeros(9*9)
board_11 = np.zeros(11*11)
main_7 = Board(7, board_7)
main_9 = Board(9, board_9)
main_11 = Board(11, board_11)
# check move generator for a 7x7 board
string1_7x7 = "wb-bw-w/--wb-wb/wb--wb-/-wb-b-w/bw-wbwb/bwb--b-/w----bw" # 18 possible moves
string2_7x7 = "wb-bw-w/-----wb/wb--wb-/----b--/---wb--/b------/w----bw" # 78 possible moves
main_7.string_parse(string1_7x7)
moves = main_7.generate_moves()
self.assertEqual(len(moves), 18, "move generator for string 1 for board 7x7 is wrong")
main_7.string_parse(string2_7x7)
moves = main_7.generate_moves()
self.assertEqual(len(moves), 78, "move generator for string 2 for board 7x7 is wrong")
# check move generator for a 9x9 board
string1_9x9 = "w--w--w-w/b--b--b-b/-----w---/-----b---/-wb-w--wb/----b----/" \
"---------/w-wb-w--w/b----b--b" # 152 possible moves
string2_9x9 = "bw-wbwbw-/-b-b-bwbb/-w---w-ww/-bwwbb-bw/bb---bw--/wwbw--bbw/" \
"bb-b--ww-/wwwwbw-b-/--b--bw--" # 42 possible moves
main_9.string_parse(string1_9x9)
moves = main_9.generate_moves()
self.assertEqual(len(moves), 152, "move generator for string 1 for board 9x9 is wrong")
main_9.string_parse(string2_9x9)
moves = main_9.generate_moves()
self.assertEqual(len(moves), 42, "move generator for string 2 for board 9x9 is wrong")
# check move generator for a 11x11 board
string1_11x11 = "wb-------bw/-----wb----/--------w--/-wb-w-w-b-w/----b-b---b/--w------w-/" \
"--b------b-/-bw--wb-w--/--------b--/-----w-----/wb---b---bw" # 248 possible moves
string2_11x11 = "bw--bw-bwb-/-b-bw-bwwbw/-w-w--w---b/wbwb-bw--bw/b-bbw-bbww-/--w-w-w--b-/" \
"wb--b-b-wbw/b-wbw-wbw-b/w-b-b---b-w/-bwbw-wbw-b/-w-wb-bwbw-" # 62 possible moves
main_11.string_parse(string1_11x11)
moves = main_11.generate_moves()
self.assertEqual(len(moves), 248, "move generator for string 1 for board 11x11 is wrong")
main_11.string_parse(string2_11x11)
moves = main_11.generate_moves()
self.assertEqual(len(moves), 62, "move generator for string 2 for board 11x11 is wrong")
if __name__ == '__main__':
unittest.main()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment