#include <cstdlib>
#include <ctime>
#include <memory>
#include <vector>
#include <iostream>
struct NPC
{
virtual void AI( ) = 0 ;
} ;
struct Pig : public NPC
{
void AI( ) { std:: cout << "Not by the hair of my chinny chin chin!\n " ; }
} ;
struct Wolf : public NPC
{
void AI( ) { std:: cout << "Little pig, little pig! Let me in!\n " ; }
} ;
const unsigned numInitialEnemies = 10 ;
int main( )
{
std:: srand ( std:: time ( 0 ) ) ;
std:: vector < std:: unique_ptr < NPC>> enemies ;
for ( unsigned i= 0 ; i< numInitialEnemies; ++ i )
{
if ( rand ( ) % 2 )
enemies.emplace_back ( new Pig) ;
else
enemies.emplace_back ( new Wolf) ;
}
for ( unsigned i= 0 ; i< enemies.size ( ) ; ++ i )
enemies[ i] - > AI( ) ;
}
I2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDxjdGltZT4KI2luY2x1ZGUgPG1lbW9yeT4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IE5QQyAKewoKICAgIHZpcnR1YWwgdm9pZCBBSSgpID0wIDsKfTsKCnN0cnVjdCBQaWcgOiBwdWJsaWMgTlBDCnsKICAgIHZvaWQgQUkoKSB7IHN0ZDo6Y291dCA8PCAiTm90IGJ5IHRoZSBoYWlyIG9mIG15IGNoaW5ueSBjaGluIGNoaW4hXG4iIDsgfQp9OwoKc3RydWN0IFdvbGYgOiBwdWJsaWMgTlBDCnsKICAgIHZvaWQgQUkoKSB7IHN0ZDo6Y291dCA8PCAiTGl0dGxlIHBpZywgbGl0dGxlIHBpZyEgIExldCBtZSBpbiFcbiIgOyB9Cn07CgoKY29uc3QgdW5zaWduZWQgbnVtSW5pdGlhbEVuZW1pZXMgPSAxMCA7CgppbnQgbWFpbigpCnsKICAgIHN0ZDo6c3JhbmQoc3RkOjp0aW1lKDApKSA7CgogICAgc3RkOjp2ZWN0b3I8c3RkOjp1bmlxdWVfcHRyPE5QQz4+IGVuZW1pZXMgOwo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