Rõ ràng, mà chỉ cần gọi đóng (), kích hoạt việc tìm kiếm đầy đủ, chúng tôi chỉ kiểm tra. Tôi không thực hiện cho thấy Bob nào được nêu ra, mặc dù. Ông cung cấp một hệ thống chứng minh với mã của mình. Bằng chứng thông qua kiểm tra đơn vị | Answer 24. Solving Tactics 255 solving_tactics require tactics puts Tactics WIN First Second player wins. Obviously that just calls play triggering the exhaustive search we just examined. I m not done showing off Bob yet though. He provided another system of proof with his code. Proof through Unit Testing Have a look at this beautiful set of unit tests solvin g_ta ctics ta ctics_test. rb require test unit require class TestTactics Test Unit TestCase Test the play engine by trying various board positions that we know are winning or losing positions. Each of these is justified no point in using ones that are just hunches on our part- cause then what would we be verifying . def te st_play Each position description is the position you re faced with just before playing. So 1 square loses means that if it s your turn to play and there s only one square available you lose. 1 square loses obviously assert_equal Tactics LOSS 0b0111_1111_1111_1111 .play assert_equal Tactics LOSS 0b1011_1111_1111_1111 .play assert_equal Tactics LOSS 0b1101_1111_1111_1111 .play assert_equal Tactics LOSS 0b1110_1111_1111_1111 .play assert_equal Tactics LOSS 0b1111_0111_1111_1111 .play assert_equal Tactics LOSS 0b1111_1011_1111_1111 .play assert_equal Tactics LOSS 0b1111_1101_1111_1111 .play assert_equal Tactics LOSS 0b1111_1110_1111_1111 .play assert_equal Tactics LOSS 0b1111_1111_0111_1111 .play assert_equal Tactics LOSS 0b1111_1111_1011_1111 .play assert_equal Tactics LOSS 0b1111_1111_1101_1111 .play assert_equal Tactics LOSS 0b1111_1111_1110_1111 .play assert_equal Tactics LOSS 0b1111_1111_1111_0111 .play assert_equal Tactics LOSS 0b1111_1111_1111_1011 .play assert_equal Tactics LOSS 0b1111_1111_1111_1101 .play assert_equal Tactics LOSS 0b1111_1111_1111_1110 .play