Skip to content

Commit

Permalink
fixes to config and setup for material test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chesslogic committed Jun 22, 2024
1 parent b876f47 commit 20d6404
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
6 changes: 3 additions & 3 deletions worlds/checksmate/Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class FairyChessPawns(Choice):
option_vanilla = 0
option_mixed = 1
option_berolina = 2
default = 1
default = 0


class MinorPieceLimitByType(NamedRange):
Expand Down Expand Up @@ -386,7 +386,7 @@ class LockedItems(ItemDict):
display_name = "Locked Items"


class DeathLink(DeathLink):
class Deathlink(DeathLink):
"""
Whenever you are checkmated or resign (close the game window), everyone who is also on Death Link dies. Whenever
you receive a Death Link event, your game window closes. (You cannot undo or review.)
Expand Down Expand Up @@ -417,7 +417,7 @@ class CMOptions(PerGameCommonOptions):
queen_piece_limit: QueenPieceLimit
pocket_limit_by_pocket: PocketLimitByPocket
locked_items: LockedItems
death_link: DeathLink
death_link: Deathlink


piece_type_limit_options: dict[str, Callable[[CMOptions], Option]] = {
Expand Down
7 changes: 0 additions & 7 deletions worlds/checksmate/Presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
# Standard Chess pieces, moving in standard Chess ways, allowing many combinations of material.
# Leaves unique features and mixed material on, but all pieces will be recognizable.
"No Dumb Pieces": {
"early_material": EarlyMaterial.option_off,

"fairy_chess_pieces": ['FIDE'],
"fairy_chess_pawns": FairyChessPawns.option_vanilla,

# TODO: Set the rest to defaults. Is this necessary? I feel like they should just be... defaults, unless the
# player changes them.
},

# A vanilla army with no pockets, comprising 2 Bishops+Knights+Rooks, and 1 Queen (or Rook until upgraded)
Expand Down
6 changes: 6 additions & 0 deletions worlds/checksmate/Rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ def determine_difficulty(opts: CMOptions):
if opts.fairy_chess_pawns.value == opts.fairy_chess_pawns.option_mixed:
difficulty *= 1.05
fairy_pieces = opts.fairy_chess_pieces.value
if opts.fairy_chess_piece_collection.value == opts.fairy_chess_piece_collection.option_fide:
fairy_pieces = [0]
elif opts.fairy_chess_piece_collection.value == opts.fairy_chess_piece_collection.option_betza:
fairy_pieces = [0, 1, 2, 3]
elif opts.fairy_chess_piece_collection.value == opts.fairy_chess_piece_collection.option_full:
fairy_pieces = [0, 1, 2, 3, 4, 5]
difficulty *= 0.99 + (0.01 * len(fairy_pieces))
# difficulty *= 1 + (0.025 * (5 - self.options.max_engine_penalties))

Expand Down
18 changes: 12 additions & 6 deletions worlds/checksmate/test/TestMaterialState.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
from . import CMTestBase
from .. import determine_difficulty, CMOptions


class MaterialStateTestBase(CMTestBase):
def setUp(self):
self.options["early_material"] = 0
super().setUp()

# this class ultimately isn't trying to test this relatively simple function
self.difficulty = determine_difficulty(self.options)

# this is mostly to demonstrate that collect fundamentally acquires the items and to show that setUp sets up
self.assertEqual(0, self.multiworld.state.prog_items[self.player]["Progressive Pawn"])
self.assertEqual(0, self.multiworld.state.prog_items[self.player]["Material"])
self.collect_all_but("Progressive Pocket Gems", self.multiworld.state)
Expand All @@ -21,17 +27,17 @@ class TestSimpleMaterial(MaterialStateTestBase):
"""
def test_no_options(self):
past_material = self.multiworld.state.prog_items[self.player]["Material"]
self.assertLessEqual(4050, past_material)
self.assertGreaterEqual(4650, past_material)
self.assertLessEqual(4050 * self.difficulty, past_material)
self.assertGreaterEqual(4650 * self.difficulty, past_material)


class TestCyclicMaterial(MaterialStateTestBase):
"""Removes all material, then adds it back again. This tests remove() via sledgehammer method"""
def test_no_options(self):
past_material = self.multiworld.state.prog_items[self.player]["Material"]
self.assertEqual(past_material, self.multiworld.state.prog_items[self.player]["Material"])
self.assertLessEqual(4050, past_material)
self.assertGreaterEqual(4650, past_material)
self.assertLessEqual(4050 * self.difficulty, past_material)
self.assertGreaterEqual(4650 * self.difficulty, past_material)

for item in list(self.multiworld.state.prog_items[self.player].keys()):
self.remove_by_name(item)
Expand All @@ -46,8 +52,8 @@ def test_no_options(self):
def test_backward(self):
past_material = self.multiworld.state.prog_items[self.player]["Material"]
self.assertEqual(past_material, self.multiworld.state.prog_items[self.player]["Material"])
self.assertLessEqual(4050, past_material)
self.assertGreaterEqual(4650, past_material)
self.assertLessEqual(4050 * self.difficulty, past_material)
self.assertGreaterEqual(4650 * self.difficulty, past_material)

items = list(self.multiworld.state.prog_items[self.player].keys())
items.reverse()
Expand Down
1 change: 0 additions & 1 deletion worlds/checksmate/test/TestPieceLimits.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def world_setup(self):
self.POTENTIAL_CHILDREN = self.world.PieceLimitCascade.POTENTIAL_CHILDREN

def assert_matches(self, expected_minors: int, expected_majors: int, expected_queens: int):
self.assertTrue(self.options["min_material"] >= 39)
self.assertEqual(0, self.world.find_piece_limit("Progressive Pawn", self.NO_CHILDREN
))
self.assertEqual(expected_minors, self.world.find_piece_limit("Progressive Minor Piece", self.NO_CHILDREN
Expand Down
1 change: 0 additions & 1 deletion worlds/checksmate/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class CMTestBase(WorldTestBase):

def world_setup(self, *args, **kwargs):
self.options["accessibility"] = "minimal"
self.options["min_material"] = 40
super().world_setup(*args, **kwargs)
if self.constructed:
self.world = self.multiworld.worlds[self.player] # noqa

0 comments on commit 20d6404

Please sign in to comment.