Skip to content

Instantly share code, notes, and snippets.

@dylnuge
Created July 26, 2012 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dylnuge/3181094 to your computer and use it in GitHub Desktop.
Save dylnuge/3181094 to your computer and use it in GitHub Desktop.
Really basic dict-based board
#! /usr/bin/python
class Board:
def __init__(self):
self.board = {}
def add_to_board(self, item, position):
# Simple function, adds something to the board at position
# where position is a tuple, returns True if add is successful
if get_item_at(position) == None:
self.board[position] = item
return True
else:
return False
def get_item_at(self, position):
# Return object or None
if position in self.board:
return self.board[position]
else:
return None
def remove_item_at(self, position):
# Stupid remove. Fails silently
if position in self.board:
del self.board[position]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment