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

Kk simplify setup #2

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ test_isolated.py
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/*.global.yml

.venv/
__pycache__/
host_game.bat
46 changes: 34 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,41 @@ creating games and sending moves to each other without exposing their inner logi
# Client Setup - Needed to create and join games

- Install requirements with `pip install -r requirements_client.txt`
- Bring in your `submission.py` from the assignment, modify it to import Board from server_isolation.
- Modify variables in client_config.py
- Import your bot from the assignment and set it to DEFAULT_PLAYER_CLASS.
- Host a game with `python client.py --host --name <your name> --time_limit <time_limit (s)>`
- Bring in your `submission.py` from the assignment.
- Optionally, modify variables in client_config.py
- Change the name/import of your bot **if** it's something other than `CustomPlayer`
- Change the `DEFAULT_PLAYER_NAME` if you'd like your display name to be something other than your os username

- Host a game with `python client.py --host`
- This will give you an ID you can send to someone to join, or that someone can read on Discord.
- Some other options:
- `--start_board <start_board>`: The board to start the game with. Can be "DEFAULT", "CASTLE", or a JSON string of an NxM array of spaces and X's
- `--secret`: If toggled, your code won't be posted on Discord. Good if you want someone specific to join.
- `--no_discord`: If toggled, your game won't be broadcast on Discord.
- `--num_random_turns <num_random_turns>`: If set, the game will start with agents making N random moves in the beginning
- `--num_rounds <num_rounds>`: If set, the game will play N rounds of the game with the same settings
- `--player_to_use <player_namee>`: If set, the game will use the player set in client_config.py with that name, instead of the DEFAULT_PLAYER_CLASS
- Join a game with `python client.py --join --name <name> --game_id <game_id>`
<details>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't showing up in the markdown preview. Maybe use markdown syntax?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure you can make a collapsible section with just markdown syntax; I think html is required. We can revert to just a list without the collapse/expand. You can also see the result in the main page of my branch

<summary>Some other <b>optional</b> flags</summary>
<ul>
<li>
<code>--name &ltname&gt</code>: Display name to use, defaults to logged in os username
</li>
<li>
<code>--start_board &ltstart_board&gt</code>: The board to start the game with. Can be "DEFAULT", "CASTLE", or a JSON string of an NxM array of spaces and X's
</li>
<li>
<code>--secret</code>: If toggled, your game ID won't be posted on Discord. Good if you want someone specific to join.
</li>
<li>
<code>--no_discord</code>: If toggled, your game won't be broadcast on Discord.
</li>
<li>
<code>--num_random_turns &ltnum_random_turns&gt</code>: If set, the game will start with agents making N random moves in the beginning
<li>
<code>--num_rounds &ltnum_rounds&gt</code>: If set, the game will play num_rounds rounds of the game with the same settings
</li>
<li>
<code>--player_to_use &ltplayer_name&gt</code>: If set, the game will use the player set in client_config.py with that name, instead of the DEFAULT_PLAYER_CLASS
</li>
</ul>
</details>

- Join a game with `python client.py --join --game_id <game_id>`
- optionally add `--name <name>` to use a custom display name
- Observe a game with `python client.py --observe --game_id <game_id>` (or just watch on Discord).


Expand Down
2 changes: 1 addition & 1 deletion application.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from flask import request
import random
import json
from server_isolation import Board
from isolation import Board
import constants
from discord_webhook import DiscordWebhook, DiscordEmbed
try:
Expand Down
6 changes: 4 additions & 2 deletions client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# from submission import CustomPlayer
import constants
import client_config
from server_isolation import Board
from isolation import Board
import json
import time
import datetime
Expand All @@ -23,6 +23,8 @@

PING_INTERVAL = 0.5

DEFAULT_USER = client_config.DEFAULT_PLAYER_NAME

def test_run():
player_1_name = 'player1'
player_2_name = 'player2'
Expand Down Expand Up @@ -242,7 +244,7 @@ def observe_game(game_id):
@click.option('--game_id', help='Game ID to join')
@click.option('--start_board', help='Start board (DEFAULT or CASTLE or RANDOM or JSON dumped custom board of spaces and Xs)', default='DEFAULT')
@click.option('--num_random_turns', help='Number of random turns to make at the start', default=0, type=int)
@click.option('--name', help='Your name')
@click.option('--name', help='Your name', default=DEFAULT_USER)
@click.option('--time_limit', default=5, help='Time limit for each move')
@click.option('--discord/--no_discord', help='Whether to replay on class Discord server', default=True, is_flag=True)
@click.option('--secret', help='Whether to announce the game to class Discord server', is_flag=True)
Expand Down
4 changes: 3 additions & 1 deletion client_config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
## Modify these values to match your requirements - you will have to import your player class
from submission import CustomPlayer
from test_players import RandomPlayer
from getpass import getuser

# Do not touch this
BASE_URL = 'http://isolation-dev.us-west-2.elasticbeanstalk.com'
# Change this to your player class
DEFAULT_PLAYER_CLASS = RandomPlayer
DEFAULT_PLAYER_CLASS = CustomPlayer
DEFAULT_PLAYER_NAME = getuser()

# If you want to test multiple player classes, you can add them here and set --player_to_use to the desired player
PLAYER_CLASSES = {
Expand Down
Loading