Skip to content
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

New Game: Chess Golf #27

Open
5 of 8 tasks
donkirkby opened this issue Dec 9, 2023 · 5 comments
Open
5 of 8 tasks

New Game: Chess Golf #27

donkirkby opened this issue Dec 9, 2023 · 5 comments

Comments

@donkirkby
Copy link
Owner

donkirkby commented Dec 9, 2023

Same movement mechanic as #20 Neighbour Chess, but as a puzzle race game. Are Neighbour Chess and Chess Golf too similar to include both?

  • Add rules.
  • Add some examples.
  • Add pieces back before dealing.
  • Dealer chooses par 2, 3, or maybe 4 by dealing more cards.
  • If a colour has no legal moves, then you may make a king move with any piece of that colour.
  • Generate interesting problems to solve.
  • Reduce memory usage in GolfGraph, or dump state to a db.
  • Simulate a bunch of games, and give quartile scores as targets for solitaire play.
@donkirkby donkirkby pinned this issue Dec 9, 2023
donkirkby added a commit that referenced this issue Dec 9, 2023
donkirkby added a commit that referenced this issue Dec 10, 2023
@donkirkby
Copy link
Owner Author

  • Try switching to capturing pieces.
  • Check for colour with no neighbours, add highest rank off board next to highest rank on board.
  • Deal over captured card.
  • For back 9, add pieces in any order, in first square w/ no neighbours of same colour.

@donkirkby
Copy link
Owner Author

Try putting pieces back before dealing, and add the option of dealing more cards to make it harder.

donkirkby added a commit that referenced this issue Dec 24, 2023
Add display and repr methods.
@donkirkby
Copy link
Owner Author

start_text = dedent("""\
    . . . R . . b .
    . Q . . . K . N
    . . . R . . . .
    b . . . . . n .
    N . . . . . . B
    . . . n . . k .
    . B . . q . . r
    . r . . . . . .
    chosen: bb""")

start_state = GolfState(start_text)
graph = GolfGraph()
tracemalloc.start()

try:
    graph.walk(start_state, size_limit=50_000)
finally:
    snapshot = tracemalloc.take_snapshot()
    display_top(snapshot)

Produced this report:

Top 3 lines
#1: chess-kit/golf.py:67: 16280.9 KiB
    return '\n'.join(sections)
#2: classes/digraph.py:709: 10447.5 KiB
    datadict.update(attr)
#3: classes/digraph.py:711: 5775.9 KiB
    self._pred[v][u] = datadict
56 other: 35030.2 KiB
Total allocated size: 67534.5 KiB

@donkirkby
Copy link
Owner Author

After converting nodes from a text display to compact bytes, I still can't get beyond depth 5 with a breadth-first search. Last report was 1.5 million nodes before oom killer struck.

Here's the previous test after converting to compact bytes:

Top 3 lines
#1: classes/digraph.py:709: 10890.9 KiB
    datadict.update(attr)
#2: classes/digraph.py:711: 7965.6 KiB
    self._pred[v][u] = datadict
#3: classes/digraph.py:708: 5809.2 KiB
    datadict = self._adj[u].get(v, self.edge_attr_dict_factory())
57 other: 38197.3 KiB
Total allocated size: 62863.2 KiB

@donkirkby
Copy link
Owner Author

Compressing move descriptions made very little difference.

Top 3 lines
#1: classes/digraph.py:709: 10890.9 KiB
    datadict.update(attr)
#2: classes/digraph.py:711: 7965.6 KiB
    self._pred[v][u] = datadict
#3: classes/digraph.py:708: 5809.2 KiB
    datadict = self._adj[u].get(v, self.edge_attr_dict_factory())
57 other: 36568.5 KiB
Total allocated size: 61234.3 KiB

donkirkby added a commit that referenced this issue Jan 4, 2024
@donkirkby donkirkby unpinned this issue Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant