Difference between revisions of "Code:Oware"
From Predictive Chemistry
(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 ...") |
|||
Line 34: | Line 34: | ||
print "A B C D E F" |
print "A B C D E F" |
||
− | ABC, fed, score = |
+ | ABC, fed, score = new_board() |
print_board(ABC, fed, score) |
print_board(ABC, fed, score) |
||
</source> |
</source> |
Revision as of 14:20, 20 January 2016
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 = new_board() print_board(ABC, fed, score) </source>