Go Back   RunUO - Ultima Online Emulation > RunUO > RunUO Post Archive

RunUO Post Archive The Archvie

Reply
 
Thread Tools Display Modes
Old 06-22-2004, 03:06 PM   #1 (permalink)
 
Join Date: Mar 2003
Location: Near a lava pool
Age: 8
Posts: 1,012
Default (Nujel'm) Battle Chess

Summary:
Play chess with NPCs as pieces on the Nujel'm chessboard (or set up your own somewhere else). This script comes with a full chess logic behind it, preventing players from making illegal moves, and manages automatically game ending.

Description:
I had this script in an almost finished state for ages, and I decided to finally give it a final touch. I believe there are other battle chess scripts out there, but I don't recall any of them implementing the chess logic. This script supports the following chess features:

- Knows the moves, and it prevents pieces to make any illegal moves (providing a little feedback to the user as well).
- Analyzes the board, preventing moves that would put the mover's king under check.
- Supports castle and en passant moves
- Supports pawn promotion
- Recognizes check, checkmate and stalemate situations

The script currently does not implemet:

- The 50 moves rule
- The 3 identical moves rule

Also this script doesn't implement single player chess. If you want a computer opponent get yourself a real chess game

If the game ends with a winner (as opposed to stalemate, resigning, disconnection or whatever), the winner will receive a little document which records the game stats and certifies the victory. You can disable this feature in ChessConfig.cs.

The game is piloted through a series of gumps displaying the current game status, the pieces captured by each side and the current score.

There are a number of time outs you can configure in ChessConfig.cs. By default a player can take up to 10 minutes to make a move, then they get a warning and have further 3 minutes to move. If they don't the game ends. A similar behaviour occurs when a player is disconnected, they have 10 minutes to get back in game before reset.

Staff can immediately terminate a chess game by deleting one of the NPCs on the board.

Important: the game will NOT serialize itself. The board, and the stone will, but not the game itself. Therefore if the server is rebooted, any game in progress will be lost.

As always, please report any issues.

Installation:
Unzip to your scripts folder and restart the server. Use:

[Add ChessControl

to add the game control stone.

Once the stone is placed it must be configured.

If you already have a board made (for example in Nujel'm):

Go to the stone props and set the following:
- BoardNorthWestCorner : this a Point2D value and you can set it by clicking the target location which corresponds to the board's north west cornder.
- BoardHeight : this is the location at which the NPCs will be created.
- SquareWidth (default 2): this is the width of each chessboard square.

If you don't have a chessboard ready:

If you wish the stone to create a chessboard for you, double click an unconfigured stone and target the ground. The stone will create the board and automatically configure the stone with the correct parameters.

Note: by default the script creates and uses a board where each square is 2x2 tiles. This however can be changed, from 1x1 upwards.

Updates

1.0.1, June 23: Quick fix to prevent players from playing against themselves (which could ultimately result in a server crash).
1.0.2, June 24: Fixed the problem that caused some pieces to be unable to capture when played on Felucca.
1.0.3, June 25: Fixed the crash that would occur when a pawn promotion resulted in a checkmate. Possibly fixed another crash occurring at game start when the guest would accept the game and the owner would cancel at the same time. Also the name of the parner is displayed correctly (without the serial) on the start game gump.
1.1, June 25:
- Increased NPCs speed
- NPCs reset their correct facing direction after moving
- Knights follow an L path when moving
- Changed default hues for black and white
- Added sounds to the NPCs. Each piece has a different sound for moving, attacking and being captured.
- Added a number of cosmetic properties to the stone. All those properties can be changed at any time and will serialize with the stone:
- WhiteHue and BlackHue, no explanation needed.
- AttackEffect : this is the ID of the effect performed by a NPC when attacking (before moving) another piece.
- CaptureEffect : this is the effect the NPC performs when it captures another NPC
- BoltOnDeath : specifies if a NPC's capture will be accompanied by a lightning strike
- ChessSet: choose from 5 (I think) chess sets. Currently supplied are: Classic, Fantasy, Fantasy Giant, Animal and Undead. Each set produces different NPCs and uses different sounds.
1.2, June 27:
- Added a region to the chessboard for the duration of the game. This ensures that players aren't allowed to cast invisibility on the chess pieces.
- When starting a game, the player will be able to decide whether to allow players on the chessboard or not (not allowed by default). This will avoid board cluttering. (Thanks to XLordX for these very valid suggestions)
- Added a minor hue to both black and white pieces. This will make the pieces look much better rather than using the opponent's hue. (Thanks to jjarmis for this!)
- Added a safe word to be used when for some reason you loose the target and the game gump. By default say 'game' and if the game isn't stopped you'll receive the game gump.
- Added the option to have a different orientation for the board (NS by default, EW through props). The automatic chessboard generation takes into consideration this parameter. Thanks to XxSp1derxX for this one.
- Something else I can't remember right now Possibly a potential crash fix.
1.2.1, June 28:
- AllowSpectators property will now serialize correctly
- AllowSpectators and Orientation properties will now be applied real time if a game is in progress
- If the board must be rebuilt during a game, the action will be delayed until the current move is over
- OverrideMinorHue property: if set to true ignores the minor hue and uses just one hue to color the pieces.
- Double clicking the stone during a game will now reset the gumps/targets if they have been lost.
1.2.2, June 29:
- OverrideMinorHue will now also override hair and skin hue
- Fixed a potential crash when a player logs our after the game ends but before both players close their gumps.
- Staff above Counselor will always have access to the chessboard.
1.2.3 July 1:
- Fixed a crash occurring when double clicking the stone during game setup.
1.2.4 July 4:
- Hopefully finally fixed the crashing issue with players disconnecting.
- Fixed a few appearance issues on the classic chess set (Sp1der will be happy )
1.2.5 Sept. 28:
- Refactored the Chessboard class to BChessboard. This will prevent the crash occuring when using the [Decorate command.
- NPCs will be now ejected from the chessboard
- Fixed crash occuring when staff would delete a pawn in the middle of its promotion
- If the winner has no backpack they will not receive their winning certificate
- You can no longer check mate your enemy and win the game, while being checked yourself.
- Player can choose the preferred chess set when starting a game.
Attached Files
File Type: zip BattleChess.1.2.5.zip (41.3 KB, 1572 views)
__________________
Oxygen should be regarded as a drug.
Arya is offline   Reply With Quote
Old 06-22-2004, 03:26 PM   #2 (permalink)
 
Join Date: Nov 2003
Posts: 72
Send a message via ICQ to [steel]
Default

Just Arya, No Comment.
[steel] is offline   Reply With Quote
Old 06-22-2004, 03:47 PM   #3 (permalink)
Forum Expert
 
jaynigs's Avatar
 
Join Date: Mar 2003
Location: England
Age: 35
Posts: 986
Default

Quote:
Also this script doesn't implement single player chess. If you want a computer opponent get yourself a real chess game
cool, wonder how hard it would be to put in an Ai to play the computer? if you know java i have a chess engine on my phone and it is very advanced and relatively small, maybe it can be converted to c#? just a thought...

jaynigs is offline   Reply With Quote
Old 06-22-2004, 03:56 PM   #4 (permalink)
draco
Guest
 
Posts: n/a
Default

Like allways Arya, a greeat job!
Im on my holiday now, on the beach outside the house. so im trying it when i get home.


Oh an idea, your the script master, a Mail Box would be cool.
  Reply With Quote
Old 06-22-2004, 04:08 PM   #5 (permalink)
 
Join Date: Mar 2003
Location: Near a lava pool
Age: 8
Posts: 1,012
Default

Quote:
Originally Posted by jaynigs
cool, wonder how hard it would be to put in an Ai to play the computer? if you know java i have a chess engine on my phone and it is very advanced and relatively small, maybe it can be converted to c#? just a thought...

It wouldn't be *that* hard. If you dig inside the script's code, you'll find methods that can perform simulations on the board (which is what's done to verify if there's a checkmate or stalemate). Each piece on the board has a value, and you could have functions making choices from different move plots.

However I honestly think that if you want to play chess against a computer, you should get a real program rather than do it in UO. Then you can fine tweak difficulty, get better help and so on. Not to mention that UO is supposed to be a socializing game. Anyway if anyone wants to alter the script to add an automatic players, by all means do so
__________________
Oxygen should be regarded as a drug.
Arya is offline   Reply With Quote
Old 06-22-2004, 04:37 PM   #6 (permalink)
Forum Expert
 
Captain The First's Avatar
 
Join Date: Jun 2003
Location: The Netherlands
Posts: 647
Default

this is absolutely a work of genius hehe, I defenitely need to find my win2k cd for my second pc that died the other day. Oh well... another hour or so down the bin to fix it :P
__________________
Captain The First
_________________

Undisclosed shard (status: building since Feb. 2003)
Captain The First is offline   Reply With Quote
Old 06-22-2004, 04:46 PM   #7 (permalink)
Helpful? Me? Nah...
 
Llyrwech's Avatar
 
Join Date: Jun 2004
Age: 26
Posts: 50
Send a message via ICQ to Llyrwech Send a message via AIM to Llyrwech Send a message via MSN to Llyrwech Send a message via Yahoo to Llyrwech
Default

First of all, I absolutely love this script. You never cease to amaze me, Arya.

However, I've found one issue. Rooks seem to not have a capture routine and thus get stuck whenever you send them to a spot on which another piece is standing. They wander about and cannot finish the move, even if you relocate the Waypoint. End result: the game has to be terminated.

I'm going to add in my own capture routine to fix this. This could lead to some pretty grumpy chess players. ^_~

Thanks once again for another excellent script.

Safe journeys,
Llyrwech

P.S. On slightly closer inspection, Rooks are the only pieces without the invulnerable orange health bar. Connection? I'm not certain. I'll continue digging.
Llyrwech is offline   Reply With Quote
Old 06-22-2004, 04:58 PM   #8 (permalink)
Forum Expert
 
Captain The First's Avatar
 
Join Date: Jun 2003
Location: The Netherlands
Posts: 647
Default

Oh I do believe the height for the chessboard in nu'jhelm is 5. At least it worked for me that way.
__________________
Captain The First
_________________

Undisclosed shard (status: building since Feb. 2003)
Captain The First is offline   Reply With Quote
Old 06-22-2004, 05:00 PM   #9 (permalink)
Helpful? Me? Nah...
 
Llyrwech's Avatar
 
Join Date: Jun 2004
Age: 26
Posts: 50
Send a message via ICQ to Llyrwech Send a message via AIM to Llyrwech Send a message via MSN to Llyrwech Send a message via Yahoo to Llyrwech
Default

Quote:
Originally Posted by Captain The First
Oh I do believe the height for the chessboard in nu'jhelm is 5. At least it worked for me that way.
Two easy ways to be sure in any situation:
1) 'Props' one of the tiles and check its location value.
2) Stand on the board and use the [where command.

Safe journeys,
Llyrwech
Llyrwech is offline   Reply With Quote
Old 06-22-2004, 05:03 PM   #10 (permalink)
 
Join Date: Mar 2003
Location: Near a lava pool
Age: 8
Posts: 1,012
Default

Llyrwech, I just tried in case some late change broke something, but rooks on my system seem to behave correctly. Also they do have the yellow invul-bar (even though for some weird reason their HP are the 0 - it shouldn't be an issue though since they're all the same type of mobile with just different bodies/clothes).

Does this happen to you all the time? Or can you give me steps to reproduce the bug?
__________________
Oxygen should be regarded as a drug.
Arya is offline   Reply With Quote
Old 06-22-2004, 05:06 PM   #11 (permalink)
Helpful? Me? Nah...
 
Llyrwech's Avatar
 
Join Date: Jun 2004
Age: 26
Posts: 50
Send a message via ICQ to Llyrwech Send a message via AIM to Llyrwech Send a message via MSN to Llyrwech Send a message via Yahoo to Llyrwech
Default

It has happened to me on mutiple attempts, but so far I've only tried pawns. I'll try taking other pieces, though I doubt the routine is selective. I may also have a theory as to the reason... it may be a matter of location. I'll look into that as well. (my board is not in Nujel'm)

Safe journeys,
Llyrwech
Llyrwech is offline   Reply With Quote
Old 06-22-2004, 05:10 PM   #12 (permalink)
 
Join Date: Mar 2003
Location: Near a lava pool
Age: 8
Posts: 1,012
Default

I do all my testing on a board in green acres, so location shouldn't be an issue really. All calculations are performed on an 8x8 matrix, not in world coordinates. Also I pretty much cleared the whole board using only rooks and didn't have a single issue so far...
__________________
Oxygen should be regarded as a drug.
Arya is offline   Reply With Quote
Old 06-22-2004, 05:12 PM   #13 (permalink)
Helpful? Me? Nah...
 
Llyrwech's Avatar
 
Join Date: Jun 2004
Age: 26
Posts: 50
Send a message via ICQ to Llyrwech Send a message via AIM to Llyrwech Send a message via MSN to Llyrwech Send a message via Yahoo to Llyrwech
Default

My rooks cannot take any pieces and no, location did not matter. (I thought that, perhaps, my region rules where I was had been preventing rooks from carrying out their tasks. Not sure why what would be the case, but it was an idea at least.)

Any ideas on your end? This is the only issue of the sort I've seen, and I'm not sure what would make rooks the exception.

Safe journeys,
Llyrwech
Llyrwech is offline   Reply With Quote
Old 06-22-2004, 05:14 PM   #14 (permalink)
Helpful? Me? Nah...
 
Llyrwech's Avatar
 
Join Date: Jun 2004
Age: 26
Posts: 50
Send a message via ICQ to Llyrwech Send a message via AIM to Llyrwech Send a message via MSN to Llyrwech Send a message via Yahoo to Llyrwech
Default

Actually, I begin to see the issue....

Felucca ruleset.

The rooks have no stamina either, so they can't push through to reach the waypoint. This also explains why they move so much slower than other pieces. Now, to simply fix their health issues. ^_~

Safe journeys,
Llyrwech
Llyrwech is offline   Reply With Quote
Old 06-22-2004, 05:17 PM   #15 (permalink)
 
Join Date: Mar 2003
Location: Near a lava pool
Age: 8
Posts: 1,012
Default

Well this is very weird, I tried and tried but my rooks perform as expected. Anyone else having this issue?

When you move a piece, a way point is created at its target location. Do you see it when you move the rook, and does it disappear when the rook reaches its location? Or it doesn't reach it at all? And if so, does it start moving? Do you still have the Make your move button in your gump?
Arya is offline   Reply With Quote
Old 06-22-2004, 05:19 PM   #16 (permalink)
 
Join Date: Mar 2003
Location: Near a lava pool
Age: 8
Posts: 1,012
Default

Quote:
Originally Posted by Llyrwech
Actually, I begin to see the issue....

Felucca ruleset.

The rooks have no stamina either, so they can't push through to reach the waypoint. This also explains why they move so much slower than other pieces. Now, to simply fix their health issues. ^_~

Safe journeys,
Llyrwech
Uhm can you try to do an add an InitStats( 25, 100, 100 ); (or whatever you like) to ChessMobile.cs around line 25 and see if that fixes it?
__________________
Oxygen should be regarded as a drug.
Arya is offline   Reply With Quote
Old 06-22-2004, 05:28 PM   #17 (permalink)
Helpful? Me? Nah...
 
Llyrwech's Avatar
 
Join Date: Jun 2004
Age: 26
Posts: 50
Send a message via ICQ to Llyrwech Send a message via AIM to Llyrwech Send a message via MSN to Llyrwech Send a message via Yahoo to Llyrwech
Default

I had already been in the process of doing the same general thing, except I added the following starting at line 37:

Code:
			m_Piece.Str = 25;
			m_Piece.Int = 100;
			m_Piece.Dex = 100;
			m_Piece.Stam = 100;
The last bit was just my paranoia.

However, it works, now. Also, my rook is slowly regaining his health, finally, as well. Something must be quirky in his general initialization.

At any rate, thank you very much. It works wonderfully. Now, if only I could figure out how to edit Felucca rules to remove that blasted push-through issue.

Safe journeys,
Llyrwech
Llyrwech is offline   Reply With Quote
Old 06-22-2004, 05:28 PM   #18 (permalink)
 
Join Date: Mar 2003
Location: Near a lava pool
Age: 8
Posts: 1,012
Default

You were correct, it's the Felucca ruleset not allowing the rook to move through as I didn't initialize any stats. I have corrected this in the original script (didn't bother to version upgrade). You can do it yourself following what I said in my previous post.

Many thanks for helping me figure this out!
__________________
Oxygen should be regarded as a drug.
Arya is offline   Reply With Quote
Old 06-22-2004, 06:37 PM   #19 (permalink)
Forum Expert
 
Join Date: Mar 2003
Posts: 383
Send a message via ICQ to danknight21 Send a message via AIM to danknight21
Default

well yes i had noticed the problem with sum of the peices not moving right...however....found a new shard crashing problem

If a player click to add a staff member 2 the game and then right as they click accept and the player clicks cancel...the shard crashed
__________________
I Still Play OSI UO, Feel free to ICQ or post with any questions between RUNUO and OSI.
danknight21 is offline   Reply With Quote
Old 06-22-2004, 08:32 PM   #20 (permalink)
 
Join Date: May 2004
Age: 33
Posts: 29
Default

as most of your work Arya, it just looks fine.
keep up the good work

hmm... i might take that idea for more games like stratego

if only i had the time
yevusi is offline   Reply With Quote
Old 06-23-2004, 05:54 AM   #21 (permalink)
 
Join Date: Mar 2003
Location: Near a lava pool
Age: 8
Posts: 1,012
Default

Quote:
Originally Posted by danknight21
well yes i had noticed the problem with sum of the peices not moving right...however....found a new shard crashing problem

If a player click to add a staff member 2 the game and then right as they click accept and the player clicks cancel...the shard crashed
First of all the score is *not* the sum of the captured pieces. In chess each piece has a different value: pawn - 1, knight and bishop - 3, rook 5 and queen 9. The score is the sum of those values for all captured pieces. It gives you a vague idea of who's leading the game.

I have a hard time figuring out where that crash might be happening exactly. Could you get me a crash log please?
__________________
Oxygen should be regarded as a drug.
Arya is offline   Reply With Quote
Old 06-23-2004, 06:43 AM   #22 (permalink)
Forum Novice
 
Join Date: Jun 2003
Posts: 165
Default

Quote:
Originally Posted by [steel]
Just Arya, No Comment.
Wow, a real chess game in Nujel'm ChessBoard has been my dream since I first saw it. When I read the title of the post I didn't even care about the author, just wanted to know if what I was reading was real.

When I saw it was Arya's, everything made sense though...

From now on when I like something I will say it's Arya. "Dude this is so fucking Arya" LOL

JOhnny
joantinet is offline   Reply With Quote
Old 06-23-2004, 12:02 PM   #23 (permalink)
Account Terminated
 
Icon's Avatar
 
Join Date: Aug 2003
Location: North Carolina
Age: 36
Posts: 390
Send a message via MSN to Icon
Default

Quote:
Originally Posted by Llyrwech
I had already been in the process of doing the same general thing, except I added the following starting at line 37:

Code:
			m_Piece.Str = 25;
			m_Piece.Int = 100;
			m_Piece.Dex = 100;
			m_Piece.Stam = 100;
The last bit was just my paranoia.

However, it works, now. Also, my rook is slowly regaining his health, finally, as well. Something must be quirky in his general initialization.

At any rate, thank you very much. It works wonderfully. Now, if only I could figure out how to edit Felucca rules to remove that blasted push-through issue.

Safe journeys,
Llyrwech


Well here u go enjoy :P

MapDefinitions.cs


Code:
RegisterMap( 0, 0, 0, 6144, 4096, 4, "Felucca",  MapRules.FeluccaRules|MapRules.FreeMovement );

Hk
Icon is offline   Reply With Quote
Old 06-23-2004, 01:54 PM   #24 (permalink)
Forum Novice
 
koluch's Avatar
 
Join Date: Mar 2004
Location: Wisconsin
Age: 45
Posts: 791
Unhappy

Ran a test on my admin playing against, well only me(which could have resulted in the crash(es)
So only moving the black pieces. Upon taking the king, server crashed:
Code:
Server Crash Report
===================

Operating System: Microsoft Windows NT 5.1.2600.0
.NET Framework: 1.1.4322.573
Time: 6/23/2004 11:58:44 AM
Mobiles: 10980
Items: 124692
Clients:
- Count: 1
+ 192.168.0.163: (account = Sharon) (mobile = 0x52 'Shazzy')

Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Arya.Chess.Chessboard.PushGame(ChessColor nextMoveColor, Move move)
   at Arya.Chess.BaseChessPiece.OnMoveOver()
   at Arya.Chess.ChessMobile.OnLocationChange(Point3D oldLocation)
   at Server.Mobile.SetLocation(Point3D newLocation, Boolean isTeleport)
   at Server.Mobiles.BaseCreature.SetLocation(Point3D newLocation, Boolean isTeleport)
   at Server.Mobile.Move(Direction d)
   at Server.Mobiles.BaseAI.DoMoveImpl(Direction d)
   at Server.Mobiles.BaseAI.DoMove(Direction d, Boolean badStateOk)
   at Server.Mobiles.BaseAI.DoMove(Direction d)
   at Server.Mobiles.BaseAI.DoActionWander()
   at Server.Mobiles.MeleeAI.DoActionWander()
   at Server.Mobiles.BaseAI.Think()
   at Server.Mobiles.AITimer.OnTick()
   at Server.Timer.Slice()
   at Server.Core.Main(String[] args)
Solely due to the fact I used myself as pick opponant - cause if thats the issure, and its crashes the server, players could also select themselves and do the same :/
Really cool idea, I hope theres a simple answer to my crash question so I can add it to the Server!
koluch is offline   Reply With Quote
Old 06-23-2004, 01:58 PM   #25 (permalink)
Helpful? Me? Nah...
 
Llyrwech's Avatar
 
Join Date: Jun 2004
Age: 26
Posts: 50
Send a message via ICQ to Llyrwech Send a message via AIM to Llyrwech Send a message via MSN to Llyrwech Send a message via Yahoo to Llyrwech
Default