diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..eb2786e Binary files /dev/null and b/.DS_Store differ diff --git a/Luca Margasoiu's Contribution/.DS_Store b/Luca Margasoiu's Contribution/.DS_Store new file mode 100644 index 0000000..5b7b7cd Binary files /dev/null and b/Luca Margasoiu's Contribution/.DS_Store differ diff --git a/Luca Margasoiu's Contribution/A*algorithm/.DS_Store b/Luca Margasoiu's Contribution/A*algorithm/.DS_Store new file mode 100644 index 0000000..cd07ed2 Binary files /dev/null and b/Luca Margasoiu's Contribution/A*algorithm/.DS_Store differ diff --git a/Luca Margasoiu's Contribution/A*algorithm/A*algorithm.xcodeproj/project.pbxproj b/Luca Margasoiu's Contribution/A*algorithm/A*algorithm.xcodeproj/project.pbxproj new file mode 100644 index 0000000..e472c00 --- /dev/null +++ b/Luca Margasoiu's Contribution/A*algorithm/A*algorithm.xcodeproj/project.pbxproj @@ -0,0 +1,253 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + CE2989F7240AED050051DAED /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE2989F6240AED050051DAED /* main.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + CE2989F1240AED040051DAED /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + CE2989F3240AED050051DAED /* A*algorithm */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "A*algorithm"; sourceTree = BUILT_PRODUCTS_DIR; }; + CE2989F6240AED050051DAED /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + CE2989F0240AED040051DAED /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + CE2989EA240AED040051DAED = { + isa = PBXGroup; + children = ( + CE2989F5240AED050051DAED /* A*algorithm */, + CE2989F4240AED050051DAED /* Products */, + ); + sourceTree = ""; + }; + CE2989F4240AED050051DAED /* Products */ = { + isa = PBXGroup; + children = ( + CE2989F3240AED050051DAED /* A*algorithm */, + ); + name = Products; + sourceTree = ""; + }; + CE2989F5240AED050051DAED /* A*algorithm */ = { + isa = PBXGroup; + children = ( + CE2989F6240AED050051DAED /* main.cpp */, + ); + path = "A*algorithm"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + CE2989F2240AED040051DAED /* A*algorithm */ = { + isa = PBXNativeTarget; + buildConfigurationList = CE2989FA240AED050051DAED /* Build configuration list for PBXNativeTarget "A*algorithm" */; + buildPhases = ( + CE2989EF240AED040051DAED /* Sources */, + CE2989F0240AED040051DAED /* Frameworks */, + CE2989F1240AED040051DAED /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "A*algorithm"; + productName = "A*algorithm"; + productReference = CE2989F3240AED050051DAED /* A*algorithm */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + CE2989EB240AED040051DAED /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0820; + ORGANIZATIONNAME = user; + TargetAttributes = { + CE2989F2240AED040051DAED = { + CreatedOnToolsVersion = 8.2; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = CE2989EE240AED040051DAED /* Build configuration list for PBXProject "A*algorithm" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = CE2989EA240AED040051DAED; + productRefGroup = CE2989F4240AED050051DAED /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + CE2989F2240AED040051DAED /* A*algorithm */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + CE2989EF240AED040051DAED /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CE2989F7240AED050051DAED /* main.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + CE2989F8240AED050051DAED /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + CE2989F9240AED050051DAED /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + }; + name = Release; + }; + CE2989FB240AED050051DAED /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + CE2989FC240AED050051DAED /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + CE2989EE240AED040051DAED /* Build configuration list for PBXProject "A*algorithm" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CE2989F8240AED050051DAED /* Debug */, + CE2989F9240AED050051DAED /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + CE2989FA240AED050051DAED /* Build configuration list for PBXNativeTarget "A*algorithm" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CE2989FB240AED050051DAED /* Debug */, + CE2989FC240AED050051DAED /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = CE2989EB240AED040051DAED /* Project object */; +} diff --git a/Luca Margasoiu's Contribution/A*algorithm/A*algorithm.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Luca Margasoiu's Contribution/A*algorithm/A*algorithm.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..967a62a --- /dev/null +++ b/Luca Margasoiu's Contribution/A*algorithm/A*algorithm.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Luca Margasoiu's Contribution/A*algorithm/A*algorithm.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate b/Luca Margasoiu's Contribution/A*algorithm/A*algorithm.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..8b99d4f Binary files /dev/null and b/Luca Margasoiu's Contribution/A*algorithm/A*algorithm.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Luca Margasoiu's Contribution/A*algorithm/A*algorithm.xcodeproj/xcuserdata/user.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Luca Margasoiu's Contribution/A*algorithm/A*algorithm.xcodeproj/xcuserdata/user.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..fe2b454 --- /dev/null +++ b/Luca Margasoiu's Contribution/A*algorithm/A*algorithm.xcodeproj/xcuserdata/user.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,5 @@ + + + diff --git a/Luca Margasoiu's Contribution/A*algorithm/A*algorithm.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/A*algorithm.xcscheme b/Luca Margasoiu's Contribution/A*algorithm/A*algorithm.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/A*algorithm.xcscheme new file mode 100644 index 0000000..7347817 --- /dev/null +++ b/Luca Margasoiu's Contribution/A*algorithm/A*algorithm.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/A*algorithm.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Luca Margasoiu's Contribution/A*algorithm/A*algorithm.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/xcschememanagement.plist b/Luca Margasoiu's Contribution/A*algorithm/A*algorithm.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..6c58f97 --- /dev/null +++ b/Luca Margasoiu's Contribution/A*algorithm/A*algorithm.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + A*algorithm.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + CE2989F2240AED040051DAED + + primary + + + + + diff --git a/Luca Margasoiu's Contribution/A*algorithm/A*algorithm/main.cpp b/Luca Margasoiu's Contribution/A*algorithm/A*algorithm/main.cpp new file mode 100644 index 0000000..df750a7 --- /dev/null +++ b/Luca Margasoiu's Contribution/A*algorithm/A*algorithm/main.cpp @@ -0,0 +1,232 @@ +#include +#include + +using namespace std; + + + + +class coord { +public: + + int x, y; + coord( int a = 0, int b = 0 ) { + x = a; y = b; + } + + bool operator==( const coord& o ) { + return o.x == x && o.y == y; + } + + coord operator +( const coord& o ) { + return coord( o.x + x, o.y + y ); } +}; + +class gameMap { +public: + char m[8][8]; + int width, height; + gameMap() { + width=8; + height=8; + char x[8][8] = { + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 1, 1, 1, 0}, + {0, 0, 1, 0, 0, 0, 1, 0}, + {0, 0, 1, 0, 0, 0, 1, 0}, + {0, 0, 1, 1, 1, 1, 1, 0}, + {0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0} + }; + for( int r = 0; r < 8; r++ ) + for( int s = 0; s < 8; s++ ) + m[s][r] = x[r][s]; + } + + int get( int x, int y ){ + return m[x][y]; + } +}; + +class coorNod { +public: + + coord position, father; + int gap, value; + + //Overloading operator that compares Coord with coorNod + bool operator== (const coord& o ){ + return position == o; + } +}; + +class algorithm { +public: + + gameMap m; coord end, start; + coord neighbours[8]; + list open; + list closed; + + algorithm() { + neighbours[0] = coord( -1, -1 ); + neighbours[1] = coord( 1, -1 ); + neighbours[2] = coord( -1, 1 ); + neighbours[3] = coord( 1, 1 ); + neighbours[4] = coord( 0, -1 ); + neighbours[5] = coord( -1, 0 ); + neighbours[6] = coord( 0, 1 ); + neighbours[7] = coord( 1, 0 ); + } + + int gapCost( coord& p ){ + //Need better heuristic + int x = end.x - p.x, y = end.y - p.y; + return( x * x + y * y ); + } + + bool isGood( coord& p ) { + return ( p.x >-1 && p.y > -1 && p.x < m.width && p.y < m.height ); + } + + bool existcoord( coord& p, int value ) { + list::iterator i; + i = find( closed.begin(), closed.end(), p ); + if( i != closed.end() ) { + if( ( *i ).value + ( *i ).gap < value ) + return true; + else { closed.erase( i ); return false; + } + } + i = find( open.begin(), open.end(), p ); + if( i != open.end() ) { + if( ( *i ).value + ( *i ).gap < value ) return true; + else { open.erase( i ); return false; } + } + return false; + } + + bool checkN( coorNod& n ) { + int stepvalue, nc, gap; + coord neighbour; + + for( int x = 0; x < 8; x++ ) { + // one can make diagonals have different value + stepvalue = 1; + neighbour = n.position + neighbours[x]; + if( neighbour == end ) return true; + + if( isGood( neighbour ) && m.get( neighbour.x, neighbour.y ) != 1 ) { + nc = stepvalue + n.value; + gap = gapCost( neighbour ); + if( !existcoord( neighbour, nc + gap ) ) { + coorNod m; + m.value = nc; m.gap = gap; + m.position = neighbour; + m.father = n.position; + open.push_back( m ); + } + } + } + return false; + } + + bool search( coord& s, coord& e, gameMap& mp ) { + coorNod n; end = e; start = s; m = mp; + n.value = 0; n.position = s; n.father = 0; n.gap = gapCost( s ); + open.push_back( n ); + while( !open.empty() ) { + //open.sort(); + coorNod n = open.front(); + open.pop_front(); + closed.push_back( n ); + if( checkN( n ) ) return true; + } + return false; + } + + + + + int pathway( list& pathway ) { + pathway.push_front( end ); + int value = 1 + closed.back().value; + pathway.push_front( closed.back().position ); + coord father = closed.back().father; + + for( int y = -1; y < 9; y++ ) { + for( int x = -1; x < 9; x++ ) { + if( x < 0 || y < 0 || x > 7 || y > 7 || m.get( x, y ) == 1 ) + cout << char(77); + else { + if( find( pathway.begin(), pathway.end(), coord( x, y ) )!= pathway.end() ) + cout << "*"; + else cout << " "; + } + } + cout << "\n"; + } + + cout << "\n"; + + for( list::reverse_iterator i = closed.rbegin(); i != closed.rend(); i++ ) { + if( ( *i ).position == father && !( ( *i ).position == start ) ) { + pathway.push_front( ( *i ).position ); + father = ( *i ).father; + + for( int y = -1; y < 9; y++ ) { + for( int x = -1; x < 9; x++ ) { + if( x < 0 || y < 0 || x > 7 || y > 7 || m.get( x, y ) == 1 ) + cout << char(77); + else { + if( find( pathway.begin(), pathway.end(), coord( x, y ) )!= pathway.end() ) + cout << "*"; + else cout << " "; + } + } + cout << "\n"; + } + + cout << "\n"; + + } + + } + pathway.push_front( start ); + + return value; + } + +}; + +int main() { + gameMap m; + coord s, e( 7, 7); + algorithm as; + + if( as.search( s, e, m ) ) { + list pathway; + //This is where everything happens + int c = as.pathway( pathway ); + for( int y = -1; y < 9; y++ ) { + for( int x = -1; x < 9; x++ ) { + if( x < 0 || y < 0 || x > 7 || y > 7 || m.get( x, y ) == 1 ) + cout << char(77); + else { + if( find( pathway.begin(), pathway.end(), coord( x, y ) )!= pathway.end() ) + cout << "*"; + else cout << " "; + } + } + cout << "\n"; + } + + cout << "\npathway value " << c << ": "; + for( list::iterator i = pathway.begin(); i != pathway.end(); i++ ) { + cout<< "(" << ( *i ).x << ", " << ( *i ).y << ") "; + } + } + cout << "\n\n"; + return 0; +} diff --git a/Luca Margasoiu's Contribution/DPSSearch/.DS_Store b/Luca Margasoiu's Contribution/DPSSearch/.DS_Store new file mode 100644 index 0000000..ad377c7 Binary files /dev/null and b/Luca Margasoiu's Contribution/DPSSearch/.DS_Store differ diff --git a/Luca Margasoiu's Contribution/DPSSearch/main.cpp b/Luca Margasoiu's Contribution/DPSSearch/main.cpp new file mode 100644 index 0000000..622c896 --- /dev/null +++ b/Luca Margasoiu's Contribution/DPSSearch/main.cpp @@ -0,0 +1,114 @@ +#include +#include +#include + +using namespace std; + + + + +//TO DO: A star search algorithm. + + + +int height=9; +int width=9; + +char freenode = ' '; // "free" is reserved +char visited = '*'; + +class Coordinates{ +public: + int x; + int y; + + Coordinates(int x = 0, int y = 0){ + this->x = x; + this->y = y; + } + + +}; + +Coordinates startP(1, 0); +Coordinates endP(7, 8); + + +char Map[9][10] = +{ + "M MMMMMMM", + "M M M", + "M MMM M M", + "M M M M", + "M M M MMM", + "M M M M", + "M MMM M M", + "M M M", + "MMMMMMM M", +}; + + +void printAlgorithm(){ + for (int Y = 0; Y < height; Y++) + { + cout< 0 && (Map[Ycor][Xcor - 1] == freenode)) + if( Solve(Xcor - 1, Ycor)){ + return true; + } + if (Xcor < width && (Map[Ycor][Xcor + 1] == freenode)) + if(Solve(Xcor + 1, Ycor)){ + return true; + } + if (Ycor > 0 && (Map[Ycor - 1][Xcor] == freenode)){ + if(Solve(Xcor, Ycor - 1)) + return true; + } + + if (Ycor < height && (Map[Ycor + 1][Xcor] == freenode)){ + if(Solve(Xcor, Ycor + 1)) + return true; + } + + Map[Ycor][Xcor] = freenode; + + printAlgorithm(); + usleep(500000); + return false; +} + + + +int main(){ + if (Solve(endP.x, startP.y)){ + printAlgorithm(); + } + else{ + cout<<"Something went terribly wrong."; + } + + return 0; +} + + +//Code inspired from +//https://stackoverflow.com/questions/9191428/maze-solving-algorithm-in-c/9192067 + diff --git a/Luca Margasoiu's Contribution/Main/.DS_Store b/Luca Margasoiu's Contribution/Main/.DS_Store new file mode 100644 index 0000000..e8de3a1 Binary files /dev/null and b/Luca Margasoiu's Contribution/Main/.DS_Store differ diff --git a/Luca Margasoiu's Contribution/Main/BattleUI.txt b/Luca Margasoiu's Contribution/Main/BattleUI.txt new file mode 100644 index 0000000..622c896 --- /dev/null +++ b/Luca Margasoiu's Contribution/Main/BattleUI.txt @@ -0,0 +1,114 @@ +#include +#include +#include + +using namespace std; + + + + +//TO DO: A star search algorithm. + + + +int height=9; +int width=9; + +char freenode = ' '; // "free" is reserved +char visited = '*'; + +class Coordinates{ +public: + int x; + int y; + + Coordinates(int x = 0, int y = 0){ + this->x = x; + this->y = y; + } + + +}; + +Coordinates startP(1, 0); +Coordinates endP(7, 8); + + +char Map[9][10] = +{ + "M MMMMMMM", + "M M M", + "M MMM M M", + "M M M M", + "M M M MMM", + "M M M M", + "M MMM M M", + "M M M", + "MMMMMMM M", +}; + + +void printAlgorithm(){ + for (int Y = 0; Y < height; Y++) + { + cout< 0 && (Map[Ycor][Xcor - 1] == freenode)) + if( Solve(Xcor - 1, Ycor)){ + return true; + } + if (Xcor < width && (Map[Ycor][Xcor + 1] == freenode)) + if(Solve(Xcor + 1, Ycor)){ + return true; + } + if (Ycor > 0 && (Map[Ycor - 1][Xcor] == freenode)){ + if(Solve(Xcor, Ycor - 1)) + return true; + } + + if (Ycor < height && (Map[Ycor + 1][Xcor] == freenode)){ + if(Solve(Xcor, Ycor + 1)) + return true; + } + + Map[Ycor][Xcor] = freenode; + + printAlgorithm(); + usleep(500000); + return false; +} + + + +int main(){ + if (Solve(endP.x, startP.y)){ + printAlgorithm(); + } + else{ + cout<<"Something went terribly wrong."; + } + + return 0; +} + + +//Code inspired from +//https://stackoverflow.com/questions/9191428/maze-solving-algorithm-in-c/9192067 + diff --git a/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/project.pbxproj b/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/project.pbxproj new file mode 100644 index 0000000..74197bb --- /dev/null +++ b/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/project.pbxproj @@ -0,0 +1,260 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + CE43543E23FA3CC900279357 /* functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE43543D23FA3CC900279357 /* functions.cpp */; }; + CEEC622523E0FD9500741E86 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEEC622423E0FD9500741E86 /* main.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + CEEC621F23E0FD9500741E86 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + CE43543C23FA3B9500279357 /* classHeader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = classHeader.h; sourceTree = ""; }; + CE43543D23FA3CC900279357 /* functions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = functions.cpp; sourceTree = ""; }; + CEEC622123E0FD9500741E86 /* Hello World */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "Hello World"; sourceTree = BUILT_PRODUCTS_DIR; }; + CEEC622423E0FD9500741E86 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + CEEC621E23E0FD9500741E86 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + CEEC621823E0FD9500741E86 = { + isa = PBXGroup; + children = ( + CEEC622323E0FD9500741E86 /* Hello World */, + CEEC622223E0FD9500741E86 /* Products */, + ); + sourceTree = ""; + }; + CEEC622223E0FD9500741E86 /* Products */ = { + isa = PBXGroup; + children = ( + CEEC622123E0FD9500741E86 /* Hello World */, + ); + name = Products; + sourceTree = ""; + }; + CEEC622323E0FD9500741E86 /* Hello World */ = { + isa = PBXGroup; + children = ( + CEEC622423E0FD9500741E86 /* main.cpp */, + CE43543C23FA3B9500279357 /* classHeader.h */, + CE43543D23FA3CC900279357 /* functions.cpp */, + ); + path = "Hello World"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + CEEC622023E0FD9500741E86 /* Hello World */ = { + isa = PBXNativeTarget; + buildConfigurationList = CEEC622823E0FD9500741E86 /* Build configuration list for PBXNativeTarget "Hello World" */; + buildPhases = ( + CEEC621D23E0FD9500741E86 /* Sources */, + CEEC621E23E0FD9500741E86 /* Frameworks */, + CEEC621F23E0FD9500741E86 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Hello World"; + productName = "Hello World"; + productReference = CEEC622123E0FD9500741E86 /* Hello World */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + CEEC621923E0FD9500741E86 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0820; + ORGANIZATIONNAME = user; + TargetAttributes = { + CEEC622023E0FD9500741E86 = { + CreatedOnToolsVersion = 8.2; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = CEEC621C23E0FD9500741E86 /* Build configuration list for PBXProject "Hello World" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = CEEC621823E0FD9500741E86; + productRefGroup = CEEC622223E0FD9500741E86 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + CEEC622023E0FD9500741E86 /* Hello World */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + CEEC621D23E0FD9500741E86 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CEEC622523E0FD9500741E86 /* main.cpp in Sources */, + CE43543E23FA3CC900279357 /* functions.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + CEEC622623E0FD9500741E86 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + CEEC622723E0FD9500741E86 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + }; + name = Release; + }; + CEEC622923E0FD9500741E86 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + CEEC622A23E0FD9500741E86 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + CEEC621C23E0FD9500741E86 /* Build configuration list for PBXProject "Hello World" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CEEC622623E0FD9500741E86 /* Debug */, + CEEC622723E0FD9500741E86 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + CEEC622823E0FD9500741E86 /* Build configuration list for PBXNativeTarget "Hello World" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CEEC622923E0FD9500741E86 /* Debug */, + CEEC622A23E0FD9500741E86 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = CEEC621923E0FD9500741E86 /* Project object */; +} diff --git a/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..3151b38 --- /dev/null +++ b/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate b/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..32f5901 Binary files /dev/null and b/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/xcdebugger/Expressions.xcexplist b/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/xcdebugger/Expressions.xcexplist new file mode 100644 index 0000000..b232067 --- /dev/null +++ b/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/xcdebugger/Expressions.xcexplist @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/xcuserdata/user.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/xcuserdata/user.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..fe2b454 --- /dev/null +++ b/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/xcuserdata/user.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,5 @@ + + + diff --git a/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/Hello World.xcscheme b/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/Hello World.xcscheme new file mode 100644 index 0000000..ef816b8 --- /dev/null +++ b/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/Hello World.xcscheme @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/xcschememanagement.plist b/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..be9ae49 --- /dev/null +++ b/Luca Margasoiu's Contribution/Main/Hello World.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + Hello World.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + CEEC622023E0FD9500741E86 + + primary + + + + + diff --git a/Luca Margasoiu's Contribution/Main/Main/.DS_Store b/Luca Margasoiu's Contribution/Main/Main/.DS_Store new file mode 100644 index 0000000..084daf7 Binary files /dev/null and b/Luca Margasoiu's Contribution/Main/Main/.DS_Store differ diff --git a/Luca Margasoiu's Contribution/Main/Main/classHeader.h b/Luca Margasoiu's Contribution/Main/Main/classHeader.h new file mode 100644 index 0000000..e69de29 diff --git a/Luca Margasoiu's Contribution/Main/Main/functions.cpp b/Luca Margasoiu's Contribution/Main/Main/functions.cpp new file mode 100644 index 0000000..7f51ced --- /dev/null +++ b/Luca Margasoiu's Contribution/Main/Main/functions.cpp @@ -0,0 +1,2 @@ +#include + diff --git a/Luca Margasoiu's Contribution/Main/Main/main.cpp b/Luca Margasoiu's Contribution/Main/Main/main.cpp new file mode 100644 index 0000000..d33a78c --- /dev/null +++ b/Luca Margasoiu's Contribution/Main/Main/main.cpp @@ -0,0 +1,537 @@ + +// +// main.cpp +// Hello World +// +// Created by user on 28/01/2020. +// Copyright © 2020 user. All rights reserved. +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + + +//Global variables, maps, arrays, game map and battle UI. +map usermap; +map, class Pocket_Monsters> enemyLocations; +vector PlayersPokemons; +char gameMap1[40][40]; +string battleUI[17]; +string UIcopy[17]; + + +//Function that changes the map + +char changeMap(int x1,int y1, int x2, int y2,char inc){ + char temp=gameMap1[x2][y2]; + gameMap1[x2][y2]=gameMap1[x1][y1]; + gameMap1[x1][y1]=(int)inc; + return temp; +} + +//Function that prints the map + +void printMap(int x=10){ + cout< bStats){ + initial=i; + type=t; + weakness=w; + attack[0]=attack[1]=bStats.begin()[0]; + health[0]=health[1]=bStats.begin()[1]; + defence[0]=defence[1]=bStats.begin()[2]; + dodgeChance[0]=dodgeChance[1]=bStats.begin()[3]; + isDowned=false; + } + //This function is called after a battle ends. If a pokemon has enough xp for lvl up it goes to assignValues + void isXpEnoughForLvlUp(bool k){ + this->xp+=10*(1+k); + if(this->xp>level*1.5){ + cout<<"Your pokemon has leveled up!"; + this->assignValues(this->level+1); + } + } + //This assigns values after battle + void assignValues(int lvl){ + this->level=lvl; + for(int i=1;icalculateAV(); + } + } + //This calculates Actual Values + void calculateAV(){ + this->attack[1]=(int)(this->attack[1]+.1*this->attack[0]); + this->health[1]=(int)(this->health[1]+.1*this->health[0]); + this->defence[1]=(int)(this->defence[1]+.1*this->defence[0]); + this->dodgeChance[1]=(int)(this->dodgeChance[1]+.1*this->dodgeChance[0]); + this->battleStats[0]=this->attack[1]; + this->battleStats[1]=this->health[1]; + this->battleStats[2]=this->defence[1]; + this->battleStats[3]=this->dodgeChance[1]; + } + + void reassignBattleStats(){ + this->battleStats[0]=this->attack[1]+this->attack[2]; + this->battleStats[1]=this->health[1]+this->health[2]; + this->battleStats[2]=this->defence[1]+this->defence[2]; + this->battleStats[3]=this->dodgeChance[1]+this->dodgeChance[2]; + } + //Oveloading the output operator + friend ostream &operator<<(ostream &output, Pocket_Monsters &temp); + + //Overloading the -= operator. Used to calculate damage between pokemons during the battle + Pocket_Monsters operator-=(Pocket_Monsters &x){ + Pocket_Monsters temp; + int random = ((int)rand())%10-5; // this int caclled random will get a number between -5 and 5. + int dodge = (int)rand()%100; + int damagedealt; + if(this->battleStats[3]>dodge) + damagedealt=0; + else + damagedealt = this->battleStats[1]-(x.battleStats[0]-x.battleStats[0]*this->battleStats[2]*pow(10,-3))+random + 20; + // formula that calcultes damage dealt + //Formula is really buggy + if(this->weakness==x.type) + damagedealt= damagedealt+damagedealt*.2; + this->battleStats[1]=this->battleStats[1]-damagedealt; + return *this; + } +}; + +ostream &operator<<(ostream &output, Pocket_Monsters &temp) +{ + output<<"This pokemon is of type "; + output<>in; + switch (1) { + case 1: + enemy-=ally; + break; + case 2: + //Nothing happens... + break; + case int(3): + return false; + break; + } + if(in==3){ + return false; + + } + } + else + ally-=enemy; + turnnumber++; + changeBattleUI(enemy,ally); + } +} + +class Block{ +private: + string color; + string type; + float eP; //Encounter Probability + +public: + char representation; //What character will be used to show this + bool isPassable; // If you can go through the block + bool canEnter; // if you can enter the block I. E. shop. So far not used + + //Constructors + Block(char rep, string clr, string typ, float P=0.0, bool passable=false, bool enter=false){ + representation=rep; + color=clr; + type=typ; + eP=P; + isPassable=passable; + canEnter=enter; + } + Block(){ + isPassable=NULL; + representation=NULL; + color.clear(); + type.clear(); + eP=NULL; + canEnter=NULL; + } + + friend ostream &operator<<(ostream &output, Block &temp); + + // function that chagnes block values. Used when + void changeValues(Block& x){ + Block temp(this->representation,this->color,this->type,this->eP,this->isPassable,this->canEnter); + this->representation=x.representation; + this->color=x.color; + this->type=x.type; + this->eP=x.eP; + this->isPassable=x.isPassable; + this->canEnter=x.canEnter; + + } + + void printValues(){ + cout<isPassable<color<representation<type<eP<positionX=x; + this->positionY=y; + } + + + void moveCharacter(char keyPress){ + pair coordInitial(this->positionX, this->positionY);// The initial coordinates of the player + pair coordMove;// The coordinates that the player wants to move into. Has a different value for each case of movement. + char var; + keyPress=tolower(keyPress); + if(keyPress=='w' or keyPress=='a' or keyPress=='s' or keyPress== 'd'){ + switch(keyPress){ + case 'w': + coordMove.first=this->positionX-1; + coordMove.second=this->positionY; + var = gameMap1[(this->positionX)-1][this->positionY]; + break; + + case 'a': + coordMove.first=this->positionX; + coordMove.second=this->positionY-1; + var = gameMap1[this->positionX][this->positionY-1]; + break; + + case 's': + coordMove.first=this->positionX+1; + coordMove.second=this->positionY; + var = gameMap1[this->positionX+1][this->positionY]; + break; + case 'd': + coordMove.first=this->positionX; + coordMove.second=this->positionY+1; + var = gameMap1[this->positionX][this->positionY+1]; + break; + } + if(var=='E'){ // If the tile we want to move into is an enemy + pair t; + t.first=coordMove.first; + t.second=coordMove.second; + auto search = enemyLocations.find(t); + if(search==enemyLocations.end()) + cout<<"There has occured an error"; + else{ + bool x=engageBattle(enemyLocations[t],PlayersPokemons[0]); + if(!x){ + cout<<"Battle is over! The enemy still stands!"; + return; + } + else{ + gameMap1[t.first][t.second]=' '; + var=' '; + cout<<"You won! The enemy has been defeated!"<Block::representation); + this->changeValues(usermap[var]); + this->changePosition(coordMove.first, coordMove.second); + } + + } +}; + + +int main(int num_args, char** arg_strings){ + + srand( static_cast(time(nullptr)));//FOUND ON THE INTERNET + + + Pocket_Monsters EarthMonster('E',"Earth","Fire",{10,110,25,10}); // Hefty pokemon that is able to withstand a beating and persevere through a big HP pool and Defence. + Pocket_Monsters FireMonster('F',"Fire","Water",{20,50,10,10}); // Hard hitting pokemon that is low on health but packs a punch. + Pocket_Monsters WaterMonster('W',"Water","Wind",{15,75,15,15}); // Jack of all trades pokemon that doesn't have one great skill but is a solid pick and very reliable. + Pocket_Monsters WindMonster('A',"Air","Earth",{15,50,10,20}); // Agile pokemon that strives to win the fight through it's ability to reach an insane dodge chance. + + cout< + string temp; + + ifstream in; + in.open("mapfile.txt"); + if(in.fail()){ + cout<<"Error Opening File"< + + + usermap['F']=Forest; + usermap['M']=Mountain; + usermap['G']=Grass; + usermap[' ']=Paveway; + usermap['C']=PlayerBlock; + usermap['E']=Enemy; + // cout< coord(4,24); + + enemyLocations[coord]=Monster1; + coord.first=6; + coord.second=0; + enemyLocations[coord]=Monster2; + + int nr; + cout<<"Welcome to the game!"<>nr; + Pocket_Monsters P1; + switch (nr) { + case 1: + P1= FireMonster; + P1.assignValues(1); + PlayersPokemons.push_back(P1); + break; + case 2: + P1= WaterMonster; + P1.assignValues(1); + PlayersPokemons.push_back(P1); + break; + case 3: + P1= WindMonster; + P1.assignValues(1); + PlayersPokemons.push_back(P1); + break; + case 4: + P1= EarthMonster; + P1.assignValues(1); + PlayersPokemons.push_back(P1); + break; + + } + + while(1){ + cout<>x; + if(x=='q'){ + for(int i=0;i +#include +#include + +// -------------------------------------------------------- +// delay( ) -- Allow the screen to be "paused" for the +// number of seconds determined by the programmer. Unlike +// the system("PAUSE");, no message is displayed on the +// screen. (5000 = 5 seconds, approximately) +// -------------------------------------------------------- +// Function for delay( ) +void delay(long seconds) +{ + clock_t time1 = clock(); // use clock time + clock_t time2 = time1 + seconds; + while(time1 < time2) + time1 = clock(); + return; +} + +// -------------------------------------------------------- +// gotoxy( , ) -- Move the cursor to any location on the +// screen. The upper left corner of the screen will be set +// to the coordinates (1,1) for easier counting of spaces. +// -------------------------------------------------------- +// Function for gotoxy( , ) +void gotoxy(int x, int y) +{ + HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); + COORD point; + point.X = x-1; + point.Y = y-1; + SetConsoleCursorPosition(hConsole, point); + return; +} + +// -------------------------------------------------------- +// getch( ) -- Waits for user to hit a key, returns +// this response, and goes on. You will not see the +// user's response on the screen (no echo). +// -------------------------------------------------------- +// Function for getch( ) +int getch(void) +{ + int response; + cout << flush; + response = _getch(); + HANDLE hConsole = GetStdHandle(STD_INPUT_HANDLE); + FlushConsoleInputBuffer(hConsole); + return response; +} + +// -------------------------------------------------------- +// getche( ) -- Waits for user to hit a key, returns +// this response, and goes on. You will see the user's +// response on the screen (echo). +// -------------------------------------------------------- +// Function for getche( ) +int getche(void) +{ + int response; + response = _getche(); + HANDLE hConsole = GetStdHandle(STD_INPUT_HANDLE); + FlushConsoleInputBuffer(hConsole); + return response; +} + diff --git a/Luca Margasoiu's Contribution/Main/mapfile.txt b/Luca Margasoiu's Contribution/Main/mapfile.txt new file mode 100644 index 0000000..67a2ab0 --- /dev/null +++ b/Luca Margasoiu's Contribution/Main/mapfile.txt @@ -0,0 +1,9 @@ +MMMMMMMMMMMMMMM MMM MM MMMMMMM +MM MM MMMMMMM MMMMMMMMM F + MMMMM MMMM F +G GGGGG G FFFF F FF FFFFFF +GGGG GGGG GGGGG E F + C FFFFFFF +E F +FFFFFFFFF F FFFFFF FF + FFFFFFFFFFF FFFFFFFF F