Can anyone tell me how to create a chess game and it's logic?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can anyone tell me how to create a chess game and it's logic??

9th Aug 2017, 4:00 AM
Sahil Singh
Sahil Singh - avatar
5 Answers
+ 7
with or without ai? that is the question without ai then you need 1 to keep track of the playing pieces at anytime, a 2d array might be best or hash table if you wish 2 you need to define how each piece can move like if the user does not select the appropriate place it does not move 3 implement kill logic i.e. if moved and such piece there what to do 4 implement some other special moves like swapping the tour with the king that's all as far as i remember for ai well you implement the above with rules start with pure randomness then refine as you go chess ai is a vast topic
9th Aug 2017, 4:35 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 7
As your profile doesn't show more than one (very) simple web code, I guess you're near to rookie in programming... so I think it's better advised to start by coding another simplest kind of game, as hangman, guess number to grow your skills by pratice... at least, start first by doing a chess game without AI (computer opponent), and if you want later, start rather with simplest rules games board, as chess are one of the most not obvious to implement among games type ^^
9th Aug 2017, 10:51 AM
visph
visph - avatar
+ 4
@visph tic tac toe also normally it provides a nice practice
9th Aug 2017, 12:27 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 4
me too i completely forgotten it and went with chess first till now i have to refine my ai in tic tac toe but got a nice cli game experience
9th Aug 2017, 12:33 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 2
@Abdur: yes, you're right... and with advantage of being simple to do AI and having a board to handle: more close to a chess game ^^ (I'm not a gamer soul... so I don't think about all existing, but I was thinking that I forgot this better example ;P)
9th Aug 2017, 12:30 PM
visph
visph - avatar