Completed Ruby Chess Game


#1

Just completed the final ruby project.

Feedback appreciated.

I felt like my code isn’t dry, and the organization could use some work.

The hardest part of this project was figuring out how to code threefold repetition, and the 50 move draw rule. I ended up using object marshalling to serialize the board before a move is made, and then checking for the draw and victory conditions. As a result, my game runs slower than it would. Are there any better ways to code draw conditions?

On a side note, I feel like if I move onto the next topic on the odin project, I’ll forget everything I learned up to that point. Anyone have a solution to this, Is it just a matter of repetition?

Thanks


#2

Great work @fffear

Your code looks really good. I wouldn’t worry about moving on and forgetting. What you’ve actually learned are the core concepts around programming so even if you forget some specific way Ruby works you’ll find you can get back up and running really easily if you need to.

I think most people (myself included) skipped the threefold rule implementation so it’s awesome you had a crack at it. I’ve had a think about it and the only other way that came to mind (and I can’t be sure this is faster) is that on each round you make each piece store it’s position. You can then query each pieces array positions to find if there are any that match 3 times. This would result in really long arrays as you’d have to update each piece every round with it’s position.

Don’t dwell on it though. Time to move on.