|
koraks
Registered: 06/02/03
Posts: 26,667
|
Re: Ive been doing c++ coding challenges [Re: SleepyE]
#28630587 - 01/22/24 12:58 AM (5 days, 21 hours ago) |
|
|
Quote:
SleepyE said: When i finally finished the code I posted it into chatgpt and ask it to explain/summarize my code and this is what it had to say!

Goes to show that ChatGTP isn't very useful in evaluating assignments etc.
I haven't looked at everything, but a quick peek suggests that there are far more elegant solutions than the proliferation of highly redundant functions you define in CheckerBoard.h lines 41-73.
It also looks like you haven't leveraged the use of arrays, lists or other types of containers yet, going by a quick peek at CheckerBoard.cpp, which is also rich in highly redundant and repetitive code.
What's the point in having two identical classes (PlayerPiece & PlayerPiece2)?
Here's a suggestion: when making a new function and you find yourself copying an existing function and adjusting a few bits here and there, you're creating redundancy in your code and probably overlooking a more elegant solution. Mind you, highly redundant code is sometimes preferable for performance issues, but in this type of application and the type of exercise you're doing, it certainly isn't.
|
koraks
Registered: 06/02/03
Posts: 26,667
|
Re: Ive been doing c++ coding challenges [Re: SleepyE] 1
#28630605 - 01/22/24 02:01 AM (5 days, 20 hours ago) |
|
|
Quote:
SleepyE said: yeah i definitely have to simplify my code. I was more concerned with getting it working. the simplifying of repetitive code has to come after. I think it will be a good exercise though!
Sure. It's good to make both things go hand in hand though. After the first handful of exercises, you really need to be able to solve the problem in an efficient way. If you don't, you'll be stuck with a high level of redundancy and that will stand in the way of doing more complex programs. You hit that wall pretty quickly.
|
koraks
Registered: 06/02/03
Posts: 26,667
|
Re: Ive been doing c++ coding challenges [Re: SleepyE] 1
#28630613 - 01/22/24 02:20 AM (5 days, 20 hours ago) |
|
|
Two things will make a major difference:
1: Arrays and other containers (https://en.cppreference.com/w/cpp/container)
2: Finite state machines (e.g. https://www.aleksandrhovhannisyan.com/blog/implementing-a-finite-state-machine-in-cpp/)
|
|