• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python Move.Move类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中Move.Move的典型用法代码示例。如果您正苦于以下问题:Python Move类的具体用法?Python Move怎么用?Python Move使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Move类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_negamax

    def test_negamax(self):
        board = Board("""
                        1 W
                        ..k..
                        .....
                        .....
                        .....
                        ..Q..
                        ...K.
                        """)

        player = NegamaxPlayer()
        best_value, best_move = player.negamax(board, 1)
        self.assertEqual(Move.from_string("c2-c6"), best_move)


        random.seed(0)
        board = Board("""
                        1 W
                        kp...
                        .p...
                        .....
                        .....
                        .Q...
                        ...K.
                        """)

        player = NegamaxPlayer()
        best_value, best_move = player.negamax(board, 3)
        self.assertEqual(Move.from_string("b2-b4"), best_move)
开发者ID:jschmer,项目名称:MiniCheese,代码行数:30,代码来源:NegamaxPlayerTest.py


示例2: test_scan_no_capture

    def test_scan_no_capture(self):
        b = Board("""
                    1 W
                    .....
                    .....
                    ..Qp.
                    .....
                    .....
                    .....
                    """)
        startpos = (3,4)
        
        # not capturing right
        movelist = []
        b.scan(movelist, startpos, 1, 0, no_capture=True)
        expected = []
        self.assertEqual(expected, movelist)

        # to the top
        movelist = []
        b.scan(movelist, startpos, 0, 1, no_capture=True)
        expected = []
        expected.append(Move.from_string("c4-c5"))
        expected.append(Move.from_string("c4-c6"))
        self.assertEqual(expected, movelist)
开发者ID:jschmer,项目名称:MiniCheese,代码行数:25,代码来源:BoardTest.py


示例3: test_legal_moves_combined

    def test_legal_moves_combined(self):
        b = Board("""
                    1 W
                    ..k..
                    q..p.
                    .....
                    .P...
                    ....r
                    N...K
                    """)

        # get legal moves for all white pieces
        legal_moves = b.legal_moves()

        expected = []
        # knight
        expected.append(Move.from_string("a1-c2"))
        # king
        expected.append(Move.from_string("e1-e2"))
        expected.append(Move.from_string("e1-d2"))
        expected.append(Move.from_string("e1-d1"))
        # pawn
        expected.append(Move.from_string("b3-b4"))

        self.assertEqual(len(expected), len(legal_moves))
        for move in expected:
            self.assertIn(move, legal_moves)
开发者ID:jschmer,项目名称:MiniCheese,代码行数:27,代码来源:BoardTest.py


示例4: test_undo_last_move

    def test_undo_last_move(self):
        b = Board("""
            1 W
            ...k.
            ..P..
            .....
            .....
            .....
            .....
            """)
        b2 = Board("""
            1 W
            ...k.
            ..P..
            .....
            .....
            .....
            .....
            """)

        b.move(Move.from_string("c5-c6"))
        b.undo_last_move()
        self.assertEqual(b, b2)

        b.move(Move.from_string("c5-d6"))
        b.undo_last_move()
        self.assertEqual(b, b2)
开发者ID:jschmer,项目名称:MiniCheese,代码行数:27,代码来源:BoardTest.py


示例5: __init__

class Remove:
	
	trashPath = 'Operate/TrashBox'

	#
	# [String] targetEntries : 作成するディレクトリ名
	#
	def __init__(self, targetEntries):
		self.targetEntries = targetEntries 
		self.move = None

	#
	# 実行
	#
	def execute(self):
		self.move = None
		pairPaths = []
		for targetEntry in self.targetEntries:
			entryName = targetEntry.rsplit(os.sep, 1)[1]
			inTrashPath = os.path.join(Remove.trashPath, entryName)

			pairPaths.append(PairPath(targetEntry, inTrashPath))

		self.move = Move(pairPaths)
		self.move.execute()

	#
	# 実行取り消し
	#
	def unexecute(self):
		self.move.unexecute()
开发者ID:tenshiPure,项目名称:FlexibleFrank,代码行数:31,代码来源:Remove.py


示例6: test_scan_one_step

    def test_scan_one_step(self):
        b = Board("""
                    1 W
                    .....
                    .....
                    .....
                    .Kq..
                    .....
                    .....
                    """)
        startpos = (2,3)
        
        # capturing right
        movelist = []
        b.scan(movelist, startpos, 1, 0, one_step=True)
        expected = []
        expected.append(Move.from_string("b3-c3"))
        self.assertEqual(expected, movelist)

        # to the top
        movelist = []
        b.scan(movelist, startpos, 0, 1, one_step=True)
        expected = []
        expected.append(Move.from_string("b3-b4"))
        self.assertEqual(expected, movelist)
开发者ID:jschmer,项目名称:MiniCheese,代码行数:25,代码来源:BoardTest.py


示例7: explore

def explore(motor, buzzer):
	'''
		Function will initialize and execute a new "move"

		Args:
			motor(motor_obj): used to control robot movement
			buzzer(buzzer_obj): signals start of exploration
	'''

	# Test output
	print "Exploring (moving to a new location) ..."

	# Beep to indicate begining of explore step
	buzzer.play(5)

	# Initialize new move object
	move = Move()

	# Vector of movement used
	move.get_move_vector()

	# Break down movement vector into motion primitives that robot can execute
	move.get_motion_plan()

	# Debug print move fields
	print(str(move))

	# Execute motion from given move primitives
	for (direction, amount) in move.primitives:
		print "Moving " + str(direction) + " " + str(amount)
		motor.move_bot(direction, distance=amount)
开发者ID:HugoCMU,项目名称:SolarTree,代码行数:31,代码来源:navigation.py


示例8: Move

 def Move(self, sReactor, sReactPosition):
     """Performs a move unit operation"""
     pParams = {"ReactorID":sReactor,
                "reactPosition":sReactPosition}
     pMove = Move(self.__pSystemModel, pParams, username = "CLI", database = self.__pDatabase)
     pMove.setDaemon(True)
     pMove.start()
     return pMove
开发者ID:henryeherman,项目名称:elixys,代码行数:8,代码来源:UnitOperationsWrapper.py


示例9: test_equal_operator

    def test_equal_operator(self):
        b = Move.from_string("a1-a2")
        c = Move.from_string("a1-a2")
        self.assertEqual(b, c)

        b = Move.from_string("e1-a2")
        c = Move.from_string("a1-a4")
        self.assertNotEqual(b, c)
开发者ID:jschmer,项目名称:MiniCheese,代码行数:8,代码来源:MoveTest.py


示例10: getValidMoves

    def getValidMoves(self, player):
        validMoves = []
        for rowNumber in range(8):
                for columnNumber in range(8):
                    move = Move(player.shape, rowNumber, columnNumber, self)
                    if move.isMoveValid():
                        validMoves.append(move)

        return validMoves
开发者ID:bonds0097,项目名称:tutoringReversi,代码行数:9,代码来源:Board.py


示例11: test_move_game_result

    def test_move_game_result(self):
        # white win
        b = Board("""
            1 W
            .k...
            P....
            .....
            .....
            .....
            .....
            """)
        result = b.move(Move.from_string("a5-b6"))
        self.assertEqual(result, 'W')

        # black win
        b = Board("""
            1 B
            ..r..
            .....
            .....
            .....
            ..K..
            .....
            """)
        result = b.move(Move.from_string("c6-c2"))
        self.assertEqual(result, 'B')

        # undecided
        b = Board("""
            1 W
            .....
            P....
            .....
            .....
            .....
            .....
            """)
        result = b.move(Move.from_string("a5-a6"))
        self.assertEqual(result, '?')

        # draw
        b = Board("""
            40 B
            .....
            p....
            .....
            .....
            .....
            .....
            """)
        result = b.move(Move.from_string("a5-a4"))
        self.assertEqual(result, '=')
开发者ID:jschmer,项目名称:MiniCheese,代码行数:52,代码来源:BoardTest.py


示例12: test_legal_moves_bishop

    def test_legal_moves_bishop(self):
        b = Board("""
                    1 W
                    .....
                    .....
                    ...p.
                    .p...
                    .B...
                    .....
                    """)
        
        # get legal moves for white bishop 'B'
        legal_moves = b.legal_moves()

        expected = []
        expected.append(Move.from_string("b2-a1"))
        expected.append(Move.from_string("b2-c3"))
        expected.append(Move.from_string("b2-d4"))
        expected.append(Move.from_string("b2-a3"))
        expected.append(Move.from_string("b2-c1"))
        
        expected.append(Move.from_string("b2-b1"))
        expected.append(Move.from_string("b2-a2"))
        expected.append(Move.from_string("b2-c2"))

        self.assertEqual(len(expected), len(legal_moves))
        for move in expected:
            self.assertIn(move, legal_moves)
开发者ID:jschmer,项目名称:MiniCheese,代码行数:28,代码来源:BoardTest.py


示例13: test_legal_moves_rook

    def test_legal_moves_rook(self):
        b = Board("""
                    1 W
                    .....
                    .....
                    ..Rr.
                    .....
                    .....
                    .....
                    """)
        
        # get legal moves for white rook 'R'
        legal_moves = b.legal_moves()

        expected = []
        expected.append(Move.from_string("c4-d4"))
        expected.append(Move.from_string("c4-c3"))
        expected.append(Move.from_string("c4-c2"))
        expected.append(Move.from_string("c4-c1"))
        expected.append(Move.from_string("c4-b4"))
        expected.append(Move.from_string("c4-a4"))
        expected.append(Move.from_string("c4-c5"))
        expected.append(Move.from_string("c4-c6"))

        self.assertEqual(len(expected), len(legal_moves))
        for move in expected:
            self.assertIn(move, legal_moves)
开发者ID:jschmer,项目名称:MiniCheese,代码行数:27,代码来源:BoardTest.py


示例14: test_try_move_and_score

    def test_try_move_and_score(self):
        b = Board("""
            1 W
            ..k..
            q..p.
            .....
            .P...
            ....r
            N...K
            """)
        self.assertEqual(b.score_after(Move.from_string("b3-b4")), 1150) # score for black!

        # moving pawn, no change in score, Black has advantage
        b.move(Move.from_string("b3-b4"))
        self.assertEqual(b.score_after(Move.from_string("e2-e1")), -100000) # score for white!
开发者ID:jschmer,项目名称:MiniCheese,代码行数:15,代码来源:BoardTest.py


示例15: test_scan_only_capture

    def test_scan_only_capture(self):
        b = Board("""
                    1 W
                    .....
                    ...p.
                    ..P..
                    ..K..
                    .....
                    .....
                    """)
        startpos = (3,4)
        
        # to the top
        movelist = []
        b.scan(movelist, startpos, 0, 1, only_capture=True)
        expected = []
        self.assertEqual(expected, movelist)

        # capturing enemy
        movelist = []
        b.scan(movelist, startpos, 1, 1, only_capture=True)
        expected = []
        expected.append(Move.from_string("c4-d5"))
        self.assertEqual(expected, movelist)

        # not capturing own
        movelist = []
        b.scan(movelist, startpos, 0, -1, only_capture=True)
        expected = []
        self.assertEqual(expected, movelist)
开发者ID:jschmer,项目名称:MiniCheese,代码行数:30,代码来源:BoardTest.py


示例16: test_construct

    def test_construct(self): 
        b = Move((1, 1), (1, 2))
        self.assertEqual((1, 1), b.start)
        self.assertEqual((1, 2), b.end)

        b = Move.from_string("a1-a2")
        self.assertEqual((1, 1), b.start)
        self.assertEqual((1, 2), b.end)
开发者ID:jschmer,项目名称:MiniCheese,代码行数:8,代码来源:MoveTest.py


示例17: test_stab

    def test_stab(self):
        for i in range(0, 16):
            a_type = Type(i)
            dif_type = Type(i + 1)

            atk = Move(self.valid_name, a_type, \
                    self.valid_accuracy, self.valid_power, self.valid_pp)

            # Test results
            self.assertEqual(atk.stab(a_type, a_type), 1.5)
            self.assertEqual(atk.stab(a_type, dif_type), 1.5)
            self.assertEqual(atk.stab(dif_type, a_type), 1.5)
            self.assertEqual(atk.stab(dif_type, dif_type), 1)

            # Test exceptions
            self.assertRaises(TypeError, atk.stab, "fire")
            self.assertRaises(TypeError, atk.stab, 0)
开发者ID:LabProg2,项目名称:EP,代码行数:17,代码来源:test_Move.py


示例18: test_scan_until_enemy

 def test_scan_until_enemy(self):
     b = Board("""
                 1 W
                 .....
                 .....
                 .....
                 ..q..
                 .....
                 Q....
                 """)
     startpos = (1,1)
     
     movelist = []
     b.scan(movelist, startpos, 1, 1)
     expected = []
     expected.append(Move.from_string("a1-b2"))
     expected.append(Move.from_string("a1-c3"))
     self.assertEqual(expected, movelist)
开发者ID:jschmer,项目名称:MiniCheese,代码行数:18,代码来源:BoardTest.py


示例19: generate_move

 def generate_move(self, game):
     print("getting move from skirmish:")
     move = sys.stdin.readline()
     try:
         _, move = move.strip().split(" ")
     except:
         f = open("crap", "w")
         f.write(move)
         f.close()
     return Move.from_string(move)
开发者ID:jschmer,项目名称:MiniCheese,代码行数:10,代码来源:Player.py


示例20: test_move_promotion

    def test_move_promotion(self):
        b1 = Board("""
            1 W
            .....
            P....
            .....
            .....
            .....
            ...kK
            """)

        b1.move(Move.from_string("a5-a6"))
        b2 = Board("""
            1 B
            Q....
            .....
            .....
            .....
            .....
            ...kK
            """)
        self.assertEqual(b1, b2)

        b3 = Board("""
            1 B
            k....
            .....
            .....
            .....
            ..p..
            ...K.
            """)
        b3.move(Move.from_string("c2-d1"))
        b4 = Board("""
            2 W
            k....
            .....
            .....
            .....
            .....
            ...q.
            """)
        self.assertEqual(b3, b4)
开发者ID:jschmer,项目名称:MiniCheese,代码行数:43,代码来源:BoardTest.py



注:本文中的Move.Move类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python MultiLanguage.MultiLanguage类代码示例发布时间:2022-05-24
下一篇:
Python MountPoints.MountPoints类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap