Skip to content

Commit 204318e

Browse files
author
okhere21@gmail.com
committed
Transforming change into a Recruitment Challenge
1 parent 4131814 commit 204318e

23 files changed

Lines changed: 1077 additions & 507 deletions
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Fix Rummy winner detection
2+
about: Correct the game completion and winner detection logic in the modular Rummy implementation.
3+
title: Fix winner detection and end-of-game flow
4+
labels: bug
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
The current Rummy implementation should end the game as soon as a player has successfully melded and discarded all cards. Review `rummy/game.py` and `rummy/env.py` to ensure that:
10+
- empty hands are recognized as winning states
11+
- invalid actions do not advance the turn or corrupt the deck/discard piles
12+
- the discard pile is restocked when the deck runs out
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Improve meld validation rules
2+
about: Add support for full meld validation and joker handling in the Rummy engine.
3+
title: Improve Rummy meld validation and wildcard rules
4+
labels: enhancement
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
The baseline Rummy engine validates simple melds, but several edge cases remain. Update the validation logic to support:
10+
- impure sets and sequences that use printed Jokers or selected wild ranks
11+
- same-suit sequence construction with wildcard fill cards
12+
- no duplicate cards and correct suit/rank constraints for valid melds
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Design RL-friendly observations and actions
2+
about: Refine the Rummy environment so agents can interact without user prompts.
3+
title: Improve RL environment observation/action design
4+
labels: enhancement
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
The current environment exposes a minimal action API, but there is an opportunity to make it more RL-friendly. Update `rummy/env.py` so that:
10+
- observations include the current hand, wild rank, top discard, and remaining card counts
11+
- actions are encoded as structured dictionaries instead of human input
12+
- invalid actions return a consistent penalty and do not corrupt game state

.github/workflows/python-app.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Python CI
2+
3+
on:
4+
push:
5+
branches: ["main", "master"]
6+
pull_request:
7+
branches: ["main", "master"]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-python@v5
15+
with:
16+
python-version: "3.11"
17+
- name: Install dependencies
18+
run: |
19+
python -m pip install --upgrade pip
20+
python -m pip install pytest
21+
- name: Run tests
22+
run: python -m pytest -q

README.md

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,69 @@
1-
# RUMMY
2-
An attempt to make a simple CLI version of the card game-Rummy.
3-
Another Odd day at College, my hostel neighbor came up to me and gave me a task,"Hey Dude, Can you code Rummy??"
4-
I was like, "Well that's interesting! Lemme give it a try...."
5-
And so we have this!!😁
1+
# Rummy
62

7-
P.S.- I have never really played any card came so if there's any fishy game logic, feel free to raise issues,
8-
suggestions are always welcome.
3+
A modular Python implementation of the classic Rummy card game, refactored for agent-based play and reinforcement-learning experiments.
94

10-
To run the program download the python script, navigate to the downloaded directory and run the following command:<br>
11-
<br>
12-
python rummy.py
5+
This repository turns a single legacy script into an importable package (`rummy/`) with clear separation for:
136

7+
- Card definitions and helpers (rummy/cards.py)
8+
- Deck and discard pile management (rummy/deck.py)
9+
- Game rules and meld validation (rummy/game.py)
10+
- A simple RL-style environment wrapper (rummy/env.py)
11+
- A small random agent example (rummy/agents.py)
12+
13+
Why this project
14+
15+
- Make the Rummy game engine testable and importable for research or challenge tasks.
16+
- Provide a minimal environment API so agents can play without human input.
17+
- Include CI and tests so merges won't regress core behavior.
18+
19+
Quick start (using uv)
20+
21+
All startup, installs and test runs should use the provided uv environment wrapper from this directory.
22+
23+
1. Open a shell in the repository root and change into the RUMMY folder:
24+
25+
cd RUMMY
26+
27+
2. Run tests and install dev deps (example):
28+
29+
uv run python3 -m pip install --upgrade pip
30+
uv run python3 -m pip install pytest
31+
uv run python3 -m pytest -q
32+
33+
3. Run the example entrypoint (small simulation):
34+
35+
uv run python3 Rummy.py
36+
37+
Package usage (importing in code)
38+
39+
- From your Python code you can import the environment and game directly:
40+
41+
from rummy.env import RummyEnv
42+
from rummy.game import RummyGame
43+
44+
- Create an environment and reset to get the first observation:
45+
46+
env = RummyEnv(["Alice", "Bob"], seed=42)
47+
obs = env.reset()
48+
49+
Testing and CI
50+
51+
- The repository contains unit tests under `tests/` that validate deck size, dealing, and meld/sequence validation.
52+
- A GitHub Actions workflow at `.github/workflows/python-app.yml` runs the tests on push and pull requests.
53+
54+
Challenge notes
55+
56+
This repo is intended as a small challenge: some rules and edge cases are intentionally simplified and there are three suggested issues for contributors to improve:
57+
58+
- Fix winner detection and game-end flow
59+
- Improve meld and wildcard validation rules
60+
- Expand the RL observation/action API for agents
61+
62+
Contributing
63+
64+
- Open a PR with targeted changes and include/adjust tests to cover the change.
65+
- The CI workflow will run the test-suite automatically.
66+
67+
License
68+
69+
- This project is provided as-is for educational and challenge purposes. Add a license file if you want to publish it.

0 commit comments

Comments
 (0)