Jump to content

Tk731

Member
  • Posts

    10
  • Joined

  • Last visited

Awards

  1. The best thing would be to start on a high-level language like c++. This will force you to have a much deeper understanding of what you are doing, and what the computer is doing. It will be difficult, but just take it slow and make sure you truly understand each new concept as fully as you can before moving on. Don't focus so much on syntax, that will come with time and can be learned for each language quickly. Focus on the main elements of programming, especially the easy stuff. Having a strong foundation in the basics is the only way to master the higher level concepts. This will make you a stronger programmer and when working with low-level languages, like c#, you will be much better off.
  2. Hey all, I am currently working on a pathfinding program and have run into a small problem. Basically, the code all works as it is supposed to but I was trying to put some of the code into a function rather than have it in code, but it is causing a memory leak. It probably has to do with my parameters and the function call but could use some other eyes. Any idea what I am doing wrong? #include <iostream>#include <string>#include "tile.h"using namespace std;//nodestruct nodeType{ Tile *tile; nodeType *link; nodeType *prevLink; nodeType(); ~nodeType();};//size of mapconst int SIZE = 10;//prototypesvoid findPath(char map[SIZE][SIZE]);void findStartAndEnd(int&, int&, int&, int&, char map[SIZE][SIZE]);void printMap(char map[SIZE][SIZE]);void deleteList(nodeType *list);void searchOpenList(nodeType *list, nodeType *&lowestNode);bool notInList(nodeType *list, int x, int y);void mapOutPath(char map[SIZE][SIZE], Tile *tile);void newTileCreation(Tile *&tile, nodeType *&newNode, int &currX, int &currY, int &endX, int &endY, nodeType *&currentNode, nodeType *&openListTail);int main(){ char end; string blank; char map1[SIZE][SIZE] = {{' ','S',' ',' ',' ',' ',' ',' ',' ',' '}, {'B','B','B',' ','B','B','B','B','B',' '}, {' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}, {'B','B','B','B','B','B','B','B',' ','B'}, {' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}, {' ',' ',' ',' ',' ',' ','B','B','B','B'}, {' ',' ',' ',' ',' ','B','B',' ',' ',' '}, {' ',' ',' ',' ','B',' ','B',' ',' ',' '}, {' ',' ',' ',' ',' ',' ','B',' ',' ',' '}, {' ',' ',' ',' ',' ',' ',' ',' ',' ','E'}}; char map2[SIZE][SIZE] = {{' ','S',' ',' ',' ',' ',' ',' ',' ',' '}, {'B','B','B','B','B','B','B','B','B',' '}, {' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}, {'B','B','B','B','B','B','B','B',' ','B'}, {' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}, {' ','B','B','B','B','B',' ',' ',' ',' '}, {' ',' ',' ',' ',' ','B',' ',' ',' ',' '}, {' ',' ',' ','B',' ','B','B','B','B','B'}, {' ',' ',' ','B',' ',' ',' ',' ',' ',' '}, {' ',' ',' ','B','B','B',' ',' ',' ','E'}}; char map3[SIZE][SIZE] = {{' ','S',' ',' ',' ',' ',' ',' ',' ',' '}, {'B','B','B','B','B','B','B','B','B',' '}, {' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}, {'B','B','B','B','B','B','B','B',' ','B'}, {' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}, {' ','B','B','B','B','B',' ',' ',' ',' '}, {' ',' ',' ',' ',' ','B',' ',' ',' ',' '}, {' ',' ',' ','B',' ','B','B','B','B','B'}, {' ',' ',' ','B',' ','B',' ',' ',' ',' '}, {' ',' ',' ','B','B','B',' ',' ',' ','E'}}; //------------------------------------------------------ cout << "\n\t---------------" << "\n\t MAP 1" << "\n\t---------------"; printMap(map1); cout << "Press enter to find path..."; getline(cin, blank); findPath(map1); //------------------------------------------------------ cout << "\n\t---------------" << "\n\t MAP 2" << "\n\t---------------"; printMap(map2); cout << "Press enter to find path..."; getline(cin, blank); findPath(map2); //------------------------------------------------------ cout << "\n\t---------------" << "\n\t MAP 3" << "\n\t---------------"; printMap(map3); cout << "Press enter to find path..."; getline(cin, blank); findPath(map3); //------------------------------------------------------ cout << "Enter a character and press enter: "; cin >> end; return 0;}//###########################################################void findPath(char map[SIZE][SIZE]){ // Coordinate Variables int startX, startY; int endX, endY; int currX, currY; // Other Variables bool foundDestination = false; // New and Current Pointers Tile *newTile; Tile *currentTile; nodeType *newNode; nodeType *currentNode; // List Pointers nodeType *openListHead = NULL; nodeType *openListTail = NULL; nodeType *closedListHead = NULL; nodeType *closedListTail = NULL; //----------------------------------------------- findStartAndEnd(startX, startY, endX, endY, map); //Staring tile and node newTile = new Tile(startX, startY, endX, endY); newNode = new nodeType; newNode->tile = newTile; //set openlist head and tail to starting node openListHead = openListTail = newNode; openListHead->prevLink = NULL; //search nodes do { //determine open list head searchOpenList(openListHead, currentNode); currentNode->tile->getCoords(currX, currY); //determine if space is searchable, if useable, create new tile and set links if (currX+1 < SIZE && map[currY][currX+1] != 'B' && notInList(openListHead, currX+1, currY) && notInList(closedListHead, currX+1, currY)) { newTileCreation(newTile, newNode, currX, currY, endX, endY, currentNode, openListTail); /* newTile = new Tile(currX+1, currY, endX, endY, currentNode->tile->getScore() + 1, currentNode->tile); newNode = new nodeType; newNode->tile = newTile; openListTail->link = newNode; openListTail->link->prevLink = openListTail; openListTail = openListTail->link; */ } else if (currY+1 < SIZE && map[currY+1][currX] != 'B' && notInList(openListHead, currX, currY+1) && notInList(closedListHead, currX, currY+1)) { newTileCreation(newTile, newNode, currX, currY, endX, endY, currentNode, openListTail); /* newTile = new Tile(currX+1, currY, endX, endY, currentNode->tile->getScore() + 1, currentNode->tile); newNode = new nodeType; newNode->tile = newTile; openListTail->link = newNode; openListTail->link->prevLink = openListTail; openListTail = openListTail->link; */ } else if (currX-1 >= 0 && map[currY][currX-1] != 'B' && notInList(openListHead, currX-1, currY) && notInList(closedListHead, currX-1, currY)) { newTileCreation(newTile, newNode, currX, currY, endX, endY, currentNode, openListTail); /* newTile = new Tile(currX+1, currY, endX, endY, currentNode->tile->getScore() + 1, currentNode->tile); newNode = new nodeType; newNode->tile = newTile; openListTail->link = newNode; openListTail->link->prevLink = openListTail; openListTail = openListTail->link; */ } else if (currY-1 >= 0 && map[currY-1][currX] != 'B' && notInList(openListHead, currX, currY-1) && notInList(closedListHead, currX, currY-1)) { newTileCreation(newTile, newNode, currX, currY, endX, endY, currentNode, openListTail); /* newTile = new Tile(currX+1, currY, endX, endY, currentNode->tile->getScore() + 1, currentNode->tile); newNode = new nodeType; newNode->tile = newTile; openListTail->link = newNode; openListTail->link->prevLink = openListTail; openListTail = openListTail->link; */ } else { if (currentNode == openListHead) { openListHead = openListHead->link; if (openListHead != NULL) openListHead->prevLink = NULL; } else if (currentNode == openListTail) { openListTail = openListTail->prevLink; openListTail->link = NULL; } else { currentNode->prevLink->link = currentNode->link; currentNode->link->prevLink = currentNode->prevLink; } currentNode->link = NULL; currentNode->prevLink = NULL; if (closedListHead == NULL) closedListHead = closedListTail = currentNode; else { closedListTail->link = currentNode; closedListTail = closedListTail->link; } } newTile->getCoords(currX, currY); if (currX == endX && currY == endY) { currentTile = newTile; foundDestination = true; break; } } while (openListHead != NULL); if (foundDestination) { mapOutPath(map, currentTile); printMap(map); } else cout << "\n\t\t\t------------------" << "\n\t\t\t No Path Exists" << "\n\t\t\t------------------\n\n"; deleteList(openListHead); deleteList(closedListHead);}//###########################################################void findStartAndEnd(int &xStart, int &yStart, int &xEnd, int &yEnd, char map[SIZE][SIZE]){ for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { if (map[i][j] == 'S') { xStart = j; yStart = i; } else if (map[i][j] == 'E') { xEnd = j; yEnd = i; } } }}//###########################################################void printMap(char map[SIZE][SIZE]){ cout << "\n\t\t-"; for (int k = 0; k < SIZE; k++) cout << "----"; cout << endl; for (int i = 0; i < SIZE; i++) { cout << "\t\t|"; for (int j = 0; j < SIZE; j++) { cout << " " << map[i][j] << " |"; } cout << "\n\t\t"; if (i == (SIZE - 1)) { cout << "-"; for (int k = 0; k < SIZE; k++) cout << "----"; } else { cout << "|"; for (int k = 0; k < SIZE; k++) cout << "---|"; } cout << endl; }}//###########################################################void deleteList(nodeType *list){ nodeType *currNode; while (list != NULL) { currNode = list; list = list->link; delete currNode; }}//###########################################################void searchOpenList(nodeType *list, nodeType *&lowestNode){ lowestNode = list; int lowestCost = list->tile->getCost(); int tempCost; list = list->link; while (list != NULL) { tempCost = list->tile->getCost(); if (tempCost <= lowestCost) { lowestNode = list; lowestCost = tempCost; } list = list->link; }}//###########################################################bool notInList(nodeType *list, int x, int y){ int tempX; int tempY; while (list != NULL) { list->tile->getCoords(tempX, tempY); if (tempX == x && tempY == y) return false; else list = list->link; } return true;}//###########################################################void mapOutPath(char map[SIZE][SIZE], Tile *tile){ int x, y; tile->getParent(tile); do { tile->getCoords(x, y); if (map[y][x] != 'S') map[y][x] = 'X'; tile->getParent(tile); } while (tile != NULL);}//##########################################################//new Tile functionvoid newTileCreation(Tile *&newTile, nodeType *&newNode, int &currX, int &currY, int &endX, int &endY, nodeType *&currentNode, nodeType *&openListTail){ newTile = new Tile(currX+1, currY, endX, endY, currentNode->tile->getScore() + 1, currentNode->tile); newNode = new nodeType; newNode->tile = newTile; openListTail->link = newNode; openListTail->link->prevLink = openListTail; openListTail = openListTail->link;}//##########################################################// nodeType constructornodeType::nodeType(){ tile = NULL; link = NULL; prevLink = NULL;}//##########################################################// nodeType destructornodeType::~nodeType(){ delete tile; } The problem is with the newTileCreation at line 346, the calls are on 131, 144, 157, and 170
  3. So in. Thanks Linus! twitter https://twitter.com/TylerK731 FB https://www.facebook.com/tyler.kemp.391
  4. Awesome I got it all working now, thanks a lot for your help! :)
  5. They were able to connect and transfer files, I did have a few more questions though. I have two different drives in the server and I have them both added for the users however only the home drive is showing, how can I make them see both? Also, is there anything I can do to increase security?
  6. Ok I got the local to work, will ask a friend to try now.
  7. I allowed it through the firewalls on both my pc and the server, but will double check them. I was using the WAN ip. I did the connection wizard and during the test it started opening data connection then failed. 503 failure of data connection.
  8. I installed the server and it up with a guide but I cannot connect to it with my pc. it says could not connect to server connection timed out. I opened a port on my router. Is there anything else i needed to do? From the video i watched it should work..
  9. I want them to be able to upload and download files to the server yes. I will take a look at it. Is there anything I need to do to get it working? Like I said I have very little networking experience.
  10. Hey guys, just had a question about connecting to a server. Basically right now I have a server running server 2008 sp2. It is set up and have some user accounts for my friends and have some drives mapped and everything is running fine, the problem I am having is that I do not know how get my friends to be able to connect to it from anywhere. I have tried a few different things, I read about FTP and a lot of different things but I still have no idea where to go from here. My one friend suggested a VPN. My question is, what would be the easiest, most secure and fastest way they can connect to it? And how would I set it up? I have very little networking experience unfortunately and there is so much information I am lost. Any help would be appreciated. Thanks.
×