void test2(){
	printf("test %d\n\n", Test++);
	vector<string> s;
	s.push_back("ooooo");
	s.push_back("xxxx.");
	FallingSand fs;
	vector<string> ans = fs.simulate(s);
	for (int i = 0; i < ans.size(); ++i) {
		cout << ans[i] << endl;;
	}
}
Exemple #2
0
int main()
{
         // Create the main window
     sf::RenderWindow window(sf::VideoMode(500, 500), "SFML window");

     FallingSand sand;

    sf::Clock fpsClock;

    sf::Clock sandClock;

     // Start the game loop
     while (window.isOpen())
     {
         // Process events
         sf::Event event;
         while (window.pollEvent(event))
         {
             // Close window : exit
             if (event.type == sf::Event::Closed)
                 window.close();
         }

        if (sandClock.getElapsedTime().asSeconds() >= 1.f/90.f)
        {
            sand.Update();
            sandClock.restart();
        }

        if (fpsClock.getElapsedTime().asSeconds() >= 1.f/30.f)
        {
            window.clear();
            sand.Draw(&window);
            fpsClock.restart();
        }

         // Update the window
         window.display();
     }

     return EXIT_SUCCESS;
}
Exemple #3
0
int main( int argc, char* argv[] ) {
    {
        string boardARRAY[] = {"ooooo",
            "..x..",
            "....x",
            ".....",
            "....o"};
        vector <string> board( boardARRAY, boardARRAY+ARRSIZE(boardARRAY) );
        string retrunValueARRAY[] = {"..o..", "..x.o", "....x", ".....", "oo.oo" };
        vector <string> retrunValue( retrunValueARRAY, retrunValueARRAY+ARRSIZE(retrunValueARRAY) );
        FallingSand theObject;
        eq(0, theObject.simulate(board),retrunValue);
    }
    {
        string boardARRAY[] = {"..o..", 
            "..x.o", 
            "....x", 
            ".....", 
            "oo.oo" };
        vector <string> board( boardARRAY, boardARRAY+ARRSIZE(boardARRAY) );
        string retrunValueARRAY[] = {"..o..", "..x.o", "....x", ".....", "oo.oo" };
        vector <string> retrunValue( retrunValueARRAY, retrunValueARRAY+ARRSIZE(retrunValueARRAY) );
        FallingSand theObject;
        eq(1, theObject.simulate(board),retrunValue);
    }
    {
        string boardARRAY[] = {"ooooxooo.ooxo.oxoxoooox.....x.oo"};
        vector <string> board( boardARRAY, boardARRAY+ARRSIZE(boardARRAY) );
        string retrunValueARRAY[] = {"ooooxooo.ooxo.oxoxoooox.....x.oo" };
        vector <string> retrunValue( retrunValueARRAY, retrunValueARRAY+ARRSIZE(retrunValueARRAY) );
        FallingSand theObject;
        eq(2, theObject.simulate(board),retrunValue);
    }
    {
        string boardARRAY[] = {"o",
            ".",
            "o",
            ".",
            "o",
            ".",
            "."};
        vector <string> board( boardARRAY, boardARRAY+ARRSIZE(boardARRAY) );
        string retrunValueARRAY[] = {".", ".", ".", ".", "o", "o", "o" };
        vector <string> retrunValue( retrunValueARRAY, retrunValueARRAY+ARRSIZE(retrunValueARRAY) );
        FallingSand theObject;
        eq(3, theObject.simulate(board),retrunValue);
    }
    {
        string boardARRAY[] = {"oxxxxooo",
            "xooooxxx",
            "..xx.ooo",
            "oooox.o.",
            "..x....."};
        vector <string> board( boardARRAY, boardARRAY+ARRSIZE(boardARRAY) );
        string retrunValueARRAY[] = {"oxxxxooo", "x.oo.xxx", "..xxo...", ".oo.x.o.", "ooxo.ooo" };
        vector <string> retrunValue( retrunValueARRAY, retrunValueARRAY+ARRSIZE(retrunValueARRAY) );
        FallingSand theObject;
        eq(4, theObject.simulate(board),retrunValue);
    }
    {
        string boardARRAY[] = {"..o..o..o..o..o..o..o..o..o..o..o",
            "o..o..o..o..o..o..o..o..o..o..o..",
            ".o..o..o..o..o..o..o..o..o..o..o.",
            "...xxx...xxx...xxxxxxxxx...xxx...",
            "...xxx...xxx...xxxxxxxxx...xxx...",
            "...xxx...xxx......xxx......xxx...",
            "...xxxxxxxxx......xxx......xxx...",
            "...xxxxxxxxx......xxx......xxx...",
            "...xxxxxxxxx......xxx......xxx...",
            "...xxx...xxx......xxx............",
            "...xxx...xxx...xxxxxxxxx...xxx...",
            "...xxx...xxx...xxxxxxxxx...xxx...",
            "..o..o..o..o..o..o..o..o..o..o..o",
            "o..o..o..o..o..o..o..o..o..o..o..",
            ".o..o..o..o..o..o..o..o..o..o..o."};
        vector <string> board( boardARRAY, boardARRAY+ARRSIZE(boardARRAY) );
        string retrunValueARRAY[] = {".................................", ".................................", "...ooo...ooo...ooooooooo...ooo...", "...xxx...xxx...xxxxxxxxx...xxx...", "...xxx...xxx...xxxxxxxxx...xxx...", "...xxxoooxxx......xxx......xxx...", "...xxxxxxxxx......xxx......xxx...", "...xxxxxxxxx......xxx......xxx...", "...xxxxxxxxx......xxx......xxx...", "...xxx...xxx......xxx............", "...xxx...xxx...xxxxxxxxx...xxx...", "...xxx...xxx...xxxxxxxxx...xxx...", ".................................", "ooo.........ooo.........ooo...ooo", "ooooooooooooooooooooooooooooooooo" };
        vector <string> retrunValue( retrunValueARRAY, retrunValueARRAY+ARRSIZE(retrunValueARRAY) );
        FallingSand theObject;
        eq(5, theObject.simulate(board),retrunValue);
    }
	return 0;
}