Discussion of chess software programming and technical issues.
Moderators: hgm , Rebel , chrisw
Aleks Peshkov
Posts: 892 Joined: Sun Nov 19, 2006 9:16 pm
Location: Russia
Post
by Aleks Peshkov » Wed Jul 16, 2014 4:39 pm
Code: Select all
void Board::setPieces(const unsigned short state[]) {
//set pieces in separate arrays for every piece
for(short i = 0; i < 64; ++i) {
if(state[i] == BLANK) { //Blank square
continue; //Do nothing
}
else if(state[i] == WPAWN) {
Board::WP[i] = WPAWN;
}
...
//Copy state to allBoard:
for (short n = 0; i < 64; i++) {
Board::allBoard[i] = state[i];
}
}
}
Sorry, it is impossible to create any complex program with that kind of code.
vittyvirus
Posts: 646 Joined: Wed Jun 18, 2014 2:30 pm
Full name: Fahad Syed
Post
by vittyvirus » Fri Jul 18, 2014 6:59 am
Aleks Peshkov wrote: Code: Select all
void Board::setPieces(const unsigned short state[]) {
//set pieces in separate arrays for every piece
for(short i = 0; i < 64; ++i) {
if(state[i] == BLANK) { //Blank square
continue; //Do nothing
}
else if(state[i] == WPAWN) {
Board::WP[i] = WPAWN;
}
...
//Copy state to allBoard:
for (short n = 0; i < 64; i++) {
Board::allBoard[i] = state[i];
}
}
}
Sorry, it is impossible to create any complex program with that kind of code.
So what? Complicated doesn't mean the best? Or does it..?
Angrim
Posts: 97 Joined: Mon Jun 25, 2012 10:16 pm
Location: Forks, WA
Full name: Ben Nye
Post
by Angrim » Fri Jul 18, 2014 8:31 am
chess programs are unavoidably complex. Which makes tidy and careful programming more important for them than for simpler programs where there is more room for errors.
vittyvirus
Posts: 646 Joined: Wed Jun 18, 2014 2:30 pm
Full name: Fahad Syed
Post
by vittyvirus » Fri Jul 18, 2014 8:38 am
Angrim wrote: chess programs are unavoidably complex. Which makes tidy and careful programming more important for them than for simpler programs where there is more room for errors.
This code was just supposed to be a starting point, you know..