find_if nans for magnarune
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
		
							parent
							
								
									37de6068e7
								
							
						
					
					
						commit
						7999b27b86
					
				| @ -1,7 +1,15 @@ | |||||||
| #Compiles the entire program with debug flags then runs it in gdb. | #Compiles the entire program with debug flags then runs it in gdb. If the "test" argument is included, will try and run tests too (in the test folder) | ||||||
| #C++ | #C++ | ||||||
| printf "Running program...\n\n\n" | printf "Running program...\n\n\n" | ||||||
| if g++ $(find . -type f -name "*.cpp") -g ${CUSTOM_PARAMS} -o ${PROJECT_NAME}; then | if [ "$1" = "test" ] | ||||||
|     gdb ./${PROJECT_NAME} "$@" | then | ||||||
|  |     printf "Running tests...\n" | ||||||
|  |     if g++ $(find . -type f -name "*.cpp") -g ${CUSTOM_PARAMS} -o ${PROJECT_NAME}; then | ||||||
|  |         gdb ./${PROJECT_NAME} "$@" | ||||||
|  |     fi | ||||||
|  | else | ||||||
|  |     if g++ $(find . -type f -name "*.cpp" -not -path "./test/*") -g ${CUSTOM_PARAMS} -o ${PROJECT_NAME}; then | ||||||
|  |         gdb ./${PROJECT_NAME} "$@" | ||||||
|  |     fi | ||||||
| fi | fi | ||||||
| printf "\n\n" | printf "\n\n" | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| build.sh:ca58f10d4e30d807987ea0105930ae51  - | build.sh:ca58f10d4e30d807987ea0105930ae51  - | ||||||
| commit.sh:d03a46e721060c22ccb146e19d27e70a  - | commit.sh:d03a46e721060c22ccb146e19d27e70a  - | ||||||
| debug.sh:abbbb0c6d9f2409f3a90738ab3d9d44f  - | debug.sh:131aac078fc1ae3c2278209a09e99a3d  - | ||||||
| lines.sh:3b907786f7fc9204025993016c9080de  - | lines.sh:3b907786f7fc9204025993016c9080de  - | ||||||
| release.sh:a54e2002be80814cc1293a11dff4d116  - | release.sh:0a525311cc14b9c8aefc6f2b816129a1  - | ||||||
| temp:d41d8cd98f00b204e9800998ecf8427e  - | temp:d41d8cd98f00b204e9800998ecf8427e  - | ||||||
| web.sh:3dcc2fe7e036359eedd257a864e9a1e1  - | web.sh:96f2c316536011a3defac50aecae487d  - | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| #Creates a release build that focuses on high runtime performance. | #Creates a release build that focuses on high runtime performance. | ||||||
| #C++ | #C++ | ||||||
| printf "Running program...\n\n\n" | printf "Running program...\n\n\n" | ||||||
| if g++ $(find . -type f -name "*.cpp") ${CUSTOM_PARAMS} -O3 -s -DNDEBUG -o ${PROJECT_NAME}; then | if g++ $(find . -type f -name "*.cpp" -not -path "./test/*") ${CUSTOM_PARAMS} -O3 -s -DNDEBUG -o ${PROJECT_NAME}; then | ||||||
|     ./${PROJECT_NAME} "$@" |     ./${PROJECT_NAME} "$@" | ||||||
| fi | fi | ||||||
| printf "\n\n" | printf "\n\n" | ||||||
|  | |||||||
| @ -1,9 +1,9 @@ | |||||||
| #Compiles emscripten instance of this project for the web. | #Compiles emscripten instance of this project for the web. | ||||||
| #C++ | #C++ | ||||||
| if [ -d "assets" ]; then | if [ -d "assets" ]; then | ||||||
|     em++ -std=c++17 -O2 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s MIN_WEBGL_VERSION=2 -s USE_SDL_MIXER=2 -s USE_LIBPNG=1 $(find . -type f -name "*.cpp") -o ${PROJECT_NAME}.html -I pixelGameEngine.h --preload-file ./assets |     em++ -std=c++17 -O2 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s MIN_WEBGL_VERSION=2 -s USE_SDL_MIXER=2 -s USE_LIBPNG=1 $(find . -type f -name "*.cpp" -not -path "./test/*") -o ${PROJECT_NAME}.html -I pixelGameEngine.h --preload-file ./assets | ||||||
| else | else | ||||||
|     em++ -std=c++17 -O2 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s MIN_WEBGL_VERSION=2 -s USE_SDL_MIXER=2 -s USE_LIBPNG=1 $(find . -type f -name "*.cpp") -o ${PROJECT_NAME}.html -I pixelGameEngine.h  |     em++ -std=c++17 -O2 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s MIN_WEBGL_VERSION=2 -s USE_SDL_MIXER=2 -s USE_LIBPNG=1 $(find . -type f -name "*.cpp" -not -path "./test/*") -o ${PROJECT_NAME}.html -I pixelGameEngine.h  | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| cp buildtemplate.html ${PROJECT_NAME}.html | cp buildtemplate.html ${PROJECT_NAME}.html | ||||||
|  | |||||||
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								border.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								border.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 7.3 KiB | 
							
								
								
									
										95
									
								
								main.cpp
									
									
									
									
									
								
							
							
						
						
									
										95
									
								
								main.cpp
									
									
									
									
									
								
							| @ -1,50 +1,51 @@ | |||||||
| #include <iostream> | #define OLC_PGE_APPLICATION | ||||||
| #include <map> | #include "pixelGameEngine.h" | ||||||
|  | #include <memory> | ||||||
|  | using namespace olc; | ||||||
|  | 
 | ||||||
|  | struct myStruct{ | ||||||
|  | 	std::string name=""; | ||||||
|  | 	int level=1; | ||||||
|  | }; | ||||||
|  | std::vector<std::weak_ptr<myStruct>> vals; | ||||||
|  | 
 | ||||||
|  | void AddVal(std::weak_ptr<myStruct>newVal) { | ||||||
|  | 	auto findVal=std::find_if(vals.begin(),vals.end(), | ||||||
|  | 		[&newVal](std::weak_ptr<myStruct>&val) | ||||||
|  | 			{ | ||||||
|  | 				return val.lock()->name==newVal.lock()->name; | ||||||
|  | 			} | ||||||
|  | 		); | ||||||
|  | 	if (findVal!=vals.end()) { | ||||||
|  | 		std::cout<<"Value "<<newVal.lock()->name<<" already exists."<<std::endl; | ||||||
|  | 		findVal->lock()->level++; | ||||||
|  | 		std::cout<<findVal->lock()->name+" is now level "<<findVal->lock()->level<<std::endl; | ||||||
|  | 	} else { | ||||||
|  | 		std::cout<<"Value "<<newVal.lock()->name<<" does not exist."<<std::endl; | ||||||
|  | 		vals.push_back(newVal); | ||||||
|  | 		std::cout<<newVal.lock()->name+" is now level "<<vals[vals.size()-1].lock()->level<<std::endl; | ||||||
|  | 	} | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| int main() { | int main() { | ||||||
| 	std::map<std::string,bool> vals; | 	std::shared_ptr<myStruct> myPtr1=std::make_shared<myStruct>(); | ||||||
| 	for (int i=1;i<=15;i++) { | 	std::shared_ptr<myStruct> myPtr2=std::make_shared<myStruct>(); | ||||||
| 		for (int j=1;j<=15;j++) { | 	std::shared_ptr<myStruct> myPtr3=std::make_shared<myStruct>(); | ||||||
| 			for (int k=1;k<=15;k++) { | 	std::shared_ptr<myStruct> myPtr4=std::make_shared<myStruct>(); | ||||||
| 				if (i+j+k==15) { | 
 | ||||||
| 					std::string testStr; | 	std::weak_ptr<myStruct> refPtr1=myPtr1; | ||||||
| 					int val1=i,val2=j,val3=k; | 	std::weak_ptr<myStruct> refPtr2=myPtr2; | ||||||
| 					if (i<j&&i<k) { | 	std::weak_ptr<myStruct> refPtr3=myPtr3; | ||||||
| 						val1=i; | 	std::weak_ptr<myStruct> refPtr4=myPtr2; | ||||||
| 						if (j<k) { | 
 | ||||||
| 							val2=j; | 	refPtr1.lock()->name="Test Upgrade 1"; | ||||||
| 							val3=k; | 	refPtr2.lock()->name="Test Upgrade 2"; | ||||||
| 						} else { | 	refPtr3.lock()->name="Test Upgrade 3"; | ||||||
| 							val2=k; | 
 | ||||||
| 							val3=j; | 	std::cout<<(refPtr2.lock()==refPtr4.lock())<<std::endl; | ||||||
| 						} | 
 | ||||||
| 					} | 	AddVal(refPtr1); | ||||||
| 					if (j<i&&j<k) { | 	AddVal(refPtr2); | ||||||
| 						val1=j; | 	AddVal(refPtr3); | ||||||
| 						if (i<k) { | 	AddVal(refPtr4); | ||||||
| 							val2=i; |  | ||||||
| 							val3=k; |  | ||||||
| 						} else { |  | ||||||
| 							val2=k; |  | ||||||
| 							val3=i; |  | ||||||
| 						} |  | ||||||
| 					} |  | ||||||
| 					if (k<i&&k<j) { |  | ||||||
| 						val1=k; |  | ||||||
| 						if (i<j) { |  | ||||||
| 							val2=i; |  | ||||||
| 							val3=j; |  | ||||||
| 						} else { |  | ||||||
| 							val2=j; |  | ||||||
| 							val3=i; |  | ||||||
| 						} |  | ||||||
| 					} |  | ||||||
| 					if (!vals.count(std::to_string(val1)+"_"+std::to_string(val2)+"_"+std::to_string(val3))) { |  | ||||||
| 						std::cout<<std::to_string(val1)+"_"+std::to_string(val2)+"_"+std::to_string(val3)<<std::endl; |  | ||||||
| 						vals[std::to_string(val1)+"_"+std::to_string(val2)+"_"+std::to_string(val3)]=true; |  | ||||||
| 					} |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user