Skip to content

Commit

Permalink
Fixed some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveBarnegren committed Oct 19, 2017
1 parent b8ed2b3 commit 8c138eb
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 13 deletions.
14 changes: 5 additions & 9 deletions SwiftChess/Source/AIPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -252,21 +252,19 @@ open class AIPlayer : Player {

let location = pawnsToPromoteLocations.first!

guard let piece = board.getPiece(at: location) else {
guard board.getPiece(at: location) != nil else {
return board
}

// Get the ratings
var bestType = Piece.PieceType.possiblePawnPromotionResultingTypes().first
var bestRating = -Double.greatestFiniteMagnitude
var highestRating = -Double.greatestFiniteMagnitude
var promotedBoard: Board!

for pieceType in Piece.PieceType.possiblePawnPromotionResultingTypes() {

var newBoard = board

guard let piece = newBoard.getPiece(at: location) else {

guard newBoard.getPiece(at: location) != nil else {
return board
}

Expand All @@ -275,9 +273,8 @@ open class AIPlayer : Player {

let rating = ratingForBoard(newBoard)

if rating > bestRating {
bestRating = rating
bestType = pieceType
if rating > highestRating {
highestRating = rating
promotedBoard = newBoard
}

Expand Down Expand Up @@ -310,7 +307,6 @@ internal class BoardRater {

func ratingfor(board: Board, color: Color) -> Double{
fatalError("Override ratingFor method in subclasses")
return 0
}
}

Expand Down
1 change: 0 additions & 1 deletion SwiftChess/Source/ASCIIBoard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

import Foundation
import SwiftChess

func transformASCIIBoardInput(_ input: String) -> String{

Expand Down
2 changes: 1 addition & 1 deletion SwiftChess/Source/Board.swift
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ public struct Board : Equatable {

let location = BoardLocation(x: xPos, y: castleMove.yPos)

if let piece = getPiece(at: location) {
if getPiece(at: location) != nil {
return false
}

Expand Down
1 change: 0 additions & 1 deletion SwiftChess/Source/BoardRaterCenterFourOccupation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class BoardRaterCenterFourOccupation: BoardRater {
let value = Double(1);
var rating = Double(0)

BoardLocation(x: 3, y: 3)
let locations = [
BoardLocation(x: 4, y: 4), // NE
BoardLocation(x: 4, y: 3), // SE
Expand Down
1 change: 0 additions & 1 deletion SwiftChess/Source/PieceMovement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ open class PieceMovementPawn: PieceMovement {
let color = movingPiece.color

// ****** Test forward locations ******
var forwardStrides = [BoardStride]()

// Test one ahead offset
let oneAheadStride = (color == .white ? BoardStride(x: 0, y: 1) : BoardStride(x: 0, y: -1))
Expand Down

0 comments on commit 8c138eb

Please sign in to comment.