Git Product home page Git Product logo

c-hess's Introduction

C-HESS

What is C-HESS?

C-HESS is a terminal application with a pseudo-GUI that allows you to play chess alone and online via tcp/ip socket communication.

game preview

How to install and run C-HESS:

To install and run C-HESS, first download the code in the repo by clicking the green button "code" and then the button "download zip".

code button location download button location

Once the source code is downloaded, before running the application, make sure the gcc compiler is installed on your computer (if you're on a UNIX-based system you most likely won't have to worry about it). Assuming now that the latter hypothesis is satisfied, let's see how to actually run the application.

Run single player C-HESS:

In order to run single player C-HESS, whilst in the terminal, move to the directory /code inside the downloaded source code. Once you're there, run the following command

make

If the command doesn't work (i.e if makefile doesn't work on the target computer for some reason), then just copy the following line to compile the program into an executable (yes it's pretty long).

gcc bishop.c chess.c movePieces.c printBoard.c tower.c calculateMoves.c methods.c king.c queen.c checkmate.c knight.c pawn.c printMenu.c moveCounters.c -o chess

You should now have a binary compiled version of the program in your directory, regardless of the approach you took for the last step. If that is the case, then just type

./chess

in the terminal and you should be ready to go. You should now see the application main menu in the terminal

Menu page

Run multiplayer C-HESS:

The process for compiling the source code of the multiplayer version of the game is very similar, however when it comes to running it some things will change. We start again by moving inside the directory "onlineChess". Here we will then run

make

as before. This time, however, make will compile the source code into two different executables, one named "client" and one named "server". Again, if makefile doesn't work, you can copy-paste the following two lines in the terminal to compile the two executables:

gcc bishop.c methods.c server3.c movePieces.c printBoard.c tower.c calculateMoves.c king.c queen.c checkmate.c knight.c pawn.c printMenu.c -o server
gcc bishop.c methods.c client3.c movePieces.c printBoard.c tower.c calculateMoves.c king.c queen.c checkmate.c knight.c pawn.c printMenu.c -o client

As the names suggest, the server will have to run the server binary file and the client will have to run the client one. In particular, the server needs to run the server executable and specify the port on which will listen for connections:

./server "port number"

While the client will have to run the client executable and specify the IP address of the machine where the server process holds, alongside with the port on which said machine is listening

./client "ip address" "port number"

You are now ready to play online chess in your terminal via TCP/IP socket, enjoy! game preview

How to move pieces:

As of now, only the following positional convention is supported: any piece on the board is represented by an ordered couple of positive integers [row,column]: both of them range between 0 and 7. In order to move a piece from a point to another, we use the following syntax:

xy x'y'

where x is the initial row, y is the inital column, x' is the ending row and y' is the ending column. Let's make an example: suppose we have the board

			 	 |♜ ||♞ ||♝ ||♛ ||♚ ||♝ ||♞ ||♜ |
			 	 |♟ ︎||♟ ︎||♟ ︎||♟ ︎||♟ ︎||♟ ︎||♟ ︎||♟ ︎|
			 	 |  ||  ||  ||  ||  ||  ||  ||  |
			 	 |  ||  ||  ||  ||  ||  ||  ||  |
			 	 |  ||  ||  ||  ||  ||  ||  ||  |
			 	 |  ||  ||  ||  ||  ||  ||  ||  |
			 	 |♙ ||♙ ||♙ ||♙ ||♙ ||♙ ||♙ ||♙ |
			 	 |♖ ||♘ ||♗ ||♕ ||♔ ||♗ ||♘ ||♖ |

and we want to move the 4th black pawn 2 units forwards. As we said earlier, the pawn is univocally determined by a couplet [row,column]. In this case row = 6 because our pawn is a distance of 6 blocks away from the top corner of the board, and the column = 3 because the pawn is at a distance of 3 units from the left corner of the board. To move our piece we will then use the command

63 43

The result of this move will be

			 	 |♜ ||♞ ||♝ ||♛ ||♚ ||♝ ||♞ ||♜ |
			 	 |♟ ︎||♟ ︎||♟ ︎||♟ ︎||♟ ︎||♟ ︎||♟ ︎||♟ ︎|
			 	 |  ||  ||  ||  ||  ||  ||  ||  |
			 	 |  ||  ||  ||  ||  ||  ||  ||  |
			 	 |  ||  ||  ||♙ ||  ||  ||  ||  |
			 	 |  ||  ||  ||  ||  ||  ||  ||  |
			 	 |♙ ||♙ ||♙ ||  ||♙ ||♙ ||♙ ||♙ |
			 	 |♖ ||♘ ||♗ ||♕ ||♔ ||♗ ||♘ ||♖ |

License

MIT

Code of conduct

Code of conduct

c-hess's People

Contributors

hsnborn22 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

imagineeeinc

c-hess's Issues

build issue

╭─    ~/Dev/Test/C-HESS/onlineChess    main ······ ✔  01:56:25 am  ─╮
╰─ make                                                                      ─╯
gcc bishop.c methods.c client3.c movePieces.c printBoard.c tower.c calculateMoves.c king.c queen.c checkmate.c knight.c pawn.c printMenu.c -o client
client3.c:70:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
}
^
1 warning generated.
checkmate.c:23:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
}
^
1 warning generated.
gcc bishop.c methods.c server3.c movePieces.c printBoard.c tower.c calculateMoves.c king.c queen.c checkmate.c knight.c pawn.c printMenu.c -o server
server3.c:64:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
}
^
1 warning generated.
checkmate.c:23:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
}
^
1 warning generated.

@hsnborn22 Those warning appears if I'd build it with the makefile

Create simple shell scripts in order to compile the code

@hsnborn22 I saw in your README that the user has to write long terminal commands. Wouldn‘t it be better if there‘s a simple script the user has to run in order to compile the code and run the compiled executable.

I can try writing a shell script for that. Could you please assign this issue to me?

Best regards
NH

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.