Skip to content

Latest commit

 

History

History
102 lines (76 loc) · 2.29 KB

README.md

File metadata and controls

102 lines (76 loc) · 2.29 KB

Introduction

Python is a general purpose language that allows one to easily model the game state of common game types

Topics

  • Boards
    • 2D grid A simple representation of a 2D grid board that can be used for games like tic-tac-toe or checkers
    • Tic-tac-toe board A board based on a 2D Grid that is specialized for the rules of tic-tac-toe
  • Cards
    • Card deck A collection of cards that can be shuffled and dealt
    • Card deck factory A simplified way to construct various types of card decks
    • Playing card A representation of a standard playing card
  • Clients
  • Other

Rubik's Cube Simulator

Run the simulator using an input file with a list of moves.

% cd gmaes/rubiks_cube
% python3 rubiks-cube-2x2.py --input moves-1.txt 

Start
G G
G G

U
R R
G G

R
R Y
G Y

R
R B
G O

D
R B
O O

D
R B
R B

L
W B
W B

U
R R
W B

U
G W
W B

End

Game Client Usage

Game clients are interactive programs that allow you to change the game world state. Running each game client is usually just a matter of running a particular Python file but additional details are provided below.

Tic-tac-toe Client

Run the client with the command ./games/game_clients/tic_tac_toe_client.py This will start an interactive CLI client to make plays and view the board. The commands available include:

Commands: 
play m,n        Current player makes a play at position m,n
board           Shows the current state of the board
restart         Restart the game
help            Print list of commands
exit            Exit the game

The desired command is entered at the prompt. The play action will use the symbol for the current turn.

Current turn: O
Command:`

Positions are given as row,column. The board uses the following numbers for rows and columns:

Command: board
   0   1   2
0  ? | ? | ?
  ---+---+---
1  ? | ? | ?
  ---+---+---
2  ? | ? | ?

Back to start