Advertisement
Kirkq

SMRPG Cheez Its

Jul 29th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.22 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <stdio.h>
  4. #include <math.h>
  5. #include <windows.h>
  6. #include <vector>
  7.  
  8. using namespace std;
  9.  
  10. #define COL 4
  11. #define LASTROUND 14
  12.  
  13. //Last round should be 14 according to this code?
  14.  
  15. class Round
  16. {
  17. public:
  18. std::vector<int> Map;
  19. std::vector<int> Hist;
  20. std::vector<Round *> Poss;
  21. int RoundNum;
  22. Round *RoundPrev;
  23. //int LastChecked;
  24.  
  25. /*Round *GetRound()
  26. {
  27. Round *temp = this;
  28. return temp;
  29. } */
  30.  
  31. };
  32.  
  33. void CopyHist(Round &round1, Round &round2)
  34. {
  35. //memcpy(&round1.Hist, &round2.Hist, sizeof(&round1.Hist) );
  36. }
  37. void CopyMap(Round &round1, Round &round2)
  38. {
  39. //printf("SIZEOFROUND %d\n", sizeof(round2.Map));
  40. //printf("SIZEOFROUND %d\n", sizeof(round2.Map));
  41. //memcpy(&round1.Map, &round2.Map, sizeof(&round1.Map) );
  42. }
  43.  
  44. //0 1 2 3
  45. //4 5 6 7
  46. //8 9 10 11
  47. //12 13 14 15
  48.  
  49.  
  50. int MapDefault[] = {1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1}; //Start
  51.  
  52. int UpArray[] = {8,9,10,11,12,13,14,15}; //Can be kicked up
  53. int DownArray[] = {0,1,2,3,4,5,6,7};
  54. int LeftArray[] = {2,3,6,7,10,11,14,15};
  55. int RightArray[] = {0,1,4,5,8,9,12,13};
  56.  
  57. #define UP 1
  58. #define DOWN 2
  59. #define LEFT 3
  60. #define RIGHT 4
  61.  
  62. int Possibilities;
  63.  
  64.  
  65. void PrintMapArray(int *MapArray)
  66. {
  67. int i = 0;
  68. int j = 0;
  69. for(i=0;i<4;i++)
  70. {
  71. for(j=0;j<4;j++)
  72. {
  73. printf("%d", MapArray[i*4+j]);
  74. }
  75. printf("\n");
  76. }
  77. printf("\n");
  78. }
  79.  
  80. void PrintMap(Round &round)
  81. {
  82. int i = 0;
  83. int j = 0;
  84. printf("\n");
  85. printf("\n");
  86. for(i=0;i<4;i++)
  87. {
  88. for(j=0;j<4;j++)
  89. {
  90. printf("%d", round.Map[i*4+j]);
  91. }
  92. printf("\n");
  93. }
  94. printf("\n");
  95. }
  96.  
  97. void InitRound(Round &round)
  98. {
  99. int i;
  100.  
  101. //round.LastChecked = -1;
  102. round.RoundNum = 1;
  103. round.Map.resize (16, 1);
  104. round.RoundPrev = NULL;
  105. //for(i=0;i<16;i++)
  106. //{
  107. // printf("%d", round.Map[i]);
  108. //}
  109. round.Hist.resize (32, 0);
  110. round.Poss.resize (32, NULL);
  111. //printf("\n\n");
  112. }
  113.  
  114.  
  115. void CopyArray(int *Array1, int *Array2)
  116. {
  117. int Size = sizeof(*Array2);///sizeof(int);
  118. printf("size = %d\n", Size);
  119. }
  120.  
  121. void CheckKicks(Round &round)
  122. {
  123. int i;
  124. int ball;
  125.  
  126. Round *roundtemp;
  127.  
  128. //UP
  129. for(i=0;i<8;i++)
  130. {
  131. ball = UpArray[i];
  132. //Check ball = 1
  133. //Check ball above = 1
  134. //Check ball above that = 0
  135. if( (round.Map[ball]==1) && (round.Map[ball-COL]==1) && (round.Map[ball-2*COL]==0) )
  136. {
  137. //printf("Can kick ball %d UP\n", ball);
  138. roundtemp = new Round;
  139. InitRound(*roundtemp);
  140. //Adjust the kick for the next map here
  141. (*roundtemp).Map = round.Map;
  142. (*roundtemp).Map[ball] = 0;
  143. (*roundtemp).Map[ball-COL]=0;
  144. (*roundtemp).Map[ball-2*COL]=1;
  145.  
  146. //Record the kick in hist.
  147. round.Hist[2*(round.RoundNum-1)]=ball;
  148. round.Hist[(2*round.RoundNum)-1]=UP;
  149. (*roundtemp).Hist = round.Hist;
  150. (*roundtemp).RoundNum = round.RoundNum + 1;
  151. //NEED TO COPY THE STATS FROM THE LAST ARRAY!!!!!!!!!!!!!
  152.  
  153. //LASTLY, GO SOLVE THAT NODE, 14 deep.
  154. CheckKicks(*roundtemp);
  155. }
  156. }
  157. //DOWN
  158. for(i=0;i<8;i++)
  159. {
  160. ball = DownArray[i];
  161. //Check ball = 1
  162. //Check ball below = 1
  163. //Check ball below that = 0
  164. if( (round.Map[ball]==1) && (round.Map[ball+COL]==1) && (round.Map[ball+2*COL]==0) )
  165. {
  166. //printf("Can kick ball %d DOWN\n", ball);
  167. roundtemp = new Round;
  168. InitRound(*roundtemp);
  169. //Adjust the kick for the next map here
  170. (*roundtemp).Map = round.Map;
  171. (*roundtemp).Map[ball] = 0;
  172. (*roundtemp).Map[ball+COL]=0;
  173. (*roundtemp).Map[ball+2*COL]=1;
  174.  
  175. //Record the kick in hist.
  176. round.Hist[2*(round.RoundNum-1)]=ball;
  177. round.Hist[(2*round.RoundNum)-1]=DOWN;
  178. (*roundtemp).Hist = round.Hist;
  179. (*roundtemp).RoundNum = round.RoundNum + 1;
  180. //NEED TO COPY THE STATS FROM THE LAST ARRAY!!!!!!!!!!!!!
  181.  
  182. //LASTLY, GO SOLVE THAT NODE, 14 deep.
  183. CheckKicks(*roundtemp);
  184. }
  185. }
  186. //LEFT
  187. for(i=0;i<8;i++)
  188. {
  189. ball = LeftArray[i];
  190. //Check ball = 1
  191. //Check ball left = 1
  192. //Check ball left of that = 0
  193. if( (round.Map[ball]==1) && (round.Map[ball-1]==1) && (round.Map[ball-2*1]==0) )
  194. {
  195. //printf("Can kick ball %d LEFT\n", ball);
  196. roundtemp = new Round;
  197. InitRound(*roundtemp);
  198. //Adjust the kick for the next map here
  199. (*roundtemp).Map = round.Map;
  200. (*roundtemp).Map[ball] = 0;
  201. (*roundtemp).Map[ball-1]=0;
  202. (*roundtemp).Map[ball-2*1]=1;
  203.  
  204. //Record the kick in hist.
  205. round.Hist[2*(round.RoundNum-1)]=ball;
  206. round.Hist[(2*round.RoundNum)-1]=LEFT;
  207. (*roundtemp).Hist = round.Hist;
  208. (*roundtemp).RoundNum = round.RoundNum + 1;
  209. //NEED TO COPY THE STATS FROM THE LAST ARRAY!!!!!!!!!!!!!
  210.  
  211. //LASTLY, GO SOLVE THAT NODE, 14 deep.
  212. CheckKicks(*roundtemp);
  213. }
  214. }
  215. //RIGHT
  216. for(i=0;i<8;i++)
  217. {
  218. ball = RightArray[i];
  219. //Check ball = 1
  220. //Check ball right = 1
  221. //Check ball right of that = 0
  222. if( (round.Map[ball]==1) && (round.Map[ball+1]==1) && (round.Map[ball+2*1]==0) )
  223. {
  224. //printf("Can kick ball %d RIGHT\n", ball);
  225. roundtemp = new Round;
  226. InitRound(*roundtemp);
  227. //Adjust the kick for the next map here
  228. (*roundtemp).Map = round.Map;
  229. (*roundtemp).Map[ball] = 0;
  230. (*roundtemp).Map[ball+1]=0;
  231. (*roundtemp).Map[ball+2*1]=1;
  232.  
  233. //Record the kick in hist.
  234. round.Hist[2*(round.RoundNum-1)]=ball;
  235. round.Hist[(2*round.RoundNum)-1]=RIGHT;
  236. (*roundtemp).Hist = round.Hist;
  237. (*roundtemp).RoundNum = round.RoundNum + 1;
  238. //NEED TO COPY THE STATS FROM THE LAST ARRAY!!!!!!!!!!!!!
  239.  
  240. //LASTLY, GO SOLVE THAT NODE, 14 deep.
  241. CheckKicks(*roundtemp);
  242.  
  243. }
  244. }
  245.  
  246. //for(i=0;i<32;i++)
  247. //{
  248. // printf("%d", round.Hist[i]);
  249. //}
  250. //printf("\n\n");
  251.  
  252. if(round.RoundNum > LASTROUND)
  253. {
  254. Possibilities++;
  255. //printf("Got close\n");
  256. //DUMP EVERYTHING
  257. //for(i=0;i<32;i++)
  258. //{
  259. // if(round.Hist[i]<10)
  260. // {
  261. // printf(" ");
  262. // }
  263. // printf("%d", round.Hist[i]);
  264. // }
  265. // printf("\n\n");
  266. }
  267.  
  268.  
  269.  
  270. delete (&round);
  271. //DELETE THIS NODE HERE.
  272.  
  273.  
  274. }
  275.  
  276.  
  277. void CopyArrayToRoundMap(int *MapDefault, Round &round)
  278. {
  279. int i;
  280.  
  281. printf("Sizeof Map = %d", round.Map.size());
  282.  
  283. for(i=0;i<16;i++)
  284. {
  285. round.Map[i] = MapDefault[i];
  286. }
  287. }
  288.  
  289. /*
  290. void InitMap(vector<int> &Map)
  291. {
  292. int i;
  293. Map.resize (16, 1);
  294. for(i=0;i<16;i++)
  295. {
  296. printf("%d", Map[i]);
  297. }
  298. printf("\n\n");
  299. }
  300. */
  301.  
  302.  
  303. int main ()
  304. {
  305. int i = 0;
  306.  
  307. Possibilities = 0;
  308.  
  309. PrintMapArray(MapDefault);
  310. Round *roundstart = new Round;
  311. printf("%d \n", sizeof(MapDefault));
  312. InitRound(*roundstart);
  313. CopyArrayToRoundMap(MapDefault, *roundstart);
  314. PrintMap(*roundstart);
  315. CheckKicks(*roundstart);
  316.  
  317.  
  318. printf("Possibilities: %d", Possibilities);
  319. //210422 SOLUTIONS
  320.  
  321.  
  322. cout << "To close type something and hit enter: ";
  323. cin >> i;
  324. return 0;
  325. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement