Darkbouncer4689

Members
  • Content count

    218
  • Joined

  • Last visited

Community Reputation

114 Neutral

About Darkbouncer4689

  • Rank
    Member
  1. TCP - Keeping clients synchronized

    Thanks guys. I'm thinking that rpiller's option may work as long as the server is smart enough to ignore client requests that happen past the end of the timer count down. I'm still not exactly sure what hplus0603 about using time stamps to keep everything in sync. If you wouldn't mind going into a bit more detail on that I would appreciate it! Thanks all!
  2. I'm working on a networked flash game using TCP sockets (forced to use TCP b/c of flash). The game is pretty simple as it is mostly a text based game. The only real synchronization that must be enforced is a countdown timer for each client. This timer will start at 60 seconds and countdown to 0 and at 0 some game state change will occur, so it is important that all clients get to 0 at a similar time. I could send the "start countdown" command from my server to all clients and use the clients system clock, but if the packet is dropped or delayed then a client could get out of sync with the others. I could also enforce some client/server protocol where the client must "check in" with the server every second (or less) and the server enforces the sync of all clients. My concern with this is efficiency. My game is a slow paced text game so it is very possible that a client may not have any data to send to the server for up to 30 seconds at a time. It may not be possible to avoid the "constantly checking in" situation, but I'm hoping someone can give me some pointers to an [b]efficient solution for keeping a timer in sync between multiple clients in a flash application[/b]. Thanks in advance. P.S. I don't think NTP is possible with flash.
  3. Flash networked web game

    thanks ss, I'm working off the trial version for now!
  4. Hey fellow gamers, I'm working on a new project for my gaming portfolio. It will be a flash game. Although I don't like Farmville, I figured it would be a good idea to use the same technologies that they do. I believe Farmville is written in ActionScript 3.0 and uses CSS for its GUI, right? (Please correct me if I'm wrong). I've started learning AS 3.0 but want to make sure I'm on the right track (especially before I buy the IDE from adobe). Also, is there a specific benefit to implementing the GUI in CSS instead of inside of flash? Thanks in advance!
  5. What SDK for multi-platform app?

    I've been looking into Rhomobile/Rhodes. It seems like you write your app in HTML5 and then it works some magic to make it look like a native app. I believe this means it has to have internet access and connect to a server. I'm wondering if anyone has used this technology and can report if there are any downfalls as to writing a native app. Thanks
  6. What SDK for multi-platform app?

    well ideally iphone, android and tablets at minimum. Then possibly blackberry/windows phone depending on if they have enough marketshare to be worth it.
  7. Hey all, Just starting to get serious about app development. I'm wondering whats the best tool to use for designing a multi-platform app. I know about Flex, but I haven't really worked with it. Downsides are that you have to pay for it and it doesn't work for windows phone. I believe it's possible to use html5 but I don't know much more than that. It's always a bit overwhelming when you don't even know what SDK and toolset to use... hoping a veteran out their can steer me in the right direction. Thanks in advance.
  8. Finding minimum distance of points along a 2D grid

    Thanks guys. Both are good algorithms that perform better than brute force! Appreciate the help.
  9. Here's an interesting question for everyone. Say you have a 2D grid with length X and width Y. You have N points in this grid (existing in some cell of the grid). It is possible for more than one point to be in the same grid position. Moving a point to a neighboring spot in the grid (horizontal and vertical, no diagonal movement) takes 1 unit. Find the spot on the grid that allows you to move all points to one grid cell with the least amount of travel cost. + - + - P - + - + | | | | | P - + - + - + - + | | | | | + - P - + - + - + (the 5 |'s are suppose to be spaced out but I guess the editor doesn't like that) +'s are grid cells, - are horizontal movements | are vertical movements, P is a point in a grid cell. The answer for this example is position (2, 2) requiring 4 moves, 2 from the top middle point, 1 each of the other two points. My brute force solution to this was to check the required distance traveled for each node in the grid. The one (or more than one) with the minimum traveled distance is the solution. This requires O(XY) comparisons. I know there is a better solution to this and I believe that this problem is very similar to finding the center of many points, just forced to fit along a grid. I thought of taking the average of all points but that doesn't work for a lot of cases. Anyone have suggestions on how to solve this with a better time complexity than the brute force method?
  10. C++ STL Algorithms

    Okay, this is making sense now. I appreciate the help. I'm having trouble finding any examples that use RandomAccessIterator, for regular iterators I could do vector<int>::iterator itr. How can this be done with a random iterator? Edit: Okay, so the random access is handled for me then? If make a sorted vector and call sort on it, passing in vector.begin and vector.end iterators, the expected run time will still be O(n log n)?
  11. C++ STL Algorithms

    [quote name='Chris_F' timestamp='1323665526' post='4893003'] No, it's not. RandomAccessIterator is simply a template parameter. Sort is expecting you to pass it iterators that support random access. This means, for instance, that std::sort cannot be used on a std::list. [/quote] I'm a bit confused here, what exactly is an iterator that supports random access? Thanks!
  12. C++ STL Algorithms

    Hey all, I've been brushing up on my algorithms and data structures lately and today I was messing around with everything in the STL. I had always known about qsort, but it seems like there are some easier functions available if you happen to already be using an STL container such as vector. Namely something like: vector<int> myVector; sort(myVector.begin(), myVector.end()); I'm guessing that sort is implemented as a quicksort, but there is one part that I'm not sure about. The template for sort is void sort(RandomAccessIterator first, RandomAccessIterator last); I know that for the basic quicksort (taking first element as pivot) it's worst case is a sorted or reverse sorted list in which it runs at O(n^2). This can be avoided by choosing a random pivot which makes it's expected run time O(n log n). I'm guessing this is what RandomAccessIterator is about, but I'm not familiar with them. If I simply use vector.begin() and vector.end() is it converted to a RandomAccessIterator or do I need to do something special to insure a O(n log n) run time? Thanks in advance!
  13. algorithms/data structures with boggle boards!

    Nice answer! I had actually used a trie structure before but didn't think about it until you mentioned it. I think this structure would definitely be more efficient than peforming a binary search each time. Since you would traverse the tree as you form potential words it would be constant time with little overhead for each lookup right? What is the general lookup time for a structure such as this? Most tree structures are log n, but since this tree isn't balanced it makes things a little different.
  14. I recently received this as an interview question. The interview is over and I did not get the job (so I'm not trying to cheat on an interview, just trying to further my knowledge of algorithms and data structures for the future). The question is as follows: [font="Times New Roman"][size="2"]Write a function which will find all the words on ageneralized Boggle™ board. [/size][size="2"]The functionshould take as input the board dimensions, the board, and a dictionary of validwords and it should output the list of all found words to the calling function.[/size] [size="2"]You should consider how your approach willperform with a large dictionary and a large board. My solution to this was to perform a quicksort on the dictionary words. Then I would do a depth first search to get all of the permutations of letters along the board and use a binary search to see if the permutation is in the dictionary. Based on the interview I guess this is not the best solution and at the time I could not think of a better one. Assuming the O(n log n) quicksort is a pre computational cost, each binary search is O(log n). The only thing I know of that could be faster than O(log n) would be to hash everything and have constant lookup time. If anyone has some recommendations on better solutions to solving this problem I would love to hear them. Thanks![/size][/font] [font="Times New Roman"][size="3"][/size][/font]
  15. C++ friend

    Okay so in this case friend and static are very similar. I think friend is a bit cleaner since it doesnt require scope resolution operator each time. (Although some may be against it since it could be confusing as to where that method is defined) Thanks guys! P.S. I'm thinking the cleanest use for this is to override the ostream/istream operators. friend ostream& operator<<(ostream&, Cat&); [size="2"][font="Consolas"] [/font][/size]