Skip to content
Michael Cochez edited this page Jan 6, 2024 · 15 revisions

Can I call "move.suit" to get the suit of a valid move?

A move does not have a suit. The reason is that a move can be a regular move, a trump exchange, and also a marriage. What you can do is get the cards of a move, for example using move.cards. This gives you a list of cards. For the individual cards, you can ask their suit using card.suit.

You can use move.cards[0].suit to find out the suit of a specific card of your move (the first in the list because: [0]).

How can you compare the scores of cards if they are objects and have only the string representation?

The scores themselves are integers. The cards are objects. You can get their score:

from schnapsen.game import SchnapsenTrickScorer
from schnapsen.deck import Card

s = SchnapsenTrickScorer()
points = s.rank_to_points(Card.QUEEN_CLUBS.rank)
print(points)

See How to get a score of a card

What is the meaning of the different games I can play when running executables/cli.py?

game-24

  • will play a game with 24 cards by adding card 9.

game-ace-one

  • In this game the Ace card has a score of 1 point, in comparison to a normal game where the points of an Ace are 11.

ml

  • Commands:
    • create-replay-memory-dataset
      • this will create a dataset of 10k games for your ml bot that will be stored at schnapsen/ML_replay_memories.
    • train-model
      • allows you to train your bot; creates folder ML_models, with python file simple_model.
    • try-bot-game
      • play a game with your ml bot; to execute this command it requires the dataset and a trained model.

notification-game

  • Plays a game with notification_example_bot against rand.

random-game

  • Will show how many games rand won against rand.

rdeep-game

  • Will show how many games rdeep won against rand.

try-example-bot-game

  • Plays a game between the example bot and rand.

How can I get the suit of a card?

If c is a card, its suit is c.suit.

How to get the suit of the card the bot played in the previous turn?

You can at the end of the turn remember which card you played. Next turn you can then look at it.

Do I need to create an extra tournament.py file + code?

Not necessarily, depends what you want to do. You can also modify the functions on cli.py and server.py that are within the executables directory.

How can you compare the scores if they are objects and have only the string representation?

The scores themselves are integers. The cards are objects. You can get their score. See How to get a score of a card

Can I use jupyter notebook for the assignment?

Yes and no. Yes, it is in theory possible to use it. However, it is strongly recommened to use an IDE like VS code to work on this project for various reasons. Also, be reminded that you have to hand in the final assignment as a .py file.

Should I differentiate if we are in Phase 1 or 2 of the game?

That is up to you. Some bots, though, can ONLY work in the second phase of the game (alphabeta,minmmax). So keep that in mind.

When my bot wins, I get the message "winner is <schnapsen.bots.bully.BullyBot object at 0x... > instead of just "BullyBot" how can I fix this?

What is printed is the string representation of the bot, which is shown if you do not specify a name for your bot. You can specify a name for you bot by providing it in the constructor. In your bot, make sure to call the parent constructor like this:

class YourBot(Bot):
    def __init__(self) -> None:
        super().__init__("preferred name for this bot")

How can I check whether the stock in the game is exhausted? How to check whether the talon is empty?

Two ways. Check whether the talon is empty explicitly:

# in get_move
    if perspective.get_talon_size() == 0:
        pass

Or check whether the game is in phase two

from schnapsen.game import GamePhase

# in get_move:
    if perspective.get_phase() == GamePhase.TWO:
        pass
Clone this wiki locally