-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pla 982 add bestemshe #185
Changes from all commits
246468a
6e3fd15
e931425
f647b5e
5475d9c
2b65d97
23c42bb
1ebc712
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package strategygames.togyzkumalak | ||
package variant | ||
|
||
import strategygames.togyzkumalak._ | ||
import strategygames.{ GameFamily, Player } | ||
|
||
case object Bestemshe | ||
extends Variant( | ||
id = 2, | ||
key = "bestemshe", | ||
name = "Bestemshe", | ||
standardInitialPosition = false, | ||
boardSize = Board.Dim5x2 | ||
) { | ||
|
||
def gameFamily: GameFamily = GameFamily.Togyzkumalak() | ||
|
||
def perfIcon: Char = '' | ||
def perfId: Int = 401 | ||
|
||
override def baseVariant: Boolean = false | ||
|
||
override def canOfferDraw = false | ||
|
||
// cache this rather than checking with the API everytime | ||
override def initialFen = | ||
format.FEN("5S,5S,5S,5S,5S/5S,5S,5S,5S,5S 0 0 S 1") | ||
|
||
override def usesTuzdik = false | ||
|
||
override def specialEnd(situation: Situation) = | ||
(situation.board.history.score.p1 > 25) || | ||
(situation.board.history.score.p2 > 25) || | ||
(situation.moves.size == 0) | ||
|
||
// shouldn't happen from starting fen as scores have to always be even so 25=25 is not possible | ||
override def specialDraw(situation: Situation) = | ||
situation.board.history.score.p1 == situation.board.history.score.p2 | ||
|
||
override def winner(situation: Situation): Option[Player] = | ||
if (specialEnd(situation) && !specialDraw(situation)) { | ||
if (situation.board.history.score.p1 > situation.board.history.score.p2) | ||
Player.fromName("p1") | ||
else Player.fromName("p2") | ||
} else None | ||
|
||
} |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -5,6 +5,7 @@ import org.specs2.matcher.ValidatedMatchers | |||
import org.specs2.mutable.Specification | ||||
|
||||
import strategygames.backgammon.format.Uci | ||||
import strategygames.backgammon.variant.Variant | ||||
|
||||
class BackgammonTest extends Specification with ValidatedMatchers { | ||||
|
||||
|
@@ -13,9 +14,13 @@ class BackgammonTest extends Specification with ValidatedMatchers { | |||
vg.flatMap { g => g.apply(action).map(_._1) } | ||||
} | ||||
|
||||
def playActionStrs(actionStrs: List[String], game: Option[Game] = None): Validated[String, Game] = | ||||
def playActionStrs( | ||||
actionStrs: List[String], | ||||
game: Option[Game] = None, | ||||
variant: Option[Variant] = None | ||||
): Validated[String, Game] = | ||||
playUciList( | ||||
game.getOrElse(Game.apply(variant.Backgammon)), | ||||
game.getOrElse(Game.apply(variant.getOrElse(Variant.default))), | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a difference here between writing Game.apply(<some_param>) and Game(<some_param>) ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both
Despite that being my personal preference, I don't think this standard is followed throughout the codebase and I have no problem with you doing either approach |
||||
Uci.readList(actionStrs.mkString(" ")).getOrElse(List()) | ||||
) | ||||
|
||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't you want to change this to false ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured best to leave this clause in (which wont be triggered with regular Bestemshe) but when we get to the point where we are offering FromPosition for all variants then it could be possible to create a position (fen) where the scores start as odd and so a draw is possible. if i remove this code then i think it will just look in
winner
and award p2 as a winner in these 'tie' situations.