SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Site Related Forums
 Article Discussion
 Article: SQLChess - A tutorial on thinking in sets
 New Topic  Reply to Topic
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

AskSQLTeam
Ask SQLTeam Question

USA
0 Posts

Posted - 05/14/2007 :  07:52:51  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote
Chess makes a fantastic game for programming examples. You will find hundreds of examples on the internet. Some dedicated to OO patterns, others to algorithms and so forth. Unfortunately, most of these examples do not use a database or if they do, treat the database as nothing more than a storage repository. In this series of articles we will use SQL Server and T-SQL to implement the game of chess with an emphasis on thinking in sets.

Article Link.

jsmith8858
Dr. Cross Join

USA
7423 Posts

Posted - 05/14/2007 :  15:18:50  Show Profile  Visit jsmith8858's Homepage  Reply with Quote
I have a doubt ... why teh chess game doesn't work? Plz help !!!

...

just kidding! Great article, a nice start to what should be a very interesting idea for a SQL tutorial ... Looking forward to more in the series.


- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

byrmol
Shed Building SQL Farmer

Australia
1591 Posts

Posted - 05/14/2007 :  15:43:44  Show Profile  Reply with Quote
>>I have a doubt ... why teh chess game doesn't work? Plz help !!!

That's funny Jeff! I'll throw in a UI at the end.



DavidM

Production is just another testing cycle
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30282 Posts

Posted - 05/14/2007 :  15:59:52  Show Profile  Visit SwePeso's Homepage  Reply with Quote
Where is the "pawn-to-queen" move?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

blindman
Flowing Fount of Yak Knowledge

USA
2365 Posts

Posted - 05/14/2007 :  16:01:25  Show Profile  Reply with Quote
You've all seen the SQL Checkers script, I assume? If not, I can find a copy of it in my files. It actually will play checkers against you using SQL.

e4 d5 xd5 Nf6
Go to Top of Page

byrmol
Shed Building SQL Farmer

Australia
1591 Posts

Posted - 05/14/2007 :  16:04:36  Show Profile  Reply with Quote
>>Where is the "pawn-to-queen" move?

Are you talking about promotion Peso?

>>You've all seen the SQL Checkers script, I assume.

No.

DavidM

Production is just another testing cycle
Go to Top of Page

jsmith8858
Dr. Cross Join

USA
7423 Posts

Posted - 05/14/2007 :  16:05:15  Show Profile  Visit jsmith8858's Homepage  Reply with Quote
quote:
Originally posted by Peso

Where is the "pawn-to-queen" move?


Peter Larsson
Helsingborg, Sweden



Pawn-to-Queen ??

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30282 Posts

Posted - 05/14/2007 :  16:08:29  Show Profile  Visit SwePeso's Homepage  Reply with Quote
quote:
Originally posted by byrmol

>>Where is the "pawn-to-queen" move?

Are you talking about promotion Peso?
Yes. It sounds right.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

jsmith8858
Dr. Cross Join

USA
7423 Posts

Posted - 05/14/2007 :  16:13:34  Show Profile  Visit jsmith8858's Homepage  Reply with Quote
That's not really a move, that's more of an "event".



- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30282 Posts

Posted - 05/14/2007 :  16:19:54  Show Profile  Visit SwePeso's Homepage  Reply with Quote
Aha.. Same as "Castling" then, which is described.
Ok, see "promotion" on page 2 of the article, then?


Peter Larsson
Helsingborg, Sweden

Edited by - SwePeso on 05/14/2007 16:20:47
Go to Top of Page

byrmol
Shed Building SQL Farmer

Australia
1591 Posts

Posted - 05/14/2007 :  16:20:36  Show Profile  Reply with Quote
>>Yes. It sounds right.

Given the current schema, we don't have enough information for that. I model a chess piece in the next article, but it was my understanding that promotion is not compulsory and does not have to be a queen.

I will be treating promotion as a "special transition". Something that alters that state of the board without actual piece movement.



DavidM

Production is just another testing cycle
Go to Top of Page

blindman
Flowing Fount of Yak Knowledge

USA
2365 Posts

Posted - 05/14/2007 :  17:15:42  Show Profile  Reply with Quote
Promotion is compulsory, but can be to any piece except a King or a Pawn.
Promotion to a piece of lesser value is called "under-promotion", and is relatively rare. A pawn may be promoted to a knight to effect an immediate checkmate, or check the opponent's king to prevent him from checkmating you on the next turn. A pawn may be promoted to a bishop or a rook to avoid stalemating the opponent.

e4 d5 xd5 Nf6
Go to Top of Page

jezemine
Flowing Fount of Yak Knowledge

USA
2886 Posts

Posted - 05/14/2007 :  17:52:12  Show Profile  Visit jezemine's Homepage  Reply with Quote
there's also the "en passant" attack that the pawn can do, but it's fairly rare. basically it can attack a pawn that is next to it rather than diagonally under some circumstances, to make up for the fact that enemy pawns can move forward 2 spaces on their first move and thus "escape" attack by your pawns. the attack is only allowed if you take it on the first chance it appears though, so would add some complexity to the query of allowed moves, since it depends on what the opponent did last.

http://www.google.com/search?q=pawn+en+passant


www.elsasoft.org
Go to Top of Page

byrmol
Shed Building SQL Farmer

Australia
1591 Posts

Posted - 05/14/2007 :  18:30:10  Show Profile  Reply with Quote
quote:

Promotion is compulsory, but can be to any piece except a King or a Pawn.
Promotion to a piece of lesser value is called "under-promotion", and is relatively rare. A pawn may be promoted to a knight to effect an immediate checkmate, or check the opponent's king to prevent him from checkmating you on the next turn. A pawn may be promoted to a bishop or a rook to avoid stalemating the opponent.

e4 d5 xd5 Nf6



You know, I should have thought about this a little more before I posted. There is probably a dozen closet chess master as members of SQLTeam. I'm screwed!

The variant I will be using has en passant and castling. That promotion rule makes en passant and castling look mild.

DavidM

Production is just another testing cycle
Go to Top of Page

blindman
Flowing Fount of Yak Knowledge

USA
2365 Posts

Posted - 05/14/2007 :  22:32:56  Show Profile  Reply with Quote
en-passant is not all that rare. But I would think it would be much more difficult to implement than promotion, because it require additional exception logic while promotion is just object substitution.

e4 d5 xd5 Nf6
Go to Top of Page

jezemine
Flowing Fount of Yak Knowledge

USA
2886 Posts

Posted - 05/14/2007 :  23:26:18  Show Profile  Visit jezemine's Homepage  Reply with Quote
that's what I was thinking. knowing when en-passant is allowed requires you to remember what the last player did.


www.elsasoft.org
Go to Top of Page

byrmol
Shed Building SQL Farmer

Australia
1591 Posts

Posted - 05/14/2007 :  23:37:12  Show Profile  Reply with Quote
If I read those promotion rules correctly, then anything other than a queen promotion, requires detemining stalemate or check mate.

Far harder than en passant...

DavidM

Production is just another testing cycle
Go to Top of Page

jezemine
Flowing Fount of Yak Knowledge

USA
2886 Posts

Posted - 05/15/2007 :  01:27:19  Show Profile  Visit jezemine's Homepage  Reply with Quote
I don't think it's a rule that you must promote to a knight (or any other piece for that matter) if it forces a checkmate. it's up to the player that wins the promotion what piece they want. it's just that if by taking a knight a player gets an instant checkmate, then the player should do that - unless of course they don't want to win for some reason

I think blindman was only listing some circumstances when you might want to promote to a piece other than a queen. another circumstance would be if you already have a couple queens. it's rather easy to end up in a stalemate if you have several queens on the board.

btw I am definitely not a sqlteam closet chess master. I played on the chess team in high school but that was it. I'm just a hack.


www.elsasoft.org
Go to Top of Page

elwoos
Flowing Fount of Yak Knowledge

United Kingdom
2050 Posts

Posted - 05/15/2007 :  03:41:48  Show Profile  Reply with Quote
quote:
There is probably a dozen closet chess master as members of SQLTeam.


I'm a chess idiot as spirit and many others will attest though he could be in trouble at the moment http://gameknot.com/chess.pl?bd=7070610&r=126

Seriously though I find this really interesting stuff

How about doing GO http://en.wikipedia.org/wiki/Go_ board_game as a future topic?


steve

-----------

Don't worry head. The computer will do all the thinking from now on.
Go to Top of Page

blindman
Flowing Fount of Yak Knowledge

USA
2365 Posts

Posted - 05/15/2007 :  09:23:37  Show Profile  Reply with Quote
Correct jezemine. It is the player's choice which piece he wants to promote to. I was just listing circumstances under which one would want to under-promote.

e4 d5 xd5 Nf6
Go to Top of Page

byrmol
Shed Building SQL Farmer

Australia
1591 Posts

Posted - 05/16/2007 :  17:59:54  Show Profile  Reply with Quote
>> It is the player's choice which piece he wants to promote to. I was just listing circumstances under which one would want to under-promote.

That is what I thought. I thought I was following a standard variant, but you seriously had me worried!

The first article was just to setup the technique that I am using.

DavidM

Production is just another testing cycle
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.17 seconds. Powered By: Snitz Forums 2000