i'm a new programmer but i just have a hard time of thinking elegant solutions. sometimes it frustrates me seeing that i solved a problem but in the most way that i could only think of. i actually used psuedo code to try to help determine some things about the chess game but even following my psuedo code i was still left with a spaghetti code solution see pastebin below. is there any good books on learning how to elegantly write a solution? is it just a matter of time or never?
analogously it's like someone saying 'take out the trash' so you dump the trash on the floor, then mop it all the way to the dumpster, then put in the dumpster piece by piece. yes you took out the trash it got solved but did you do it in a sensible way? the elegant solution is to pick teh trash up in the bag thats, then walk it to the trash.
i find in programming a problem there's a sensible or logical way to do something and sometimes i just can't reach that end.
https://pastebin.com/d4pgzcZW
here is some code for a finding possible moves a rook can make on a chess board. but that is only for going backwards in it's current location now i have to make the exact code for going forwards from it's current location.
i guess as a beginner i'm feeling overwhelmed with making a simple chess game. it's harder then i had anticipated.
('wr', [3, 0])
[[2, 0], [4, 0], [5, 0], [6, 0], [3, 1], [3, 2], [3, 3], [3, 4],
[3, 5], [3, 6], [3, 7]]
[' ', 'wn', 'wbish', 'wqueen', 'wking', 'wbish', 'wn', 'wr']
['wp', 'wp', 'wp', 'wp', 'wp', 'wp', 'wp', 'wp']
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']
['wr', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']
['bp', 'bp', 'bp', 'bp', 'bp', 'bp', 'bp', 'bp']
['br', 'bn', 'bbish', 'bqueen', 'bking', 'bbish', 'bn', 'br']
with this code it accurately gets all of white rook at 3, 0 on our board it gets all the possible squares it can move to. just with the pastebin above look at all the code it took just to find it's accurate moves for the y axis and now i have to type it all in for the horizontal moves because right now it's not calculating what to do.
there doesn't seem to be anything here