Chess

Discussion in 'Plugin Development' started by nurta, Jan 17, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    nurta

    I decided to go ahead with the idea I mentioned in http://forums.bukkit.org/threads/idea-chess.628/

    Some details:

    Code:
    Commands:
    
    
    Admin:
        # Creates a new board.  The caller's current position is set as the bottom-left-most block of the A1 square.  The caller's orientation is rounded to the nearest non-diagonal direction and that is used as the Y-axis (numbered 
        # side) of the chess board.
        /chess create board <int: square size>
        # Deletes a board and any active game on the board
        /chess delete board <int: board id>
        
    
    Mod:
        # Creates a game between the players specified as the colors specified. 
        /chess create game <player: white> <player: black>
        # Ends a specific game
        /chess end <int: game id>
    
    
    User:        
        # messages the caller with a list of boards in the world
        /chess list boards                    
    
        # messages the caller with a list of games currently active in the world    
        /chess list games
    
        # Signs up this player to play a color on a board if the spot is available.  If no color is specified, it defaults to white if available, black if not.  If no board is specified, it defaults to the nearest board to the player
        /chess sign-up [white/black] [int: board id]                   
        
        # If opponent is signed up on a board without an opponent, signs up the caller as the opponent.  If not, it picks a board between the two players, signs the caller as a player, and invites the opponent to join.  If a color is
        # specified, it uses that color if possible for the caller if it signs them up for a game.  If no color is specified, it picks a random color of the available choices
        /chess sign-up against <player: opponent> [as] [white/black]    
        
        # Resigns a game.  If the player is in multiple games, game id is not optional
        /chess resign [int: game id]                        
        
        # Displays a list of the caller's current games
        /chess my games
        
        # Displays the status of a board.  Defaults to the nearest board if no board specified
        /chess status board [int: board id]
    
        # Displays the status of a game.  Defaults to the game on the nearest board if no game specified
        /chess status game [int: game id]
        
        # Offers a draw to a game or accepts a draw if one has been offered.  Upon a legal move, a draw request is automatically recalled.  If the caller is in multiple games, the game id is not optional
        /chess draw [int: game id]
        
        # Does a move in a game.  The caller must be a player in the desired game and it must be that players turn.  The move is automatically checked for legality.  If the caller is in multiple games the game id is not optional.  If the
        # move results in a pawn reaching the opponent's back row, a unit for the pawn to be promoted to must be stated
        /move [int: game id] <a-h><1-8>-<a-h><1-8> [Promotion Choice]
    
        # Provides help on all the commands blah blah
        /chess help
    
    
    Options:
    
        # If true, a player will automatically resign a game upon leaving a server
        Resign-On-Disconnect: true/false
    
        # The name of the NPC to use to represent a piece.  If it is set to the name of a non-human NPC, it will use that rather than a player.  Hopefully you don't want to use a person named Creeper
        White-Bishop-Entity: NPC name
        White-Knight-Entity: NPC name
        White-Rook-Entity: NPC name
        White-King-Entity: NPC name
        White-Queen-Entity: NPC name
        White-Pawn-Entity: NPC name
        Black-Bishop-Entity: NPC name
        Black-Knight-Entity: NPC name
        Black-Rook-Entity: NPC name
        Black-King-Entity: NPC name
        Black-Queen-Entity: NPC name
        Black-Pawn-Entity: NPC name
    
        # If true, the game will automatically be a draw if the exact same position occurs three times        
        Draw-3x-Rep: true/false
        
        # If true, allows pawns to capture en-passant
        En-Passant: true/false
    
        # If true, to win a player must capture the king.  As well, check will not be announced and a player can move in a way that doesn't protect their king on check
        Must-Capture-King: true/false
    
    Things I need to figure out still:
    
        # References would be appreciated
        Creating an NPC
        Controlling an NPC/overriding default behaviour (esp. creepers)
        Best way for non-volatile data storage (I don't like the idea of requiring a DB if they don't already have one since there's so little data)
    
    
    Future version ideas:
    
        # For your sanity, you should assume these things will never happen
        Time limits
        Click to move
        Block formations for pieces
        Vote-to-move
        Custom rules/variants (i.e. bug chess, monster chess, etc)
        Ranking
        Game replay/history
        Ascii art powered game monitoring
    
    If anyone has some suggestions for a better name, one of the issues mentioned above, or anything else, I'd appreciate it
     
  2. Offline

    MillerTheBeast

    Fund this...
     
  3. Offline

    Adondriel

    well i have a board already made what we want to do is beable to say this WorldEdit cube is this piece and we want to be able to make that piece. and if it gets killed it goes and floats to the side. if you goto the website in my sig you can look at some pictures we have.
     
  4. You may want to use a WorldEdit craft script. They can easily make the chess board.
     
  5. Offline

    desht

    As it happens, I've been mulling over what it would take for a chess implementation. I haven't got past the ideas stage yet, but here's a rough idea of what I've got so far:
    • Game management (adding players, listing players, tracking game state, score, leaderboards, etc.) should be in a separate plugin that other games could potentially use.
    • Pluggable libraries of pieces, one set can be supplied with the plugin. Size of pieces would define the size of the board tiles needed to play with that set (3x3 piece footprint would really need 5x5 board tiles to look good)
    • Pieces instantiated to "stones" - a stone has an orientation which based on whether it's white or black, and the board orientation, and its material depends on whether it's white or black. The materials used for white/black should also be configurable. Edit: wonder if it's better to use entities or block structures for pieces? Entities might be simpler to manage, but blocks could make for some impressively large chessboards...
    • Boards: created dynamically for a game and then destroyed at the end? Terrain restoration when the board is removed would be desirable - can we use Worldedit to write NBT files? Also, maybe have static boards which can be used for games (plugin would need to track which boards are currently in use). Optional features to include board enclosure (box everything in with glass or something else), lighting, build/breakage protection etc.
    • Persistence - save/load games in-progress. Also cleanly handle players going offline & back on later.
    • The Chesspresso library is probably a very good idea, for maintaining the board model, ensuring positions & moves are valid, etc. Also has some useful routines like FEN loading/saving. Its documentation is not the best, though.
    • UCI support for plugging in external chess engines to play against the computer (though this might be a later addition!)
    • Piece animation effects (slide a piece from one tile to another, knight jumping...) - again maybe for a later version
    • MVC principles probably useful here: internal Chesspresso model, plugin code to implement a view on the game's board, controller will be via /chess commands, or maybe clicking pieces/board tiles.
    Thoughts? Ambitious plugin, I know, but it'll be awesome if ever implemented :)

    Update: mock-up of a block-based chess set that I made with 3x3 pieces & 5x5 board tiles. This is viewed from about 10 blocks above and a few blocks off to the side, using gold & iron blocks for the materials:

    [​IMG]
     
  6. Offline

    nurta

    I originally intended to use living entities for pieces, however from my investigations so far, I've found no good way to kill existing AI so that I can manually control then, which is problematic. Using players would cause some unnecessary lag issues and not being able to supply default initial pieces (with both a name and skin that indicates the piece well) is an issue. So I'm considering going with the block approach instead.

    I originally intended to just use my own engine for maintaining the game and I got most of it set up, but I'm considering ditching that and using an existing engine (such as Chesspresso as you linked) so I also get some additional benefits (multiple annotation formats) and of course have less risk of bugs.

    I'm planning on static boards. The boards themselves would be built by whoever and added to the system by an admin or mod and then a player who is looking for a game can get a listing of nearby boards. I may also add some basic board generation capabilities.
     
  7. Offline

    bennyty

    How about spawning a glass box containing an entity to represent pieces.
     
  8. Offline

    desht

Thread Status:
Not open for further replies.

Share This Page