Git Product home page Git Product logo

gogo's Introduction

Hi there πŸ‘‹

I'm Mathew. I'm a software engineer.

πŸ₯ž Current Tech stack

  • Building with: Ruby-on-Rails, React, Next.js, Node.js
  • Data engineering with: Apache Spark, Databricks, AWS, SQL
  • Deploying with: AWS, CircleCI, Kubernetes

gogo's People

Contributors

mathewtrivett avatar xephz avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

gogo's Issues

isSuicide() does not deal with captures

Currently isSuicide will return true if you are filling in a gap that should result in a capture rather than suicide. eg:

W W B -
W - W B
B W B -
- B - -

Black cannot currently play on (1,1). It should be a legal move that results in the capture of all the white stones.

Code conventions

Modules should be named with lower case or snakeCase if more than one word.

Class names should be capitalised

If...else should be bracketed

Determining Captured Stones

Assuming even individual stones are part of a group.
Loop through each stone in a group and if it has no liberties
i.e. no empty spaces surrounding it then it is captured.

Peer Review Template

@Xephz Thorsten has uploaded a peer review template on Moodle we need to use to describe our contributions to the project.

We need to use this as he's going to process it with python (of course).

My student id is psxmpt, what's yours?

Fonts

Minor point which is easy to fix, but the font directory is currently hardcoded. This does not work across different OSes. The .ttf should be included with the game and loaded from there.

Game Class

  • Left Player - Instance of the Player Class
  • Right Player - Instance of the Player Class (Prevents there being lots of players initiated)

##Β Methods

  • init()
  • calculateScore()

Intro game

For players who don't know how to play you could step through a really simple game and show tooltips for what's going on.

Groups

A single or multiple stones of the same colour connected non-diagonally.

  • colour
  • list / set of coordinates as tuples
  • isVirtual? - Boolean if the group is temporary
  • id - incremented from groups.length

Methods

  • init(colour, coordinate)
  • isInGroup? (coordinate) -> Boolean
  • mergeGroup (group)
  • add group.coordinates to self.coordinates
  • is captured? (if every element of the group has no surrounding spaces)

Board

Board controls the game state, it places stones, removes stones, checks for suicide, checks for empty spaces, checks if a play is on the board, check for contents of square, check for group membership, update group ids.

  • size = int
  • groups = []
  • matrix = []

Methods

  • placeStone
  • getGroup(coordinates) -> group.Id, colour
  • isSuicide?(coordinate)-> Boolean
  • isEmpty?(coordinate) -> Boolean
  • offBoard?(coordinate) -> Boolean
  • playable?(coordinate) -> Boolean
  • printBoard
  • deleteGroup

Start Menu

We could do with a start menu that allows you to select the Board size. Probably best implemented as a UImessage that exists in a main.py (which replaces test.py) and calls matches up. This would also probably need to implement a menu class which can be recreated by match on completion.

Game Description File

As part of our hand in we need to provide a description file explaining the game <= 2 pages. I think in this we should also be including how the code is structured?

We should probably think about defining the structure of this at some point soon, perhaps just with headers and bullets to start?

I think it would be good to try and keep everything in this repository if possible and use git to manage versioning.

Board UI Class

Board UI class, draws the board and board lines.

Variables

  • Divisor - holds the board size plus one.
  • Background - the board's background shape
  • Origin - (0,0) as pixels on the grid
  • Coordinates - list of lists with pixel rules for coordinates on the board
  • Interval - the step between lines,based on the board by size and grid size
  • Line width - sets the line width of the grid

Methods

  • init()
    self.grid = Board.size

  • create()
    Draws the board and board lines.

  • getBoardUICoords(self, coordinates)
    Returns pixel tuple for a given set of coordinates.

Timing

Games of go should have a time limit that counts down for each player and pauses when the game switches to the other player.

Should be able to increment time for each player.

General approach to UI

So I can probably work through the UI over the next few days but I think it would probably good to make some decisions about how all the logic interfaces with the UI and vice versa?

My general thought is that the UI does no logic, UI classes are responsible for:

  • handling user input
  • drawing elements to the screen to represent the match / board state (e.g. timers, current player, groups etc.)
  • displaying messages (e.g. can't go that would be suicide, Ko! etc.)
  • binding ui logic to game logic (e.g. ensuring that 0,0 in the UI corresponds to (0,0) in data)

UI classes will be initialised and called within game logic classes. E.g when a match is initialised, then it will create the game in data but also build the UI

What are your thoughts @Xephz ?

Refactor Group

I think the current method of having virtual classes is a bit hacky and can be brought in line with the method used for potential boards (using deepcopy). This will be cleaner.

Stone UI Class

Stone Ui, displays stone sprites, moves stones around the game board, places stones on the board

Variables

  • colour
  • coordinates
  • isPlaced: Boolean
  • isPlayable: Boolean
  • diameter
  • BoardUi

Methods

  • show () - shows the stone. if is placed is false. Show at lower opacity. If true show at full opacity

  • Move(self, mx, my) - If the stone has not been placed then move the stones coordinates by mx, my based on user input.

  • Place() - if group.isplayable set isPlayable to true and a valid control is given then set the stones coordinates to coordinates and set isPlaced to true

Graphics

So that we can see what's going on with the board, we're going to need to design the visual look / feel of the game. Perhaps we should start with a simple wireframe before sketching up a high fidelity design.

We also need to work out which visual elements need to be included e.g:

  • Stones
  • Stone placement indicator - e.g. 'ghost stone or crosshairs'
  • Last played stone
  • Board
  • Prisoner pots
  • Timers
  • Pass button
  • Resign button
  • Score card / win state

Player Class

Represents a single player.

Variables

Colour - The character representing the players stones.
Prisoners - The number of pieces the player has captured
Time - indicates the ammount of time in seconds that the player has remaining.
Ingame? - potentially if we want to allow for many players we may need to keep track of who is still in the game, although this may be better stored in the game class.

Methods

placeStone(self, board, coordinate): - This will return a boolean to indicate if the stone was placed.
The process will be along the lines of:
-Check move is playable.
-Check for Ko
-Check for merges
-Check for captures - and adjust for prisoners.
hasTime() - returns a boolean indicating if the player is out of time, may not be needed
resign()? - Again may be better stored in the game class. Will reexamine once I start implementing.

I expect that there are more methods that will need to be added to this class.

Messages

It would be nice to add UI messages for KO and no possible moves.

Deleting the 'Project' board in Github

As it seems we're doing pretty well using Issues to track todos and handle discussion, perhaps we should delete the 'Project' view with to do, doing, done boards. It feels superfluous and a distraction?

Territory

Calculating the territory score at the end is more complicated than I had first imagined. It will take a little bit of research and time for me to sort.

PlayerUI

Variables

  • isCurrent: Boolean
  • colour
  • time

Error Messages

It would be helpful to implement Error messages / console logs in the event of errors so the play can know why there was a problem.

Fun fun

Massive multi player mode

Cats vs dolphins mode

Timer fun: getting more time with each play, if you capture a big group you lose the equivalent in time, or time speeds up or slows down as the game progresses

Flash Messages UI

We want to be able to display messages during the game to a player, when the player clicks on the message it should disappear and they should be able to resume play.

One option would be to have a list of messages, when a state is triggered, create a message and add to the list. When the user clicks on the message fire messages.remove(message) removing its reference.

Messages

State: isSuicide
Message: Can't play there...that would be suicide!!!
Action: Remove Message

State: Ko
Message: Can't play...that's Ko..we might end up in a loop.
Action: Remove Message

State: noPlayableMoves
Message: There is nowhere to go. You are completely surrounded.
Action:


**Game End** This should actually be an Element with a two buttons.

new_game_button

State: gameEnd
Message: Another Game?.
Action: Should create a new match and launch the matchloop

quit_button

State: gameEnd
Message: Quit.
Action: Should return to the 'Start Screen'

Match Class

Variables

players[] - a list of the players in the match, given as a list so as to not limit the number of players when we look at experimenting with game mechanics.
currentPlayer - an intiger indicating the index in the players list of whose turn it is.
board - the board on which the match is being played
previousBoard - a matrix representing the previous state, used for indentifying ko
currentboard - tracked just to pass to previous board

Methods

playTurn() - The main loop in which the process a turn is evaluated
matchLoop()

Merging branches

I think it would probably make sense to merge the board and group branches into some kind of core game logic branch, rather than have separate branches for each class. Thoughts?

Snap to Grid

When a player is choosing where to place a stone their stone should snap to grid positions.

Button UI

Button UI, builds buttons, handles button actions in response to button state

Variables

  • text - String for the button's text
  • parent - parent Object
  • background -
  • border
  • textcolour
  • font
  • states - hover, active
  • action
  • width
  • height
  • x, y

Methods

  • init
  • onclick()
  • onhover()

UISounds

Sound is important in Go, the placing of stones is encouraged to make a 'click' noise when playing for real and so we should include sounds as part of GamePlay.

I'm going to create a UISounds class that:

  • Inits a pygame.Mixer to load and playback different types of sounds.

stone_placed_sound = UISound(soundsDir)
stones_captured_sound = UISound(soundsDir)

Methods

  • UISounds.update()
    Will select a random file from the given directory, create a Sound object and play it back.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.