So don’t nobody go away thinking you need 2 updates for a move, you just need 2 updates for the code to draw the board to be legible and concise □ If I read this correctly, I think you should be able to do piece moves in one update - the board representation isn’t necessary to this code. You got the chessboard upside down (Black queen starts on black square) :p (I attached chess.js, if you don’t want to copy/paste it yourself.) Also, it’ll only take two updates to move a piece. Now we can query by symbol, human readable name, or board position. make sure the db is empty (in case we run this multiple times)Ĭolumn_map = ) use the "chess" database, creates it if it doesn't exist If it doesn’t exist yet, it’ll be created when we put something in it. It defaults to “test”, so we’ll start by switching it to the “chess” database. “db” is a global variable that is the database you’re connected to. Here’s the code to create the basic chess board. So, MongoDB can just run JavaScript, so I’ll write a JavaScript file that does everything we need. Ha! Can your relational database query for a subfield of a subfield of type integer or string? (Actually, I have no idea, maybe it can.) Anyway, moving right along… I’m tempted to just use the UTF-8 symbol and position, but it would be nice ot have a human-readable string to query on. Okay, so first we need a representation for a chess piece. What database can’t store a chessboard? On the other hand, it’s fun, and once I thought of the title, I really had to write the post. On the one hand, I can’t believe I’m doing this. This is in response to this nifty blog post on storing a chess board in MySQL and this snarky Tweet about NoSQL DBs (because I’m never snarky).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |