Topic: "TBS chess?" (page 4 of 6)

< 1 2 3 4 5 6 >
Author Post
moose
groupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
I've just created a project on Google Code: linkcommunity chess.

I think I will not change the way how moves are made (see linkwiki).

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 linkfeatures, I'll clean up the code.)
Edited by moose on 28.07.2011 14:19:01
private message EMail Website
aceldama
groupmastergroupmastergroupmastergroupmaster
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 (linkhttp://www.webster.uk.net/HobbiesAndInterests/IndoorHobbies/PontypoolChessClub/Images/chess_board_blank.gif)

just a thought ;) wish i had more time so i too could enjoy developing the game.
private message
moose
groupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
QuoteQuote:
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.

QuoteQuote:
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 linkdiff of playChess.php you can see 724 lines of 2238 could be replaced by better code. Thats 32%. This is what I thought when I talked about bad code. And the code could still be much better.

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.

QuoteQuote:
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 linkPortable Game Notation (PGN) what you thought of? I'll implement a PGN-Converter, so you will soon be able to use
  • playChess.php?gameID=123&move=2224
  • playChess.php?gameID=123&pgn=d4


If you want linksome other chess notations, you should post a link with specifications. I'll implement it as soon as possible.

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 linkPGN-Converter by writing a RegEx to parse the PGN. If my RegEx is correct I'll probably include the possibility to use PGN next week.
Edited by moose on 06.08.2011 15:25:46
private message EMail Website
aceldama
groupmastergroupmastergroupmastergroupmaster
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
private message
moose
groupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
QuoteQuote from aceldama:
i just meant move=a2a4 (if it were a pawn)

I've just added your idea (see linkNotation of moves)

QuoteQuote from aceldama:
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.

QuoteQuote from aceldama:
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.
private message EMail Website
aceldama
groupmastergroupmastergroupmastergroupmaster
QuoteQuote from moose:
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.

QuoteQuote from moose:
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
private message
moose
groupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
Do you really thing that the loops are that CPU-intensive? In the worst case it's only 4*(8-1) ) = 28 times substr().

QuoteQuote:
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 linkSingle-elimination tournament. But what happens, if you don't have 2^n players? What do you do if a match ends draw?

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 linkWorld Chess Championship 2010, but it seems as if only two players were involved in this World Chess Championchip and they played 12 matches.
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 linkSwiss-system tournament. This might be a solution. I have to take a look at it tomorrow.
Edited by moose on 12.08.2011 21:19:13
private message EMail Website
harvestsnow
groupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
Hi,
I haven't looked at your code, but linkhere is another rule that you might have missed (en passant capture, aka "you have been pawned").

Have you considered implementing it as an irc bot module ?
Edited by harvestsnow on 13.08.2011 05:19:04
private message
moose
groupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
QuoteQuote from harvestsnow:
Hi,
I haven't looked at your code, but linkhere is another rule that you might have missed (en passant capture, aka "you have been pawned").

No, I didn't miss that.

QuoteQuote from harvestsnow:
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?
private message EMail Website
harvestsnow
groupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
QuoteQuote:
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
private message

Topic: "TBS chess?" (page 4 of 6)

< 1 2 3 4 5 6 >