Skip to content
Snippets Groups Projects
Commit 199fe347 authored by Brady James Garvin's avatar Brady James Garvin
Browse files

Initial commit.

parents
No related branches found
No related tags found
No related merge requests found
.idea
main.py 0 → 100644
from kivy.app import App
from kivy.properties import BooleanProperty, NumericProperty
__app_package__ = 'edu.unl.cse.soft161.nim'
__app__ = 'Nim'
__version__ = '0.1'
__flags__ = ['--bootstrap=sdl2', '--requirements=python2,kivy', '--orientation=landscape']
class NimApp(App):
heap_a = NumericProperty(3)
heap_b = NumericProperty(5)
heap_c = NumericProperty(7)
take_a_enabled = BooleanProperty(True)
take_b_enabled = BooleanProperty(True)
take_c_enabled = BooleanProperty(True)
next_enabled = BooleanProperty(True)
def make_computer_move(self):
if self.heap_b ^ self.heap_c < self.heap_a:
self.heap_a = self.heap_b ^ self.heap_c
elif self.heap_a ^ self.heap_c < self.heap_b:
self.heap_c = self.heap_a ^ self.heap_c
elif self.heap_a ^ self.heap_b < self.heap_c:
self.heap_c = self.heap_a ^ self.heap_b
elif self.heap_a >= self.heap_b and self.heap_a >= self.heap_c:
self.heap_a -= 1
elif self.heap_b >= self.heap_c:
self.heap_b -= 1
else:
self.heap_c -= 1
def reset(self):
self.heap_a = 3
self.heap_b = 5
self.heap_c = 7
def take_a(self):
pass
def take_b(self):
pass
def take_c(self):
pass
def next(self):
pass
if __name__ == "__main__":
nim = NimApp()
nim.run()
nim.kv 0 → 100644
BoxLayout:
orientation: 'vertical'
BoxLayout:
orientation: 'horizontal'
BoxLayout:
orientation: 'vertical'
Label:
size_hint: (1, 0.25)
text: 'Heap A:'
Label:
font_size: '150sp'
text: str(app.heap_a)
Button:
size_hint: (1, 0.25)
disabled: not app.take_a_enabled
text: 'Take A'
on_press: app.take_a()
BoxLayout:
orientation: 'vertical'
Label:
size_hint: (1, 0.25)
text: 'Heap B:'
Label:
font_size: '150sp'
text: str(app.heap_b)
Button:
size_hint: (1, 0.25)
disabled: not app.take_b_enabled
text: 'Take B'
on_press: app.take_b()
BoxLayout:
orientation: 'vertical'
Label:
size_hint: (1, 0.25)
text: 'Heap C:'
Label:
font_size: '150sp'
text: str(app.heap_c)
Button:
size_hint: (1, 0.25)
disabled: not app.take_c_enabled
text: 'Take C'
on_press: app.take_c()
BoxLayout:
size_hint: (1, 0.2)
orientation: 'horizontal'
Button:
text: 'New Game'
on_press: app.reset()
Button:
disabled: not app.next_enabled
text: 'Next'
on_press: app.next()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment