Hi everyone! I know it's been a while since the last post of mine, but I've been busy with finals and am taking a quick break to start this post (and maybe finish? this reinforcement learning paper I'm reading is kind of hefty reading and a lot more detailed than I'll need...). So, last time we saw the basic framework for the chess representation, with the board, pieces, and the player data structures. Since then, I've actually not done very much, but that's because it's been buggy and stupid.
This guy right here is a fucking champion. Helped me pinpoint so many bugs, and testing each unit's move set would be bitchy without it. It also has a lot of debug output, but don't mind that. It doesn't do much special, really, just makes a new piece of type x and puts it somewhere on the board (should have checks for values of x_ and y > 7...done). The function name is somewhat misleading, as it is in no way required to operate on who's playing white, but I'm lazy. I'll probably change it once I figure out how to refactor move selection so I can just function call it for both players.
The next big thing I've been working on is the game loop, which is being omitted from this post because it's disgusting and large to transplant into a blog post (seriously, I tried - if anyone really wants to see it, I can email you the current source in all its incomplete glory). I have encountered so many god damn problems with this loop because C++ iterators are wonky, including and not limited to:
It's been a bit of a headache, but I'm pretty sure it's mostly fine now. As for how it works, well, it doesn't really do anything special, but here's some pseudocode anyway:
And that's basically it. It's not fully complete, as I still need to have actual moves and turn-swapping, but yenno. After that I can start working on the actual AI, but finishing just this will probably be a fairly slow process as well, since I need to finish a research proposal, continue studying for finals and somehow manage to feed myself food, because the ramen/rice diet of two days is starting to actually hurt. I should be able to have something by the time spring break comes around, though, and if not in the middle of spring break. Until then, for my OSU friends who are also killing themselves with finals, I wish you all luck!
As always, comments and whatnot can go in the comments, or you can email me!
void unitTestWhite(Pieces x, int x_ = 4, int y = 4) { struct Piece *unittest = new Piece(x); unittest->setPos(x_, y); pieces.push_back(*unittest); //std::cout << "test type: " << unittest->type << endl; //std::cout << "test2: " << pieces.begin()->type << endl; delete unittest; //std::cout << "test3: " << pieces.begin()->type << endl; //std::cout << pieces.size() << endl;}This guy right here is a fucking champion. Helped me pinpoint so many bugs, and testing each unit's move set would be bitchy without it. It also has a lot of debug output, but don't mind that. It doesn't do much special, really, just makes a new piece of type x and puts it somewhere on the board (should have checks for values of x_ and y > 7...done). The function name is somewhat misleading, as it is in no way required to operate on who's playing white, but I'm lazy. I'll probably change it once I figure out how to refactor move selection so I can just function call it for both players.
The next big thing I've been working on is the game loop, which is being omitted from this post because it's disgusting and large to transplant into a blog post (seriously, I tried - if anyone really wants to see it, I can email you the current source in all its incomplete glory). I have encountered so many god damn problems with this loop because C++ iterators are wonky, including and not limited to:
- kings thinking they are pawns
- pieces only wanting to move to legal moves down and right (and in between for bishops and rooks)
- knights thinking they are pawns and sort-of queens
- pieces suddenly becoming paralyzed
- pieces exploding upon the realization they have the potential of movement
It's been a bit of a headache, but I'm pretty sure it's mostly fine now. As for how it works, well, it doesn't really do anything special, but here's some pseudocode anyway:
figure out the current board state and drawdo some fancy aesthetic shit based on whose turn it iswhile a move hasn't been made yet if player's turn, let them click until they click a piece of theirs show all possible moves for clicked piece wait for player to make a moveupdate board and switch turns to opposing playerAnd that's basically it. It's not fully complete, as I still need to have actual moves and turn-swapping, but yenno. After that I can start working on the actual AI, but finishing just this will probably be a fairly slow process as well, since I need to finish a research proposal, continue studying for finals and somehow manage to feed myself food, because the ramen/rice diet of two days is starting to actually hurt. I should be able to have something by the time spring break comes around, though, and if not in the middle of spring break. Until then, for my OSU friends who are also killing themselves with finals, I wish you all luck!
As always, comments and whatnot can go in the comments, or you can email me!