Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Brady James Garvin
nim
Commits
199fe347
Commit
199fe347
authored
8 years ago
by
Brady James Garvin
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit.
parents
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
main.py
+53
-0
53 additions, 0 deletions
main.py
nim.kv
+53
-0
53 additions, 0 deletions
nim.kv
with
107 additions
and
0 deletions
.gitignore
0 → 100644
+
1
−
0
View file @
199fe347
.idea
This diff is collapsed.
Click to expand it.
main.py
0 → 100644
+
53
−
0
View file @
199fe347
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
()
This diff is collapsed.
Click to expand it.
nim.kv
0 → 100644
+
53
−
0
View file @
199fe347
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()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment