Skip to content

RubyKanima/socha-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Software-Challenge Logo

Read the Docs Socha PyPI PyPI - Python Version Documentation

ペンギンの神 (Pengin no Kami)

Introduction

Each changelog should contain general changes of the bot's behaviour. Furhtermore it should also contain all files, classes, functions and variable changes. Images can be used and should only be used as far as it contributes to the subject. Code examples aren't necessary although they can come in handy for certain runtime discussions and special functionality.

Dress-Code / Formatting

The code should be viewable wihtout any confusion which leads to following rules for formatting:

  • Type declaration

    If not clear, the declaration of variable types are needed.

    i: int = None
    text: str = None
    lists: list = None
    list_in_list: list[list[]] = None
    anything: any = None
    any_class: Class = None
  • Comments

    If you want to take notes on a class or function you can make use of VisualStudios comment features like the following

    class Test():
      ''' This is a `Test` class '''
      def __init__(self, num: int, txt: str, yn: bool):
        '''
        This is the initialization of the `Test` class
    
        Parameters:
          - num: int
          - txt: str
          - yn: bool
        '''

    Example of VisualStudio,hovering over the function

  • Unnesting

    Nesting is describing the excessive use of indents which can be prevented. It mostly occures in multiple if-statements or for-loops

    Unnesting with return

    def return_smaller_int(first_num: int, second_num: int):
      if first_num < second_num:
        return first_num
      else:
        return second_num

    This Code can easily be shortened in multiple ways. The first is intermediate but quite genius; The function will end as soon as a value is returned which leads to this solution:

    def return_smaller_int(first_num: int, second_num: int):
      if first_num < second_num:
        return first_num
      return second_num

    Although it seems a little cheesy, you can completely delete this function because it already exists! Here you could easily use the max() or min() function. And don't worry about your performance; Integrated functions are most likely faster because they're written in C. There are only a few exceptions.

    min(first_num, second_num)

    More Unnesting Tips: Youtube: Why You Shouldn't Nest Your Code

  • Consistency

    Don't use different names for the same variable in different functions and make a function describe itself:

    def evaluate(state: GameState):
      return len(state.possible_moves) - len(state.other_possible_moves) 
    
    def evaluate2(current_state: GameState):
      return len(current_state.opp_moves) - len(current_state.poss_moves)

    You should rather do something like this:

    def delta_current_possible_moves(state: GameState):
      return len(state.possible_moves) - len(state.other_possible_moves)
    
    def delta_other_possible_moves(state: GameState):
      return len(state.other_possible_moves) - len(state.possible_moves)

About

socha client for "penguins, 2022/23, SoftwareChallenge"

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages