Looks like it's coming along nicely. The checkmate display is rather strange. All of the pieces appear to work as suspected.
Re: my chess Program
Posted: Sat Jun 12, 2010 11:20 am
by cndr
I'm think I might be changing all the graphics pretty soon, I didn't really know what to do for checkmate so I just whipped that together. I was playing around with the program this morning and found out that I totally forgot that pinned pieces can't stop checkmate, so the program doesn't recognize checkmate when a piece is pinned to the king, and it would normally be able to stop the check. It looks like I have a little bit more work before I can continue.
Re: My Chess Program
Posted: Mon Jun 14, 2010 5:03 pm
by cndr
when I run my chess program I notice that atleast 1 of my cpu's is at 100%, I ran the program with valgrind, the summary is as follows:
==3154== LEAK SUMMARY:
==3154== definitely lost: 114 bytes in 4 blocks
==3154== indirectly lost: 304 bytes in 7 blocks
==3154== possibly lost: 1,335,280 bytes in 2 blocks
==3154== still reachable: 121,181 bytes in 1,334 blocks
==3154== suppressed: 0 bytes in 0 blocks
==3154==
==3154== For counts of detected and suppressed errors, rerun with: -v
==3154== ERROR SUMMARY: 5 errors from 5 contexts (suppressed: 268 from 8)
I think the possibly lost bytes might be a problem
make sure that you have just as many deletes as you have news. If something is allocated and then not deallocated it will cause a lot of memory issues... but that isn't what's eating up your CPU. I think it might be that you forgot to limit the framerate.
Re: My Chess Program
Posted: Mon Jun 14, 2010 5:27 pm
by cndr
wow, I never even thought about limiting the frame rate. I'll get working on that, and I'll update you when I have it implemented, it wont be until tomorrow I think.
thanks for the link Ginto8, I've been messing around with lazy foo's timer class, and made this program this afternoon, I don't know if its worthy of entering moosaders competition, but it is pretty retarded. here is the link for windows users http://www.box.net/shared/24s8kisqj2. if anyone is interested in the Linux version of it, I'll post it.
Re: My Chess Program
Posted: Mon Jun 14, 2010 10:52 pm
by cndr
well I have the frame rate limiter working in my chess program, but I am still having problems with how much cpu usage it uses, I made a video to show off the board editor I added, it doesn't show off loading and saving because I forgot to include it, but the program can do it. In the video I also show that the program stays steadily over 90% cpu usage. I must have a memory leak somewhere, I'm going to look into it, heres the video.
Re: My Chess Program
Posted: Tue Jun 15, 2010 6:17 am
by Live-Dimension
Growing memory usage signifies a memory leak, not a high CPU usage.
Chess programs by definition are CPU-usage hogs.
Re: My Chess Program
Posted: Tue Jun 15, 2010 8:06 am
by cndr
I think the bit boards is taking up more space than is needed, since I have them in a class I decided to make them private, and have another bit board outside the class that represents the data. Right now I have 117 bit boards all with a size of 144, so that would take up 16848 bytes. If I make the bit boards I can cut them down to 63, cutting the bytes down to 9072. I believe this might be some sort of solution, another thing I could do is keep them all private and only use them inside the class, I think I'll go for that approach first.
Re: My Chess Program
Posted: Tue Jun 15, 2010 7:59 pm
by cndr
I finally finished removing all the unnecessary bit boards, my program now uses 11.5 MiBs of memory, I believe before it was around 13. Since I don't use a number higher than 1000 I changed all my ints to shorts, there wasn't that many so there was hardly a difference but that should give me some more space to play with later on. I still have to deal with that cpu usage problem.
Re: My Chess Program
Posted: Wed Jun 16, 2010 5:43 am
by cypher1554R
The CPU usage problem usually occurs at bad looping methods and no vsync.
Try to refresh the screen (call Display() fuction) only when a move is made.
Re: My Chess Program
Posted: Wed Jun 16, 2010 7:25 am
by cndr
last night I found out the problem, I had the graphics and the calculations of the bit boards in the game loop updating as much as possible, I did a test I ran the program for roughly 10 seconds at a frame rate of 13 seconds, the program looped through 131 times, 13 times a second, as expected, 126000 bytes called to store the bit boards alone every second. I'll be updating the program soon, I'm going to start working on the checkmating system again, haven't actually worked on that in a while. I was playing around with SDL_WaitEvent(), I like how it puts the program to sleep, but the only way to exit the program is to esc out of it, I just had it in the main loop, but I'm sure there is a better way to handle it, I think I might come back to it in the future, I'll look deeper into it once I have this game actually working.
Re: My Chess Program
Posted: Fri Jun 18, 2010 5:26 pm
by pythip
have you thought about going open source so we can see how exactly you do things?
Re: My Chess Program
Posted: Sat Jun 19, 2010 8:43 am
by cndr
I'm not sure how much you can learn from my code, but if enough people are interested I'll release it, but for the mean time I have a new release, I should note that some functions aren't working 100% in windows, like loading and saving, seems like windows puts cout to file, which is kinda annoying, I'm going to have to go to lazy foo's site, and do a lesson on displaying text, and inputing text. I'm pretty sure I have checkmate working now, I'm going to be doing some more testing on it, so far it seems like I have to select a piece on the person who is checkmated turn for the checkmate message to appear, I'm going to have to give some credit to people in this version because I've temporarily used other peoples functions, I borrowed lazy foos timer class, and I learned collision detection from moosader. I should also say that the promoting piece is the piece that is out of board, the box around it is just temporary graphics for it, I'm still working on that. If you find bugs please report it, I hope to have another update soon.
EDIT: the game freezes in windows when you try to load, I didn't test for saving.