Skip to content

darth-cy/Chess

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chess in the Console

This console game is jointly developed with Rehan Alam. The development process took in total two days.

See a Demo Video

This is the chess game played by two AIs. It shows how AIs move the cursor, and capture pieces when chances are present. Full Fight Here

Sample Screenshot

chess

Development Schedule

Day1:

  • Inheritance hierarchy and cordinates-based control.

Day2:

  • Integrate keypress.rb keystroke detection library into the game.
  • Wrote computer AI that can construct sequence of keystroke moves.

How to Run

  • You need the latest versions of Ruby to run this game.
  • Download the repository and navigate into the directory using command line.
  • Once you are there, run the command $ bundle install.
  • After that's done, run $ ruby lib/chess.rb (You will be asked if you want to load a saved game. Choose n for now. If you want to save a copy of the game, you can do that during the game play using the ESC key).

Development Highlights

  • Serialization: This game uses YAML serialization to preserve a game state. The saved game states are added to the repository and can be later revived on game load.
  • Keystroke Detection: The keypress.rb library translates keyboard actions into bare string representation. The game then take the string and feed it into a case statement to determine appropriate actions.
  • AI that moves the cursor: The AI has an internal queue of commands. When a desirable move is determined, the AI calculate the necessary keystroke steps and push them onto the queue. The AI then shift all commands in sequential order to perform the action.

Future Development Considerations

  • Use nodes to emulate the forsight behavior of normal human players. Each node should have a valid "advantage score" measure. The AI then choose the the node that has the highest advantage scores.
  • Switch to web-based interface. This chess game has Ruby as hard dependencies. It would be nice if it can be translated into a web-based chess interface.

About

Learn polymorphism and user interface

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages