Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2008-03-20 23:23:12

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,711

Chess

I have a new Flash version of Chess. It is still being developed, but I thought you would like to have a play with it.

Let me know how it performs.


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

#2 2008-03-20 23:40:35

mathsyperson
Moderator
Registered: 2005-06-22
Posts: 4,900

Re: Chess

I like watching two computers play against each other. Black seems to have a habit of making spectacular comebacks!

It's been working fine for me so far, and the computers don't spend too long thinking either.


Why did the vector cross the road?
It wanted to be normal.

Offline

#3 2008-03-21 04:22:10

JaneFairfax
Member
Registered: 2007-02-23
Posts: 6,868

Re: Chess

1: e4  Nf6
2: Nc3  Nc6
3: Bb5  Ne4
4: Nxe4  e6
5: Nf3  Ke7
6: b3  Nb4
7: Ba3  d6
8: Bxb4  c5
9: Nxc5  f6
10: Ne4  Bd7
11: c4  Bb5
12: cxb5  Kf7
13: Kg1  Kg8
14: d4  Be7
15: Qd2  Rc8
16: Ba5  Qd7
17: b6  axb6
18: Bxb6  f5
19: Nc3  Qe8
20: d5  exd5
21: Qxd5  Kf8
22: Qxf5  Kg8
23: Qe6  Kf8
24: Nd5  Rc2
25: Rc1  Rc1
26: Rxc1  Qh5
27: Qxe7  Kg8
28: Rc8  Qxe8
29: Rxe8

I win!! tongue

Offline

#4 2008-03-21 06:37:25

JaneFairfax
Member
Registered: 2007-02-23
Posts: 6,868

Re: Chess

By the way, some of the moves are not very accurately recorded, particularly with the taking or non-taking of pieces. For example, the computer’s third move was recorded as 3: … Ne4 when it ought to be N×e4 while its last move was recorded as 28: … Q×e8 when it should be just Qe8. Wanna look into that, MathsIsFun? smile

Also my 25th move could have been less ambiguously recorded as 25: Rfc1 rather than just Rc1. And, of course, checks could be indicated by a +. tongue

Offline

#5 2008-03-21 11:26:24

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,711

Re: Chess

Thanks Jane.

Is the game slightly challenging? That is all it needs to be, really. Don't want to have it too hard for new players. (Though with limited compute-power, that is all it could be)


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

#6 2008-03-21 11:31:42

mikau
Member
Registered: 2005-08-22
Posts: 1,504

Re: Chess

did you write the AI mathsisfun? smile


A logarithm is just a misspelled algorithm.

Offline

#7 2008-03-21 11:39:23

Daniel123
Member
Registered: 2007-05-23
Posts: 663

Re: Chess

Good game, but...

The game allowed me, three times in a row, to move a random piece whilst in check. My king flashed during this, but I was still able to do it.

Last edited by Daniel123 (2008-03-21 11:39:43)

Offline

#8 2008-03-21 12:28:53

JaneFairfax
Member
Registered: 2007-02-23
Posts: 6,868

Re: Chess

MathsIsFun wrote:

Is the game slightly challenging? That is all it needs to be, really. Don't want to have it too hard for new players. (Though with limited compute-power, that is all it could be)

The level is fine. The computer makes a mixture of good moves and “unthinking” moves – this should suit new players to a T. tongue

Daniel123 wrote:

The game allowed me, three times in a row, to move a random piece whilst in check. My king flashed during this, but I was still able to do it.

Then this is a definite glitch that needs to be fixed! The rules of chess strictly forbid the moving of random pieces when the king is in check. yikes

Offline

#9 2008-03-21 12:36:54

LuisRodg
Real Member
Registered: 2007-10-23
Posts: 322

Re: Chess

The computer played a solid game and then had a few brainfarts even allowing me to do a very simple checkmate?

Offline

#10 2008-03-21 12:40:02

LuisRodg
Real Member
Registered: 2007-10-23
Posts: 322

Re: Chess

Last game I just murdered the computer.

1: e4  Nc6
2: f4  Nf6
3: Nc3  d6
4: Nf3  Be6
5: Be2  h5
6: Bb5  Qd7
7: Kg1  Kc8
8: f5  Bxf5
9: exf5  Qf5
10: Bxc6  bxc6
11: Nd4  Qd7
12: Qf3  Nh7
13: Nxc6  Re8
14: Nxa7  Kd8
15: Qa8  Qc8
16: Qxc8

Maybe you should allow for different levels of play? Its too easy to beat.

Offline

#11 2008-03-21 12:47:29

JaneFairfax
Member
Registered: 2007-02-23
Posts: 6,868

Re: Chess

I also just found out that the computer doesn’t understand the rule of en passant. yikes

Offline

#12 2008-03-21 15:22:24

John E. Franklin
Member
Registered: 2005-08-29
Posts: 3,588

Re: Chess

42 turns, computer wins me.  I went first.
Good learning tool!!


igloo myrtilles fourmis

Offline

#13 2008-03-21 18:18:16

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,711

Re: Chess

I have the notation working better.

Valid moves when in Check could involve moving the King, blocking, or capturing ... so my best idea so far is to initially allow the move, then retract move if still in Check ... I have put this in the latest version (v0.7)

En Passant is hard! It involves undoing a move, doesn't it?


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

#14 2008-03-22 00:58:31

JaneFairfax
Member
Registered: 2007-02-23
Posts: 6,868

Re: Chess

Well, if it’s a game for mostly “new” players, then I suppose you don’t need to add en passant to it if it’s too hard to code. Many new players to chess don’t understand en passant themselves – so it is just as well not to confuse them. tongue

BTW, the computer is murdered again:

1: d4  Nc6
2: e3  Nf6
3: Nf3  Nd5
4: Bc4  Nd4
5: Nxd4  c5
6: Bxd5  Qa5
7: Bd2  Qd2
8: Qxd2  e6
9: Be4  cxd4
10: Qxd4  Bd6
11: Qxd6  Kd8
12: Kg1  f5
13: Bd3  Ke8
14: Nc3  e5
15: Bxf5  Kd8
16: Nd5  g5
17: Qe7

It lost its queen at move 8. tongue The notation is still not very good because line 7 should have been 7: Bd2  Qxd2 – the “×” is still missing. neutral

Last edited by JaneFairfax (2008-03-22 01:01:17)

Offline

#15 2008-03-22 09:37:22

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,711

Re: Chess

Do you see "v0.7" ? You may have the older version cached.

My AI is mostly positional and piece-value. I thought of adding "piece is attacked/protected" scoring, but thought it may make the game too defensive.

So far it seems to make an interesting game.

And with "en passant" I may be able to make a "dummy piece" that sits behind the pawn, so it can be "taken". The code may end up a bit kludged, but I will have a go.


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

#16 2008-03-22 12:53:49

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,711

Re: Chess

New Version (v0.72) posted ... handles en-passant.

Notation should be correct (except for "0-0" for castling).

I may leave the development about where it is, so long as it gives a reasonable game, but intend to come back in the future and improve it.

What I am missing is a simple "Rules of Chess" page.


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

#17 2008-03-25 16:06:47

John E. Franklin
Member
Registered: 2005-08-29
Posts: 3,588

Re: Chess

v72 hung after I took rook with king:
1: d4  Nc6
2: e3  Nf6
3: c3  Nd5
4: Qf3  Nf4
5: Qxf4  f5
6: Qxf5  Nxd4
7: exd4  c5
8: dxc5  b5
9: Bxb5  Bb7
10: Bxd7+  Qxd7
11: Qxd7+  Kxd7
12: Nf3  Ke8
13: Na3  Bxf3
14: Rg1  Bb7
15: g4  Rd8
16: Rg3  a5
17: Be3  e6
18: Rd1  Rxd1+
19: Kxd1


igloo myrtilles fourmis

Offline

#18 2008-03-25 16:20:38

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,711

Re: Chess

"hung" ... ? Did it say something like "taking too long"?


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

#19 2008-03-25 21:13:07

JaneFairfax
Member
Registered: 2007-02-23
Posts: 6,868

Re: Chess

It happened to me as well. I got a dialogue box ssying an element in the script is causing things to run very slowly and asking me if I wanted to abort the script. Whether I click yes or no, the program “hangs” – I can’t make another move. neutral

Offline

#20 2008-03-25 22:32:03

Identity
Member
Registered: 2007-04-18
Posts: 934

Re: Chess

Some comments - first of all, I think it's great, the computer level is decent, and I can have an enjoyable game, however:

When the King castles on his side, it should say 0-0 instead of the square he moves to, and on the Queen side, the castle should show 0-0-0.

Game 1 (i'm white):
1: e4  Nc6
2: Nf3  Nf6
3: d3  d6
4: Be2  Be6
5: Bg5  Nd7
6: Kg1  Nc5
7: Nc3  a5
8: a3  h5
9: d4  Nd7
10: d5  Bxd5
11: exd5  Na7
12: b4  axb4
13: axb4  g6
14: Bb5  Nxb5
15: Rxa8  Qxa8
16: Nxb5  Kc8 (glancing at the list, this is the first time the black king has moved, so he infact jumps a square)
17: Nxd6+  exd6
18: c4  Bg7
19: Nd4  Bxd4
20: Qxd4  Re8
21: c5  dxc5
22: bxc5  dxc5 (ok this is pretty funny, for the first "dxc5", the black pawn spawns a clone of itself to attack tongue)
23: Ra1  cxd4
24: Rxa8+  Nb8
25: g3  Re1+
26: Kg2  c5
27: dxc6  bxc6 (the en passant worked flawlessly)
28: Bf4  d3
29: Rxb8+  Kd7
30: Bd2  Re2
31: Bf4  c5
32: Rb7+  Kc6
33: Rxf7  Ka6 (a black rook has spawned on d5 as the king moves!)
34: Kf3

Then the Javascript freezes or something, so the game ends here. Pretty good game, apart from the fact black cheated when I was up... what a bad sport!

Game 2 (i'm black):
1: Nc3  e5
2: Nf3  Nc6
3: Nd5  Nf6
4: Nxf6+  Qxf6
5: c4  Bc5
6: e3  Kg8
7: Bd3  d6
8: Kg1  Bg4
9: Bxh7+  Kxh7
10: Qc2+  Kg8
11: d4  Bxf3
12: dxc5  Qg5
13: cxd6  Qxg2+

Technically everything worked well, black missed a very obvious checkmate threat at the end but I guess that's down to AI

Game 3 (i'm black - nothing interesting happens in this game until the end):
1: Nf3  c5
2: Nc3  Nc6
3: Ne4  d6
4: c4  Be6
5: b4  a6
6: bxc5  Bxc4
7: cxd6  exd6
8: Bb2  Be7
9: Bxg7  Bf6
10: Nxf6+  Nxf6
11: Bxf6  Qxf6
12: Rc1  Ne5
13: Nxe5  Bxe2
14: Bxe2  Qxe5
15: Qa4+  b5
16: Qb4  Kg8
17: Qg4+  Kh8
18: Kg1  Re8
19: Bd3  Rg8
20: Qh3  f5
21: Rc7  Re7
22: Rxe7  Qxe7
23: Qxf5  Rg5
24: Qc8+  Rg8
25: Qc3+  Rg7
26: Rc1  Qg5
27: Qc8+  Rg8
28: Qc3+  Rg7
29: Qc8+  Rg8
30: Qc3+  Qg7
31: Qxg7+  Rxg7
32: Rc8+  Rg8
33: Rxg8+  Kxg8
34: Ke1  Kf7

So I'm down a bishop and a pawn when white creates a rook on d1 and the game freezes, spookily on move 34 again.

However I've played another game since and I don't think move 34 is where the problem lies.

Last edited by Identity (2008-03-25 22:56:24)

Offline

#21 2008-03-26 09:10:01

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,711

Re: Chess

Thanks guys ... looks like I have a little debugging work to do sad


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

#22 2008-03-28 21:34:49

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,711

Re: Chess

AFAIK most of the bugs were caused by invalid castling attempts (with a Rook that had been captured).

I think I have fixed it now (v0.73)


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

#23 2008-03-28 21:57:51

JaneFairfax
Member
Registered: 2007-02-23
Posts: 6,868

Re: Chess

You mean the computer was trying to make invalid castling moves? Not me – I know enough of the rules of chess to even think of castling when I’m aware it’s not allowed. wink

PS: I just made my first en passant move with the new software. Thanks! big_smile

Last edited by JaneFairfax (2008-03-28 22:06:43)

Offline

#24 2008-03-28 22:12:47

luca-deltodesco
Member
Registered: 2006-05-05
Posts: 1,470

Re: Chess

i never knew about the en passant move before o.O


The Beginning Of All Things To End.
The End Of All Things To Come.

Offline

#25 2008-03-28 23:49:13

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,711

Re: Chess

JaneFairfax wrote:

You mean the computer was trying to make invalid castling moves? Not me – ...

Yes, yes, the computer was the one doing the naughty things smile

Probably still has some more naughties waiting to spring on us, so let me know.

Oh, and castling should be correctly notated now.


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

Board footer

Powered by FluxBB