New Stuff: Chat Server/Client

21 views
Skip to first unread message

Matt Thompson

unread,
Aug 29, 2012, 10:45:31 AM8/29/12
to py...@googlegroups.com
Hey, just a heads up for those of you that didn't make it last night. 

We started a new project to learn client/server networking with sockets and probably a little graphics work on the side. The link is https://github.com/pysgf/ChatAdventure

James Vann

unread,
Aug 30, 2012, 7:51:10 PM8/30/12
to py...@googlegroups.com
I've been working on a brain for the BrainTank exercise.  I've figured out several things.  Code is in my Github repo-


I'd appreciate any advice!  This is my first publicly shared code, so any feedback on technique and style is also very much appreciated.  It is probably not very good :)

One challenge I am having- I tried to run all tank commands through a filtering  function that checks to see if that command is already in the queue before adding it.  It has helped, but for some reason my queue still tends to fill up with duplicate entries!

This is making my tank move all the way until it hits something that forces it to stop, rather than checking to see where the enemy tank is before moving another tile.

Matt Thompson

unread,
Aug 31, 2012, 3:06:17 PM8/31/12
to py...@googlegroups.com
Awesome! I'll have to try it out this evening when I get some time. One thing you could try is just forgetting all the commands each time your brain thinks and rebuild them (it will have newer, up to date information at that point anyway). I'm still not entirely sure using a command queue in the interface was a good idea... lol

James Vann

unread,
Aug 31, 2012, 3:20:49 PM8/31/12
to py...@googlegroups.com
I thought that the think function was only called after the command queue was empty anyway?  So forgetting what is in the queue at the beginning of the think function seemed to be pointless?  Did I misunderstand the documentation?

Matt Thompson

unread,
Sep 4, 2012, 12:31:33 PM9/4/12
to py...@googlegroups.com
The idle state is really only defined in the source. We talked a bit about how it interrupts at one of the meetings because it's pretty confusing, but it works like this:

The simulation operates in ticks. Each tick will process logic for your tank according to what's on the queue and what state your tank is in. If your tank is done with a command (a move command or shot command for example) it returns to the idle state for the next tick. Once it's idle, it will re-run the think function in your brain to give you a chance to interrupt any potentially bad commands. So, I added a forget() function to help you clear them out.

Let me know if any of this is confusing - this is the weakest part of BrainTanks IMO.

James Vann

unread,
Sep 4, 2012, 12:48:56 PM9/4/12
to py...@googlegroups.com
Thanks!  I misunderstood the documentation on that. When I get a chance to work on this again, I will add the forget() call to my logic so it calls every time before doing anything else.  I may make some changes to the readme that you can decide whether or not to merge to yours.

Matt Thompson

unread,
Sep 4, 2012, 3:55:04 PM9/4/12
to py...@googlegroups.com
Better documentation is always appreciated :)
Reply all
Reply to author
Forward
0 new messages