Author | Post | |||
moose![]() ![]() ![]() ![]() ![]() ![]() |
I've just created a project on Google Code: ![]() I think I will not change the way how moves are made (see ![]() If someone likes to write a client which allows adding your own credentials (PHP session) and would provide a GUI for the actuall chess game, I would like to add it to the project. Its no need of checking rules, only a simple GUI for receiving data from the server and sending the moves to the server would be enough. It would be great for testing. (By the way: Please, don't look at the code. Its ugly. I know it. But it works. As soon as I've implemented all ![]() |
|||
Edited by moose on 28.07.2011 14:19:01 | ||||
![]() |
|
|||
aceldama![]() ![]() ![]() ![]() |
the main problem imho would be to get erik to agree to putting up a bright-shadows GUI for this chess project. none the less, good job moose. your code isn't as ugly as you made out. and not bad for a week's work, though you have been working on this for quite some time now judging by the previous entries in the thread. anyhow, i digress. unless erik has a sub domain (like games.bright-shadows.net) you'll have a whole new playground for us n00b/1337 xss h4xx0rs stealing all sorts of "solutions" on the challenge section. so i guess we'll need to implement some sort of token system that doesn't share the player's php session id directly. if i could suggest one thing though moose, even though the numeric rows and columns work fine, i would prefer (and i guess many other interface programmers as well) a row column system that uses numbers and letters. then you can still say "knight to B6" and have a visual image of said move. like on a real chess board ( ![]() just a thought ![]() |
|||
![]() |
|
|||
moose![]() ![]() ![]() ![]() ![]() ![]() |
![]() the main problem imho would be to get erik to agree to putting up a bright-shadows GUI for this chess project. The GUI is client-side, so its no need of putting it on bright-shadows. Only the scripts which are currently in the svn trunk should be put online. But before anything is put online I have to complete the project to a first stable release. ![]() none the less, good job moose. your code isn't as ugly as you made out. and not bad for a week's work, though you have been working on this for quite some time now judging by the previous entries in the thread. Today I did some code refactoring. If you take a look at the ![]() The first posts I wrote in this topic were only some quick thoughts of writing a community chess software. I didn't realy start to write software; as far as I remember I only thought of the database structure. The software for hosting chess games with an API for developers who want to compete with other developers which is now on code.google.com is a completely new start. I read about this idea on wechall.net so I started coding. I remembered that I wanted to write something simmilar some years ago for bright-shadows, but for any reason I didn't continue the TBS-chess-project. I don't want to write code/think about this project without having a woring example again, so I did some quick and dirty "code-sketches". Now it's time to make the interface-part and the tournament-part, the phpBB / WeChall-Framework integration but after that I'll make some code refactoring again. ![]() if i could suggest one thing though moose, even though the numeric rows and columns work fine, i would prefer (and i guess many other interface programmers as well) a row column system that uses numbers and letters. Is the ![]()
If you want ![]() edit: PGN is much more complicated than my notion. The software needs to know where the different pieces are to decide, from which field the current piece should move. I've started a ![]() |
|||
Edited by moose on 06.08.2011 15:25:46 | ||||
![]() |
|
|||
aceldama![]() ![]() ![]() ![]() |
moose, it's sort of what i meant with the notation. i just meant move=a2a4 (if it were a pawn), though i guess that pgn=Pa4 (or in fact pgn=a4) would be the pgn equivalent of said move, whereas you'd use move=1214. pgn is only handy if you play on a mobile platform (though the fact that you'd have to locate the pawn first would drain battery life faster on mobile devices) or if you have to cope with very many gamers playing at once (you save 1 byte per move, so less bandwidth overall). so, my point - the latter (pgn) is easier to read as an after-game analysis, but the former is easier to program a gaming platform on, but also easier to visualise on a chessboard than the one you currently have. i guess it's just me being a bit iffy. EDIT: also, i only skimmed over the code (nice job on the reductions by the way) but where do you check if you are putting yourself in check? i couldn't find it, and i don't have the time right now. EDIT2: also, a more efficient way to check for a bishop's movements (line 117) is to subtract row and column index 1 from index 2 and if displacement row = column and > 0, then the move is valid (unless moving the bishop puts you in check of course) example: b3-a2 -> 1:1 (correct) b3-a1 -> 1:2 (incorrect) EDIT3: same goes for rooks (line 71). ((row displacement * column displacement) == 0) && ((row displacement + column displacement) > 0) not sure how to incorporate castling into this. EDIT 4: queen (bishop) || (rook) |
|||
Edited by aceldama on 08.08.2011 11:31:40 | ||||
![]() |
|
|||
moose![]() ![]() ![]() ![]() ![]() ![]() |
![]() i just meant move=a2a4 (if it were a pawn) I've just added your idea (see ![]() ![]() EDIT: also, i only skimmed over the code (nice job on the reductions by the way) but where do you check if you are putting yourself in check? i couldn't find it, and i don't have the time right now. Thanks. I check with function isPlayerCheck($board, $colorOfPlayer) if a player is check. The function is defined in line 493. I think you were searching for line 1331 following. ![]() EDIT2: also, a more efficient way to check for a bishop's movements (line 117) is to subtract row and column index 1 from index 2 and if displacement row = column and > 0, then the move is valid (unless moving the bishop puts you in check of course) example: b3-a2 -> 1:1 (correct) b3-a1 -> 1:2 (incorrect) I don't understand what you would like to do. Line 117 is part of function getAllDiagonalFields($board, $x, $y). When I check if a move is possible, I have to get the fields in between. The only exceptions are knights. |
|||
![]() |
|
|||
aceldama![]() ![]() ![]() ![]() |
![]() I don't understand what you would like to do. Line 117 is part of function getAllDiagonalFields($board, $x, $y). When I check if a move is possible, I have to get the fields in between. The only exceptions are knights. i meant do some checking before you go through all the intensive loops. basically if it doesn't pass the criteria i suggested, don't bother with the calculations of where the piece can go. which will save you a lot of processing in the end. also, your castling algorithm doesn't seem to check whether you are moving though check, or i couldn't find it at least. take the following example to see what i mean: -+--+--+--+--+ |Kw|::| |Rw| -+--+--+--+--+ | |::| | | -+--+--+--+--+ | |Rb| | | -+--+--+--+--+ | | | | |the king will move through check in this example, and that isn't allowed. ![]() I check with function isPlayerCheck($board, $colorOfPlayer) if a player is check. The function is defined in line 493. I think you were searching for line 1331 following. what i meant by "putting yourself in check was this: -+--+--+--+--+ |Kw| | |Rw| -+--+--+--+--+ |Bw| | | | -+--+--+--+--+ |Rb| | | | -+--+--+--+--+ | | |::| | -+--+--+--+--+ | | | | | moving the white bishop to the [::] would be a valid move, but it isn't because you put yourself in check. EDIT: nevermind. i found the line of code validating the legitimacy of the player's move. it's on line 1288 |
|||
Edited by aceldama on 11.08.2011 23:02:47 | ||||
![]() |
|
|||
moose![]() ![]() ![]() ![]() ![]() ![]() |
Do you really thing that the loops are that CPU-intensive? In the worst case it's only 4*(8-1) ) = 28 times substr(). ![]() also, your castling algorithm doesn't seem to check whether you are moving though check, or i couldn't find it at least. Thanks, I didn't know that moving through check isn't allowed. I will add this as soon as possible (so I guess tomorrow). I started programming an interface for creating chess tournaments. I thought of four variations for tournaments: 1. an open tournament: everyone can participate 2. protected tournament: its protected by a password 3. closed tournament: The players get invitations (personalized codes which they can receive via email / see in status.php) 4. medal based tournaments: only players with a specific medal may join the tournament (Additionally, every has a close time. After this time (default: 7 days) no more players may join the tournament.) I started to programm the first two. I thought, that the procedure may be the following: 1. Join phase: The players may join / leave the tournament 2. Matches in rounds: Now no player can join / leave the tournament. 3. Finish: A date when the tournament should be defined before the tournament begins Now I thought of a ![]() I thought if I could determine the number of maximum rounds at the end of the join phase, I could simply say time for one round = (FinishTime-EndOfJoinPhase)/Rounds. If I had 2^n players and if chess would not allow draw, this would have been a good solution. But apparently it's not that simple. Do you know a better solution? How does this work in famous chess tournaments? I only took a quick look at ![]() Well, of course I could say that every two players who compete have to play until a game ends not with draw. But that doesn't change anything for the 2^n-players problem. Edit: Just found the ![]() |
|||
Edited by moose on 12.08.2011 21:19:13 | ||||
![]() |
|
|||
harvestsnow![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Hi, I haven't looked at your code, but ![]() Have you considered implementing it as an irc bot module ? |
|||
Edited by harvestsnow on 13.08.2011 05:19:04 | ||||
13.08.2011 05:15:41 |
|
|||
moose![]() ![]() ![]() ![]() ![]() ![]() |
![]() Hi, I haven't looked at your code, but ![]() No, I didn't miss that. ![]() Have you considered implementing it as an irc bot module ? No. What would be the advantages of an irc bot module compared with a webpage? |
|||
![]() |
|
|||
harvestsnow![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() What would be the advantages of an irc bot module compared with a webpage? It doesn't require to modify the site. Now that I think of it, it may require some modification to the bot. What was I saying again? |
|||
Edited by harvestsnow on 13.08.2011 12:00:16 | ||||
13.08.2011 11:59:55 |
|