Code:Oware
From Predictive Chemistry
Revision as of 14:20, 20 January 2016 by David M. Rogers (talk | contribs) (Created page with "Here is the code we're building in Intro. Scientific Computing, 2016 for playing [https://en.wikipedia.org/wiki/Oware Oware]. There is a simple rule summary and a few example ...")
Here is the code we're building in Intro. Scientific Computing, 2016 for playing Oware. There is a simple rule summary and a few example game openings at this site.
<source lang="python">
- objective: create a game of Owari
- ASCII Art: f e d c b a <-- (fed) # score[1]
- A B C D E F --> (ABC) # score[0]
- 0 1 2 3 4 5
- create a new board
def new_board(): # () -> ([int], [int], [int])
ABC = [4]*6 fed = [4]*6 score = [0, 0] return ABC, fed, score
- move pieces (TODO)
def move(ABC, fed, start):
# player 1, assume start is at position F ABC[5] = 0 #assign old position to zero fed[5] = fed[5] + 1 # distribute seeds fed[4] = fed[4] + 1 # distribute seeds fed[3] = fed[3] + 1 # distribute seeds fed[2] = fed[2] + 1 # distribute seeds # TODO: check for capture return 0, 0 # return score update
- print_board : ([int], [int], [int]) -> ()
def print_board(ABC, fed, score):
print "Current board:" print "f e d c b a" print fed, score[1] print ABC, score[0] print "A B C D E F"
ABC, fed, score = create_board() print_board(ABC, fed, score) </source>