# File test/libttc_test.rb, line 710
  def test_undo_move!
    game = Game.new(3)
  
    pieceA1 = game.pieces['a1']
    pieceA2 = game.pieces['a2']
    pieceC1 = game.pieces['c1']
    pieceC2 = game.pieces['c2']
    pieceE1 = game.pieces['e1']
    pieceE2 = game.pieces['e2']
    
    assert_equal [], game.history
    assert_equal game.pieces['a1'], pieceA1
    assert_equal game.pieces['a2'], pieceA2
    assert_equal game.pieces['c1'], pieceC1
    assert_equal game.pieces['c2'], pieceC2
    assert_equal game.pieces['e1'], pieceE1
    assert_equal game.pieces['e2'], pieceE2
    assert_equal game.pieces['a1'].position, game.board.positions['a']
    assert_equal game.pieces['a1'].captured, false
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['a']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['c1'].position, game.board.positions['c']
    assert_equal game.pieces['c1'].captured, false
    assert_equal game.pieces['c1'].contains, []
    assert_equal game.pieces['c2'].position, game.board.positions['c']
    assert_equal game.pieces['c2'].captured, false
    assert_equal game.pieces['c2'].contains, []
    assert_equal game.pieces['e1'].position, game.board.positions['e']
    assert_equal game.pieces['e1'].captured, false
    assert_equal game.pieces['e1'].contains, []
    assert_equal game.pieces['e2'].position, game.board.positions['e']
    assert_equal game.pieces['e2'].captured, false
    assert_equal game.pieces['e2'].contains, []
    assert_equal game.current_player, 'a'
    
    game.undo_move!
    assert_equal [], game.history
    assert_equal game.pieces['a1'], pieceA1
    assert_equal game.pieces['a2'], pieceA2
    assert_equal game.pieces['c1'], pieceC1
    assert_equal game.pieces['c2'], pieceC2
    assert_equal game.pieces['e1'], pieceE1
    assert_equal game.pieces['e2'], pieceE2
    assert_equal game.pieces['a1'].position, game.board.positions['a']
    assert_equal game.pieces['a1'].captured, false
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['a']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['c1'].position, game.board.positions['c']
    assert_equal game.pieces['c1'].captured, false
    assert_equal game.pieces['c1'].contains, []
    assert_equal game.pieces['c2'].position, game.board.positions['c']
    assert_equal game.pieces['c2'].captured, false
    assert_equal game.pieces['c2'].contains, []
    assert_equal game.pieces['e1'].position, game.board.positions['e']
    assert_equal game.pieces['e1'].captured, false
    assert_equal game.pieces['e1'].contains, []
    assert_equal game.pieces['e2'].position, game.board.positions['e']
    assert_equal game.pieces['e2'].captured, false
    assert_equal game.pieces['e2'].contains, []
    assert_equal game.current_player, 'a'

    game.apply_moves! ['A1 A3'].collect { |m| m.to_move(game) }
    assert_equal game.history.length, 1
    assert_equal game.pieces['a1'], pieceA1
    assert_equal game.pieces['a2'], pieceA2
    assert_equal game.pieces['c1'], pieceC1
    assert_equal game.pieces['c2'], pieceC2
    assert_equal game.pieces['e1'], pieceE1
    assert_equal game.pieces['e2'], pieceE2
    assert_equal game.pieces['a1'].position, game.board.positions['a3']
    assert_equal game.pieces['a1'].captured, false
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['a']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['c1'].position, game.board.positions['c']
    assert_equal game.pieces['c1'].captured, false
    assert_equal game.pieces['c1'].contains, []
    assert_equal game.pieces['c2'].position, game.board.positions['c']
    assert_equal game.pieces['c2'].captured, false
    assert_equal game.pieces['c2'].contains, []
    assert_equal game.pieces['e1'].position, game.board.positions['e']
    assert_equal game.pieces['e1'].captured, false
    assert_equal game.pieces['e1'].contains, []
    assert_equal game.pieces['e2'].position, game.board.positions['e']
    assert_equal game.pieces['e2'].captured, false
    assert_equal game.pieces['e2'].contains, []
    assert_equal game.current_player, 'c'

    game.undo_move!
    assert_equal [], game.history
    assert_equal game.pieces['a1'], pieceA1
    assert_equal game.pieces['a2'], pieceA2
    assert_equal game.pieces['c1'], pieceC1
    assert_equal game.pieces['c2'], pieceC2
    assert_equal game.pieces['e1'], pieceE1
    assert_equal game.pieces['e2'], pieceE2
    assert_equal game.pieces['a1'].position, game.board.positions['a']
    assert_equal game.pieces['a1'].captured, false
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['a']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['c1'].position, game.board.positions['c']
    assert_equal game.pieces['c1'].captured, false
    assert_equal game.pieces['c1'].contains, []
    assert_equal game.pieces['c2'].position, game.board.positions['c']
    assert_equal game.pieces['c2'].captured, false
    assert_equal game.pieces['c2'].contains, []
    assert_equal game.pieces['e1'].position, game.board.positions['e']
    assert_equal game.pieces['e1'].captured, false
    assert_equal game.pieces['e1'].contains, []
    assert_equal game.pieces['e2'].position, game.board.positions['e']
    assert_equal game.pieces['e2'].captured, false
    assert_equal game.pieces['e2'].contains, []
    assert_equal game.current_player, 'a'

    move_set1 = ['A1 AC5', 'A2 AC5', 'A1 AC6', 
      'C1 CC5', 'C2 CC5', 'C1 AC6']  # A1 now captured by C1
    move_set1a = ['C1 AC6']
    move_set2 = ['E1 EC5', 'E2 EC5', 'E1 AC6'] # C1+A1 now caputred by E1
    move_set2a = ['E1 AC6']

    game.apply_moves! move_set1.collect {|m| m.to_move(game)}
    assert_equal game.history.length, 6
    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
    assert_equal game.pieces['a1'].captured, true
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
    assert_equal game.pieces['c1'].captured, false
    assert       game.pieces['c1'].contains.include?(pieceA1) 
    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
    assert_equal game.pieces['c2'].captured, false
    assert_equal game.pieces['c2'].contains, []
    assert_equal game.pieces['e1'].position, game.board.positions['e']
    assert_equal game.pieces['e1'].captured, false
    assert_equal game.pieces['e1'].contains, []
    assert_equal game.pieces['e2'].position, game.board.positions['e']
    assert_equal game.pieces['e2'].captured, false
    assert_equal game.pieces['e2'].contains, []
    assert_equal game.current_player, 'e'

    game.undo_move!
    assert_equal game.history.length, 5
    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
    assert_equal game.pieces['a1'].captured, false
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['c1'].position, game.board.positions['cc5']
    assert_equal game.pieces['c1'].captured, false
    assert_equal game.pieces['c1'].contains, []
    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
    assert_equal game.pieces['c2'].captured, false
    assert_equal game.pieces['c2'].contains, []
    assert_equal game.pieces['e1'].position, game.board.positions['e']
    assert_equal game.pieces['e1'].captured, false
    assert_equal game.pieces['e1'].contains, []
    assert_equal game.pieces['e2'].position, game.board.positions['e']
    assert_equal game.pieces['e2'].captured, false
    assert_equal game.pieces['e2'].contains, []
    assert_equal game.current_player, 'c'

    game.apply_moves! move_set1a.collect {|m| m.to_move(game)}
    assert_equal game.history.length, 6
    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
    assert_equal game.pieces['a1'].captured, true
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
    assert_equal game.pieces['c1'].captured, false
    assert       game.pieces['c1'].contains.include?(pieceA1) 
    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
    assert_equal game.pieces['c2'].captured, false
    assert_equal game.pieces['c2'].contains, []
    assert_equal game.pieces['e1'].position, game.board.positions['e']
    assert_equal game.pieces['e1'].captured, false
    assert_equal game.pieces['e1'].contains, []
    assert_equal game.pieces['e2'].position, game.board.positions['e']
    assert_equal game.pieces['e2'].captured, false
    assert_equal game.pieces['e2'].contains, []
    assert_equal game.current_player, 'e'
        
    game.apply_moves! move_set2.collect {|m| m.to_move(game)}
    assert_equal game.history.length, 9
    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
    assert_equal game.pieces['a1'].captured, true
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
    assert_equal game.pieces['c1'].captured, true
    assert_equal game.pieces['c1'].contains, []
    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
    assert_equal game.pieces['c2'].captured, false
    assert_equal game.pieces['c2'].contains, []
    assert_equal game.pieces['e1'].position, game.board.positions['ac6']
    assert_equal game.pieces['e1'].captured, false
    assert       game.pieces['e1'].contains.include?(pieceA1) 
    assert       game.pieces['e1'].contains.include?(pieceC1) 
    assert_equal game.pieces['e2'].position, game.board.positions['ec5']
    assert_equal game.pieces['e2'].captured, false
    assert_equal game.pieces['e2'].contains, []
    assert_equal game.current_player, 'a'

    game.undo_move!
    assert_equal game.history.length, 8
    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
    assert_equal game.pieces['a1'].captured, true
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['c1'].captured, false
    assert       game.pieces['c1'].contains.include?(pieceA1) 

    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
    assert_equal game.pieces['c2'].captured, false
    assert_equal game.pieces['c2'].contains, []
    assert_equal game.pieces['e1'].position, game.board.positions['ec5']
    assert_equal game.pieces['e1'].captured, false
    assert_equal game.pieces['e1'].contains, []
    assert_equal game.pieces['e2'].position, game.board.positions['ec5']
    assert_equal game.pieces['e2'].captured, false
    assert_equal game.pieces['e2'].contains, []
    assert_equal game.current_player, 'e'

        assert_equal game.pieces['c1'].position, game.pieces['a1'].position
    assert_equal game.pieces['c1'].position, game.board.positions['ac6']

    
    game.apply_moves! move_set2a.collect {|m| m.to_move(game)}
    assert_equal game.history.length, 9
    assert_equal game.pieces['a1'].position, game.board.positions['ac6']
    assert_equal game.pieces['a1'].captured, true
    assert_equal game.pieces['a1'].contains, []
    assert_equal game.pieces['a2'].position, game.board.positions['ac5']
    assert_equal game.pieces['a2'].captured, false
    assert_equal game.pieces['a2'].contains, []
    assert_equal game.pieces['c1'].position, game.board.positions['ac6']
    assert_equal game.pieces['c1'].captured, true
    assert_equal game.pieces['c1'].contains, []
    assert_equal game.pieces['c2'].position, game.board.positions['cc5']
    assert_equal game.pieces['c2'].captured, false
    assert_equal game.pieces['c2'].contains, []
    assert_equal game.pieces['e1'].position, game.board.positions['ac6']
    assert_equal game.pieces['e1'].captured, false
    assert       game.pieces['e1'].contains.include?(pieceA1) 
    assert       game.pieces['e1'].contains.include?(pieceC1) 
    assert_equal game.pieces['e2'].position, game.board.positions['ec5']
    assert_equal game.pieces['e2'].captured, false
    assert_equal game.pieces['e2'].contains, []
    assert_equal game.current_player, 'a'
        
  end