templates.chess_test_game2

  1import smartpy as sp
  2from smartpy.templates.chess import main, play, build_fen
  3
  4if "main" in __name__:
  5    player1 = sp.test_account("player1")
  6    player2 = sp.test_account("player2")
  7
  8    @sp.add_test()
  9    def test():
 10        sc = sp.test_scenario("Chess - Vachier Lagrave Maxime vs Bacrot Etienne", main)
 11        c1 = main.Chess(player1.address, player2.address)
 12
 13        sc.h1("Vachier Lagrave,M (2579) vs. Bacrot,E (2705) 1/2-1/2")
 14        sc += c1
 15
 16        # Vachier Lagrave,M (2579) vs. Bacrot,E (2705) 1/2-1/2
 17        c1.play(play(f=sp.record(i=1, j=4), t=sp.record(i=3, j=4)), _sender=player1)
 18        c1.play(play(f=sp.record(i=6, j=4), t=sp.record(i=4, j=4)), _sender=player2)
 19        c1.play(play(f=sp.record(i=0, j=6), t=sp.record(i=2, j=5)), _sender=player1)
 20        c1.play(play(f=sp.record(i=7, j=1), t=sp.record(i=5, j=2)), _sender=player2)
 21        c1.play(play(f=sp.record(i=0, j=5), t=sp.record(i=4, j=1)), _sender=player1)
 22        c1.play(play(f=sp.record(i=6, j=0), t=sp.record(i=5, j=0)), _sender=player2)
 23        c1.play(play(f=sp.record(i=4, j=1), t=sp.record(i=5, j=2)), _sender=player1)
 24        c1.play(play(f=sp.record(i=6, j=3), t=sp.record(i=5, j=2)), _sender=player2)
 25        c1.play(play(f=sp.record(i=0, j=4), t=sp.record(i=0, j=6)), _sender=player1)
 26        sc.verify(
 27            build_fen(c1)
 28            == "r1bqkbnr/1pp2ppp/p1p5/4p3/4P3/5N2/PPPP1PPP/RNBQ1RK1 b kq - 1 5"
 29        )
 30        c1.play(play(f=sp.record(i=6, j=5), t=sp.record(i=5, j=5)), _sender=player2)
 31        c1.play(play(f=sp.record(i=1, j=3), t=sp.record(i=3, j=3)), _sender=player1)
 32        c1.play(play(f=sp.record(i=4, j=4), t=sp.record(i=3, j=3)), _sender=player2)
 33        c1.play(play(f=sp.record(i=2, j=5), t=sp.record(i=3, j=3)), _sender=player1)
 34        c1.play(play(f=sp.record(i=5, j=2), t=sp.record(i=4, j=2)), _sender=player2)
 35        c1.play(play(f=sp.record(i=3, j=3), t=sp.record(i=2, j=1)), _sender=player1)
 36        c1.play(play(f=sp.record(i=7, j=3), t=sp.record(i=0, j=3)), _sender=player2)
 37        c1.play(play(f=sp.record(i=0, j=5), t=sp.record(i=0, j=3)), _sender=player1)
 38        c1.play(play(f=sp.record(i=7, j=2), t=sp.record(i=3, j=6)), _sender=player2)
 39        c1.play(play(f=sp.record(i=1, j=5), t=sp.record(i=2, j=5)), _sender=player1)
 40        c1.play(play(f=sp.record(i=3, j=6), t=sp.record(i=6, j=3)), _sender=player2)
 41        c1.play(play(f=sp.record(i=0, j=1), t=sp.record(i=2, j=2)), _sender=player1)
 42        c1.play(play(f=sp.record(i=7, j=4), t=sp.record(i=7, j=2)), _sender=player2)
 43        c1.play(play(f=sp.record(i=0, j=2), t=sp.record(i=3, j=5)), _sender=player1)
 44        c1.play(play(f=sp.record(i=4, j=2), t=sp.record(i=3, j=2)), _sender=player2)
 45        c1.play(play(f=sp.record(i=2, j=1), t=sp.record(i=4, j=0)), _sender=player1)
 46        c1.play(play(f=sp.record(i=7, j=5), t=sp.record(i=4, j=2)), _sender=player2)
 47        c1.play(play(f=sp.record(i=0, j=6), t=sp.record(i=0, j=5)), _sender=player1)
 48        c1.play(play(f=sp.record(i=6, j=1), t=sp.record(i=4, j=1)), _sender=player2)
 49        c1.play(play(f=sp.record(i=1, j=0), t=sp.record(i=3, j=0)), _sender=player1)
 50        c1.play(play(f=sp.record(i=7, j=6), t=sp.record(i=6, j=4)), _sender=player2)
 51        sc.verify(
 52            build_fen(c1)
 53            == "2kr3r/2pbn1pp/p4p2/Npb5/P1p1PB2/2N2P2/1PP3PP/R2R1K2 w - - 1 16"
 54        )
 55        c1.play(play(f=sp.record(i=3, j=0), t=sp.record(i=4, j=1)), _sender=player1)
 56        c1.play(play(f=sp.record(i=6, j=3), t=sp.record(i=4, j=1)), _sender=player2)
 57        c1.play(play(f=sp.record(i=3, j=5), t=sp.record(i=1, j=3)), _sender=player1)
 58        c1.play(play(f=sp.record(i=7, j=7), t=sp.record(i=7, j=4)), _sender=player2)
 59        c1.play(play(f=sp.record(i=2, j=2), t=sp.record(i=4, j=1)), _sender=player1)
 60        c1.play(play(f=sp.record(i=5, j=0), t=sp.record(i=4, j=1)), _sender=player2)
 61        c1.play(play(f=sp.record(i=1, j=1), t=sp.record(i=2, j=1)), _sender=player1)
 62        c1.play(play(f=sp.record(i=3, j=2), t=sp.record(i=2, j=1)), _sender=player2)
 63        c1.play(play(f=sp.record(i=4, j=0), t=sp.record(i=2, j=1)), _sender=player1)
 64        c1.play(play(f=sp.record(i=4, j=2), t=sp.record(i=5, j=1)), _sender=player2)
 65        c1.play(play(f=sp.record(i=1, j=3), t=sp.record(i=2, j=2)), _sender=player1)
 66        c1.play(play(f=sp.record(i=7, j=3), t=sp.record(i=0, j=3)), _sender=player2)
 67        c1.play(play(f=sp.record(i=0, j=0), t=sp.record(i=0, j=3)), _sender=player1)
 68        c1.play(play(f=sp.record(i=6, j=2), t=sp.record(i=4, j=2)), _sender=player2)
 69        c1.play(play(f=sp.record(i=0, j=3), t=sp.record(i=5, j=3)), _sender=player1)
 70        c1.play(play(f=sp.record(i=5, j=1), t=sp.record(i=6, j=0)), _sender=player2)
 71        c1.play(play(f=sp.record(i=5, j=3), t=sp.record(i=5, j=0)), _sender=player1)
 72        c1.play(play(f=sp.record(i=7, j=2), t=sp.record(i=6, j=1)), _sender=player2)
 73        c1.play(play(f=sp.record(i=5, j=0), t=sp.record(i=5, j=4)), _sender=player1)
 74        c1.play(play(f=sp.record(i=6, j=1), t=sp.record(i=6, j=2)), _sender=player2)
 75        c1.play(play(f=sp.record(i=3, j=4), t=sp.record(i=4, j=4)), _sender=player1)
 76        c1.play(play(f=sp.record(i=6, j=2), t=sp.record(i=6, j=3)), _sender=player2)
 77        c1.play(play(f=sp.record(i=5, j=4), t=sp.record(i=5, j=0)), _sender=player1)
 78        c1.play(play(f=sp.record(i=6, j=4), t=sp.record(i=7, j=2)), _sender=player2)
 79        c1.play(play(f=sp.record(i=4, j=4), t=sp.record(i=5, j=5)), _sender=player1)
 80        c1.play(play(f=sp.record(i=6, j=6), t=sp.record(i=5, j=5)), _sender=player2)
 81        c1.play(play(f=sp.record(i=5, j=0), t=sp.record(i=5, j=5)), _sender=player1)
 82        c1.play(play(f=sp.record(i=7, j=2), t=sp.record(i=5, j=3)), _sender=player2)
 83        c1.play(play(f=sp.record(i=5, j=5), t=sp.record(i=5, j=7)), _sender=player1)
 84        c1.play(play(f=sp.record(i=7, j=4), t=sp.record(i=6, j=4)), _sender=player2)
 85        c1.play(play(f=sp.record(i=5, j=7), t=sp.record(i=4, j=7)), _sender=player1)
 86        c1.play(play(f=sp.record(i=6, j=3), t=sp.record(i=5, j=2)), _sender=player2)
 87        c1.play(play(f=sp.record(i=2, j=2), t=sp.record(i=0, j=4)), _sender=player1)
 88        c1.play(play(f=sp.record(i=5, j=3), t=sp.record(i=3, j=2)), _sender=player2)
 89        c1.play(play(f=sp.record(i=0, j=4), t=sp.record(i=1, j=5)), _sender=player1)
 90        c1.play(play(f=sp.record(i=3, j=2), t=sp.record(i=2, j=4)), _sender=player2)
 91        c1.play(play(f=sp.record(i=1, j=5), t=sp.record(i=2, j=4)), _sender=player1)
 92        c1.play(play(f=sp.record(i=6, j=4), t=sp.record(i=2, j=4)), _sender=player2)
 93        c1.play(play(f=sp.record(i=4, j=7), t=sp.record(i=6, j=7)), _sender=player1)
 94        c1.play(play(f=sp.record(i=6, j=0), t=sp.record(i=5, j=1)), _sender=player2)
 95        c1.play(play(f=sp.record(i=6, j=7), t=sp.record(i=5, j=7)), _sender=player1)
 96        c1.play(play(f=sp.record(i=5, j=2), t=sp.record(i=6, j=2)), _sender=player2)
 97        c1.play(play(f=sp.record(i=5, j=7), t=sp.record(i=6, j=7)), _sender=player1)
 98        c1.play(play(f=sp.record(i=6, j=2), t=sp.record(i=5, j=2)), _sender=player2)
 99        c1.play(play(f=sp.record(i=6, j=7), t=sp.record(i=5, j=7)), _sender=player1)
100        c1.play(play(f=sp.record(i=5, j=2), t=sp.record(i=6, j=2)), _sender=player2)
101        c1.play(play(f=sp.record(i=5, j=7), t=sp.record(i=6, j=7)), _sender=player1)
102        c1.play(play(f=sp.record(i=6, j=2), t=sp.record(i=5, j=2)), _sender=player2)
103        c1.play(play(f=sp.record(i=6, j=7), t=sp.record(i=5, j=7)), _sender=player1)
104
105        sc.verify(build_fen(c1) == "8/8/1bk4R/1pp5/8/1N2rP2/2P3PP/5K2 b - - 10 40")