Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMichael Cook
Full Stack JavaScript Techdegree Graduate 28,975 PointsWhy can't you differentiate tokens by their position on the board?
Once a token is dropped it will occupy a set of coordinates on the board, which will probably be a position in an array. Since no two tokens will be able to occupy the same set of coordinates, wouldn't it just be a lot simpler to identify tokens on that basis?
1 Answer
Steven Parker
231,271 PointsLocation would not make a good identifier because the token ID's are assigned before they are placed on the board.
Michael Cook
Full Stack JavaScript Techdegree Graduate 28,975 PointsMichael Cook
Full Stack JavaScript Techdegree Graduate 28,975 PointsI understand that. But why would tokens ever need to be distinguished before they are played? I guess that was my mindset. But I'm still not very far into the course so I suppose I will see.
Steven Parker
231,271 PointsSteven Parker
231,271 PointsThe tokens are identified by owner and index. The owner aspect will be important to determining if adjacent tokens contribute to a winning position. This information will be used in addition to the location they are placed in during game play.