-
-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
Desktop Application/Basic/Python/US_State_Game/50_states.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
state,x,y | ||
Alabama,139,-77 | ||
Alaska,-204,-170 | ||
Arizona,-203,-40 | ||
Arkansas,57,-53 | ||
California,-297,13 | ||
Colorado,-112,20 | ||
Connecticut,297,96 | ||
Delaware,275,42 | ||
Florida,220,-145 | ||
Georgia,182,-75 | ||
Hawaii,-317,-143 | ||
Idaho,-216,122 | ||
Illinois,95,37 | ||
Indiana,133,39 | ||
Iowa,38,65 | ||
Kansas,-17,5 | ||
Kentucky,149,1 | ||
Louisiana,59,-114 | ||
Maine,319,164 | ||
Maryland,288,27 | ||
Massachusetts,312,112 | ||
Michigan,148,101 | ||
Minnesota,23,135 | ||
Mississippi,94,-78 | ||
Missouri,49,6 | ||
Montana,-141,150 | ||
Nebraska,-61,66 | ||
Nevada,-257,56 | ||
New Hampshire,302,127 | ||
New Jersey,282,65 | ||
New Mexico,-128,-43 | ||
New York,236,104 | ||
North Carolina,239,-22 | ||
North Dakota,-44,158 | ||
Ohio,176,52 | ||
Oklahoma,-8,-41 | ||
Oregon,-278,138 | ||
Pennsylvania,238,72 | ||
Rhode Island,318,94 | ||
South Carolina,218,-51 | ||
South Dakota,-44,109 | ||
Tennessee,131,-34 | ||
Texas,-38,-106 | ||
Utah,-189,34 | ||
Vermont,282,154 | ||
Virginia,234,12 | ||
Washington,-257,193 | ||
West Virginia,200,20 | ||
Wisconsin,83,113 | ||
Wyoming,-134,90 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# US States Game | ||
|
||
This is a simple interactive game that challenges players to name all 50 states of the United States. The game uses the `turtle` graphics module to display the map and the `pandas` library to handle the state data. | ||
|
||
## Features | ||
|
||
- Displays a map of the United States. | ||
- Allows users to input state names. | ||
- Keeps track of correctly guessed states. | ||
- Exits the game and saves the list of missing states to a CSV file if the user chooses to exit. | ||
|
||
## Requirements | ||
|
||
- Python 3.x | ||
- `turtle` module | ||
- `pandas` module | ||
|
||
## How to Play | ||
|
||
1. Run the game. | ||
2. A map of the United States will appear. | ||
3. Enter the names of the states one by one. | ||
4. The game will keep track of the states you have correctly guessed. | ||
5. Type "Exit" to stop the game and save the list of states you missed to `missing_states.csv`. | ||
|
||
## Setup | ||
|
||
1. Ensure you have Python installed on your machine. | ||
2. Install the required modules if you don't already have them: | ||
```bash | ||
pip install pandas | ||
``` | ||
3. Download or clone the repository to your local machine. | ||
|
||
## Running the Game | ||
|
||
1. Ensure you have the necessary files in the same directory: | ||
- `main.py` (the main game script) | ||
- `blank_states_img.gif` (the map image file) | ||
- `50_states.csv` (the CSV file containing state names and coordinates) | ||
|
||
2. Run the game: | ||
```bash | ||
python main.py | ||
``` | ||
|
||
## CSV File Format | ||
|
||
The `50_states.csv` file should have the following columns: | ||
- `state`: The name of the state. | ||
- `x`: The x-coordinate for the state's position on the map. | ||
- `y`: The y-coordinate for the state's position on the map. | ||
|
||
Example: | ||
```csv | ||
state,x,y | ||
Alabama,139,-77 | ||
Alaska,-203,-226 | ||
... | ||
``` | ||
## Contributor | ||
|
||
<table> | ||
<tr> | ||
<td align="center"> | ||
<a href="https://github.com/sahuf2003" target="_black"> | ||
<img src="https://github.com/sahuf2003.png" width="150px;" alt="Sahuf Shaikh"/> | ||
<br /> | ||
<sub><b>Sahuf Shaikh</b></sub></a> | ||
</td> | ||
|
||
|
||
</tr> | ||
</table> | ||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import turtle | ||
from turtle import Screen | ||
import pandas | ||
|
||
|
||
screen = Screen() | ||
image = "blank_states_img.gif" | ||
screen.addshape(image) | ||
turtle.shape(image) | ||
|
||
|
||
data = pandas.read_csv("50_states.csv") | ||
state_data = data.state.to_list() | ||
|
||
guessed_states = [] | ||
|
||
while len(guessed_states) < 50: | ||
answer = screen.textinput(title=f"Your score is {len(guessed_states)}/50", prompt="Name another state:").title() | ||
|
||
if answer is None: | ||
break | ||
|
||
if answer == 'Exit': | ||
missing_states = [state for state in state_data if state not in guessed_states] | ||
new_data = pandas.DataFrame(missing_states) | ||
new_data.to_csv("missing_states.csv") | ||
break | ||
|
||
if answer in state_data and answer not in guessed_states: | ||
guessed_states.append(answer) | ||
t = turtle.Turtle() | ||
t.penup() | ||
t.hideturtle() | ||
state = data[data.state == answer] | ||
t.goto(int(state.x.iloc[0]), int(state.y.iloc[0])) | ||
t.write(answer) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters