Git Product home page Git Product logo

swiftchess's People

Contributors

sochalewski avatar stevebarnegren avatar yixiang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swiftchess's Issues

Reset Game

First of all, your project is really impressive. Thank you for sharing it.

Secondly, if I wanted to add a reset entire game feature to the GameViewController how would you recommend going about that?

I've tried a few different things but I think I am quite close now, but can't seem to figure out why it's not working.

I decided to use your persistence feature to reset the game. When the game is initially set I saved the dictionaryRepresentation of the game in a variable, so that when I reset the game I could do game = ChessGame(dictionary: startGameRepresentation), but that did not work. So i decided to reinitialize the game with a human and AI Player (the only scenario I want) and set the current player to the human player.

After that I remove all the pieces from the board and then setup the game again with the code that you've written in your viewDidLoad(). I then use the code you set up in viewDidLayoutSubviews to layout the pieces, but once that happens I cannot move any pieces. I can click on a piece and the square behind it gets highlighted in red, but I cannot then move the piece.

The problem I'm facing now is that guard let player = game.currentPlayer as? Human else { return } always returns in the touchedSquareAtIndex delegate function

My current code is as follows

fileprivate func setupGame() { //Copy of your viewDidLoad code
	// Add initial piece views
	for location in BoardLocation.all {

		guard let piece = game.board.getPiece(at: location) else {
			continue
		}

		addPieceView(at: location.x, y: location.y, piece: piece)
	}

	// Activity Indicator
	activityIndicator.hidesWhenStopped = true

	// Update castle buttons visibility
	updateCastleButtonsVisibility()

}

func reset() {
	let whitePlayer = Human(color: .white)
	let blackPlayer = AIPlayer(color: .black, configuration: AIConfiguration(difficulty: gameDifficulty ?? AIConfiguration.Difficulty.medium))
    game = ChessGame(firstPlayer: whitePlayer, secondPlayer: blackPlayer)
	game.currentPlayer = whitePlayer
	boardView.subviews.forEach { (v) in
		v.removeFromSuperview()
	}
	pieceViews = []
	setupGame()

	layoutPieces()
}

fileprivate func layoutPieces() { //Copy of your layouting code in viewDidLayoutSubviews()
	// Layout pieces
	for pieceView in pieceViews {

		let gridX = pieceView.location.x
		let gridY = 7 - pieceView.location.y

		let width = boardView.bounds.size.width / 8
		let height = boardView.bounds.size.height / 8

		pieceView.frame = CGRect(x: CGFloat(gridX) * width,
								 y: CGFloat(gridY) * height,
								 width: width,
								 height: height)
	}
}

Past that I can't seem to find why I can no longer interact with the game. Any help would be greatly appreciated.

Once again, thanks for the great repo.

Alan

Multi player

Hi
How can we code multi player for this game?
(Two Phones).

Timer

Hi
Can you please add a timer for the chess board?

Really appreciate your work.

thanks

undo options

I want to add undo options, guide me on how to do undo?

Levels

Hi,
How can we change Game levels?
Like easy, Medium, Hard.
Please tell us.

Thanks lot.

Some time moves not working.

Moving g6 to e7 not working with Piece.PieceType.knight

Please help me

piece :Piece(type: SwiftChess.Piece.PieceType.knight, color: SwiftChess.Color.black, tag: Optional(0), hasMoved: false, canBeTakenByEnPassant: false, location: SwiftChess.BoardLocation(index: 0)), location: BoardLocation(index: 52)
Piece is unable to move to this location
Simulator Screen Shot - iPhone 11 - 2019-10-17 at 12 40 07

PGN Parser

How to use SwifChess with predefine PGN?

add legal moves?

Is there a painless way to display a green circle on the board to show legal moves once a piece is touched?

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.