September 11th, 2013, 08:35 AM
Question about networking, tdd and gameprogramming
Hey, I'm trying to learn more about the use of the socket module while making a simple rock, paper, scissors terminal game using test driven development. My goal is to be able to play up to 3 players in the same game at the same time, and be able to add ai players into the game at will.
I've figured out that I should make a client and a server, instead of rolling it all into one. So I'm just looking for some tips regarding this.
1. How should i unittest this with all the networking and whatnot?
2. How can I test this only using one computer? What should I use as id for the diffrent clients? ip adresses wont work, because they all will have the same ip adress.
3.How would i add ai players in a seamless way without adding alot of code?
4. How should the server and client communicate? is it normal to have stupid clients that just prints out what the server wants them to, and sends back input? or should I have smarter clients with built in rock paper scissors logic?
September 11th, 2013, 05:48 PM
1. Unit testing is mostly to test that a single "stand-alone" function returns the correct/expected "output" given a specific input.
Network is more complex to test, as there can be different output. Especially when you work with random values.
2. Each client connect with an IP and a Port number, the combination of this is unique. (I would really like to hear if this isn't unique )
3. You will need to create somekind of an "automated client", where the selection is done randomly.
4. I would assume the client/player should make the selection and then send this to the server.
For start, I would make one client connection to the server.
When the user send the selection to the server, it will then get/perform a AI selection.
The server should then send back the AI selection and who is the winner.
Last edited by MrFujin; September 11th, 2013 at 05:51 PM.