Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
2048
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Thomas Bianco
2048
Commits
386a403c
Commit
386a403c
authored
6 years ago
by
Thomas Bianco
Browse files
Options
Downloads
Plain Diff
move left
parents
834c449f
952d2fcf
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.idea/workspace.xml
+111
-7
111 additions, 7 deletions
.idea/workspace.xml
game2048/grid_2048.py
+49
-22
49 additions, 22 deletions
game2048/grid_2048.py
with
160 additions
and
29 deletions
.idea/workspace.xml
+
111
−
7
View file @
386a403c
...
@@ -4,11 +4,15 @@
...
@@ -4,11 +4,15 @@
<list
default=
"true"
id=
"a1e637b1-c555-4557-a6ba-8dfbc46c2cef"
name=
"Default Changelist"
comment=
""
>
<list
default=
"true"
id=
"a1e637b1-c555-4557-a6ba-8dfbc46c2cef"
name=
"Default Changelist"
comment=
""
>
<change
beforePath=
"$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<<<<<<
< HEAD
<change
beforePath=
"$PROJECT_DIR$/game2048/.pytest_cache/v/cache/lastfailed"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/game2048/.pytest_cache/v/cache/lastfailed"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/game2048/.pytest_cache/v/cache/lastfailed"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/game2048/.pytest_cache/v/cache/lastfailed"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/game2048/.pytest_cache/v/cache/nodeids"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/game2048/.pytest_cache/v/cache/nodeids"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/game2048/.pytest_cache/v/cache/nodeids"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/game2048/.pytest_cache/v/cache/nodeids"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/game2048/grid_2048.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/game2048/grid_2048.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/game2048/grid_2048.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/game2048/grid_2048.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/game2048/test_grid_2048.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/game2048/test_grid_2048.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/game2048/test_grid_2048.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/game2048/test_grid_2048.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/game2048/textual_2048.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/game2048/textual_2048.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/game2048/textual_2048.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/game2048/textual_2048.py"
afterDir=
"false"
/>
=======
<change
beforePath=
"$PROJECT_DIR$/game2048/grid_2048.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/game2048/grid_2048.py"
afterDir=
"false"
/>
>>>>>>> 952d2fcf3d0f6c682a4b8680a958de165afc17ae
</list>
</list>
<option
name=
"EXCLUDED_CONVERTED_TO_IGNORED"
value=
"true"
/>
<option
name=
"EXCLUDED_CONVERTED_TO_IGNORED"
value=
"true"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
...
@@ -49,12 +53,44 @@
...
@@ -49,12 +53,44 @@
</counts>
</counts>
</usages-collector>
</usages-collector>
</session>
</session>
<session
id=
"-897679322"
>
<usages-collector
id=
"statistics.lifecycle.project"
>
<counts>
<entry
key=
"project.closed"
value=
"1"
/>
<entry
key=
"project.open.time.6"
value=
"1"
/>
<entry
key=
"project.open.time.7"
value=
"1"
/>
<entry
key=
"project.opened"
value=
"2"
/>
</counts>
</usages-collector>
<usages-collector
id=
"statistics.file.extensions.open"
>
<counts>
<entry
key=
"py"
value=
"2"
/>
</counts>
</usages-collector>
<usages-collector
id=
"statistics.file.types.open"
>
<counts>
<entry
key=
"Python"
value=
"2"
/>
</counts>
</usages-collector>
<usages-collector
id=
"statistics.file.extensions.edit"
>
<counts>
<entry
key=
"Python Console"
value=
"38"
/>
<entry
key=
"py"
value=
"1757"
/>
</counts>
</usages-collector>
<usages-collector
id=
"statistics.file.types.edit"
>
<counts>
<entry
key=
"Python"
value=
"1795"
/>
</counts>
</usages-collector>
</session>
</component>
</component>
<component
name=
"FileEditorManager"
>
<component
name=
"FileEditorManager"
>
<leaf
SIDE_TABS_SIZE_LIMIT_KEY=
"300"
>
<leaf
SIDE_TABS_SIZE_LIMIT_KEY=
"300"
>
<file
pinned=
"false"
current-in-tab=
"true"
>
<file
pinned=
"false"
current-in-tab=
"true"
>
<entry
file=
"file://$PROJECT_DIR$/game2048/grid_2048.py"
>
<entry
file=
"file://$PROJECT_DIR$/game2048/grid_2048.py"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<<<<<<
< HEAD
<state
relative-caret-position=
"219"
>
<state
relative-caret-position=
"219"
>
<caret
line=
"87"
column=
"43"
selection-start-line=
"87"
selection-start-column=
"43"
selection-end-line=
"87"
selection-end-column=
"43"
/>
<caret
line=
"87"
column=
"43"
selection-start-line=
"87"
selection-start-column=
"43"
selection-end-line=
"87"
selection-end-column=
"43"
/>
<folding>
<folding>
...
@@ -71,11 +107,27 @@
...
@@ -71,11 +107,27 @@
<caret
line=
"64"
lean-forward=
"true"
selection-start-line=
"64"
selection-end-line=
"64"
/>
<caret
line=
"64"
lean-forward=
"true"
selection-start-line=
"64"
selection-end-line=
"64"
/>
<folding>
<folding>
<element
signature=
"e#0#32#0"
expanded=
"true"
/>
<element
signature=
"e#0#32#0"
expanded=
"true"
/>
=======
<state
relative-caret-position=
"349"
>
<caret
line=
"126"
column=
"34"
selection-start-line=
"126"
selection-start-column=
"34"
selection-end-line=
"126"
selection-end-column=
"34"
/>
<folding>
<marker
date=
"1542184310612"
expanded=
"true"
signature=
"3334:3339"
ph=
"..."
/>
>>>>>>> 952d2fcf3d0f6c682a4b8680a958de165afc17ae
</folding>
</folding>
</state>
</state>
</provider>
</provider>
</entry>
</entry>
</file>
</file>
<file
pinned=
"false"
current-in-tab=
"false"
>
<entry
file=
"file://$PROJECT_DIR$/game2048/textual_2048.py"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
/>
</entry>
</file>
<file
pinned=
"false"
current-in-tab=
"false"
>
<entry
file=
"file://$PROJECT_DIR$/game2048/test_textual_2048.py"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
/>
</entry>
</file>
</leaf>
</leaf>
</component>
</component>
<component
name=
"FileTemplateManagerImpl"
>
<component
name=
"FileTemplateManagerImpl"
>
...
@@ -91,18 +143,23 @@
...
@@ -91,18 +143,23 @@
<component
name=
"IdeDocumentHistory"
>
<component
name=
"IdeDocumentHistory"
>
<option
name=
"CHANGED_PATHS"
>
<option
name=
"CHANGED_PATHS"
>
<list>
<list>
<<<<<<
< HEAD
<option
value=
"$PROJECT_DIR$/game2048/textual2048.py"
/>
<option
value=
"$PROJECT_DIR$/game2048/textual2048.py"
/>
<option
value=
"$PROJECT_DIR$/game2048/test_textual_2048.py"
/>
<option
value=
"$PROJECT_DIR$/game2048/test_textual_2048.py"
/>
<option
value=
"$PROJECT_DIR$/game2048/textual_2048.py"
/>
<option
value=
"$PROJECT_DIR$/game2048/textual_2048.py"
/>
<option
value=
"$PROJECT_DIR$/game2048/test_grid_2048.py"
/>
<option
value=
"$PROJECT_DIR$/game2048/test_grid_2048.py"
/>
=======
<option
value=
"$PROJECT_DIR$/game2048/textual_2048.py"
/>
<option
value=
"$PROJECT_DIR$/game2048/test_textual_2048.py"
/>
>>>>>>> 952d2fcf3d0f6c682a4b8680a958de165afc17ae
<option
value=
"$PROJECT_DIR$/game2048/grid_2048.py"
/>
<option
value=
"$PROJECT_DIR$/game2048/grid_2048.py"
/>
</list>
</list>
</option>
</option>
</component>
</component>
<component
name=
"ProjectFrameBounds"
extendedState=
"6"
>
<component
name=
"ProjectFrameBounds"
>
<option
name=
"x"
value=
"10
5
6"
/>
<option
name=
"x"
value=
"106
9
"
/>
<option
name=
"width"
value=
"
756
"
/>
<option
name=
"width"
value=
"
1085
"
/>
<option
name=
"height"
value=
"1
032
"
/>
<option
name=
"height"
value=
"1
391
"
/>
</component>
</component>
<component
name=
"ProjectLevelVcsManager"
>
<component
name=
"ProjectLevelVcsManager"
>
<ConfirmationsSetting
value=
"2"
id=
"Add"
/>
<ConfirmationsSetting
value=
"2"
id=
"Add"
/>
...
@@ -132,7 +189,7 @@
...
@@ -132,7 +189,7 @@
</panes>
</panes>
</component>
</component>
<component
name=
"PropertiesComponent"
>
<component
name=
"PropertiesComponent"
>
<property
name=
"last_opened_file_path"
value=
"$PROJECT_DIR$"
/>
<property
name=
"last_opened_file_path"
value=
"$PROJECT_DIR$
/../2048 local
"
/>
<property
name=
"settings.editor.selected.configurable"
value=
"com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable"
/>
<property
name=
"settings.editor.selected.configurable"
value=
"com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable"
/>
</component>
</component>
<component
name=
"RunDashboard"
>
<component
name=
"RunDashboard"
>
...
@@ -147,16 +204,28 @@
...
@@ -147,16 +204,28 @@
</list>
</list>
</option>
</option>
</component>
</component>
<<<<<<
< HEAD
<component
name=
"RunManager"
selected=
"Python tests.pytest for test_grid_2048.test_create_grid"
>
<component
name=
"RunManager"
selected=
"Python tests.pytest for test_grid_2048.test_create_grid"
>
<configuration
name=
"pytest for test_grid_2048.test_create_grid"
type=
"tests"
factoryName=
"py.test"
temporary=
"true"
nameIsGenerated=
"true"
>
<configuration
name=
"pytest for test_grid_2048.test_create_grid"
type=
"tests"
factoryName=
"py.test"
temporary=
"true"
nameIsGenerated=
"true"
>
<module
name=
"2048"
/>
<module
name=
"2048"
/>
<option
name=
"INTERPRETER_OPTIONS"
value=
""
/>
<option
name=
"INTERPRETER_OPTIONS"
value=
""
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
=======
<component
name=
"RunManager"
>
<configuration
name=
"grid_2048"
type=
"PythonConfigurationType"
factoryName=
"Python"
temporary=
"true"
>
<module
name=
"2048"
/>
<option
name=
"INTERPRETER_OPTIONS"
value=
""
/>
<option
name=
"PARENT_ENVS"
value=
"true"
/>
<envs>
<env
name=
"PYTHONUNBUFFERED"
value=
"1"
/>
</envs>
>>>>>>> 952d2fcf3d0f6c682a4b8680a958de165afc17ae
<option
name=
"SDK_HOME"
value=
""
/>
<option
name=
"SDK_HOME"
value=
""
/>
<option
name=
"WORKING_DIRECTORY"
value=
"$PROJECT_DIR$/game2048"
/>
<option
name=
"WORKING_DIRECTORY"
value=
"$PROJECT_DIR$/game2048"
/>
<option
name=
"IS_MODULE_SDK"
value=
"true"
/>
<option
name=
"IS_MODULE_SDK"
value=
"true"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_CONTENT_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<option
name=
"ADD_SOURCE_ROOTS"
value=
"true"
/>
<<<<<<
< HEAD
<option
name=
"_new_keywords"
value=
""""
/>
<option
name=
"_new_keywords"
value=
""""
/>
<option
name=
"_new_additionalArguments"
value=
""""
/>
<option
name=
"_new_additionalArguments"
value=
""""
/>
<option
name=
"_new_target"
value=
""test_grid_2048.test_create_grid""
/>
<option
name=
"_new_target"
value=
""test_grid_2048.test_create_grid""
/>
...
@@ -203,6 +272,20 @@
...
@@ -203,6 +272,20 @@
<item
itemvalue=
"Python tests.pytest for test_grid_2048.test_create_grid"
/>
<item
itemvalue=
"Python tests.pytest for test_grid_2048.test_create_grid"
/>
<item
itemvalue=
"Python tests.pytest in test_grid_2048.py"
/>
<item
itemvalue=
"Python tests.pytest in test_grid_2048.py"
/>
<item
itemvalue=
"Python tests.pytest for test_grid_2048.test_move_row_left"
/>
<item
itemvalue=
"Python tests.pytest for test_grid_2048.test_move_row_left"
/>
=======
<option
name=
"SCRIPT_NAME"
value=
"$PROJECT_DIR$/game2048/grid_2048.py"
/>
<option
name=
"PARAMETERS"
value=
""
/>
<option
name=
"SHOW_COMMAND_LINE"
value=
"false"
/>
<option
name=
"EMULATE_TERMINAL"
value=
"false"
/>
<option
name=
"MODULE_MODE"
value=
"false"
/>
<option
name=
"REDIRECT_INPUT"
value=
"false"
/>
<option
name=
"INPUT_FILE"
value=
""
/>
<method
v=
"2"
/>
</configuration>
<recent_temporary>
<list>
<item
itemvalue=
"Python.grid_2048"
/>
>>>>>>> 952d2fcf3d0f6c682a4b8680a958de165afc17ae
</list>
</list>
</recent_temporary>
</recent_temporary>
</component>
</component>
...
@@ -227,20 +310,28 @@
...
@@ -227,20 +310,28 @@
</history-entry>
</history-entry>
</component>
</component>
<component
name=
"ToolWindowManager"
>
<component
name=
"ToolWindowManager"
>
<frame
x=
"
-
7"
y=
"
-7
"
width=
"
1295
"
height=
"
695
"
extended-state=
"
6
"
/>
<frame
x=
"7
13
"
y=
"
0
"
width=
"
723
"
height=
"
927
"
extended-state=
"
0
"
/>
<editor
active=
"true"
/>
<editor
active=
"true"
/>
<layout>
<layout>
<window_info
active=
"true"
content_ui=
"combo"
id=
"Project"
order=
"0"
visible=
"true"
weight=
"0.
24960254
"
/>
<window_info
content_ui=
"combo"
id=
"Project"
order=
"0"
visible=
"true"
weight=
"0.
12244898
"
/>
<window_info
id=
"Structure"
order=
"1"
weight=
"0.25"
/>
<window_info
id=
"Structure"
order=
"1"
weight=
"0.25"
/>
<window_info
anchor=
"bottom"
id=
"Message"
order=
"0"
/>
<window_info
anchor=
"bottom"
id=
"Message"
order=
"0"
/>
<window_info
anchor=
"bottom"
id=
"Find"
order=
"1"
/>
<window_info
anchor=
"bottom"
id=
"Find"
order=
"1"
/>
<<<<<<
< HEAD
<window_info
anchor=
"bottom"
id=
"Run"
order=
"2"
visible=
"true"
weight=
"0.2605753"
/>
<window_info
anchor=
"bottom"
id=
"Run"
order=
"2"
visible=
"true"
weight=
"0.2605753"
/>
=======
<window_info
active=
"true"
anchor=
"bottom"
id=
"Run"
order=
"2"
visible=
"true"
weight=
"0.32955974"
/>
>>>>>>> 952d2fcf3d0f6c682a4b8680a958de165afc17ae
<window_info
anchor=
"bottom"
id=
"Debug"
order=
"3"
weight=
"0.4"
/>
<window_info
anchor=
"bottom"
id=
"Debug"
order=
"3"
weight=
"0.4"
/>
<window_info
anchor=
"bottom"
id=
"Cvs"
order=
"4"
weight=
"0.25"
/>
<window_info
anchor=
"bottom"
id=
"Cvs"
order=
"4"
weight=
"0.25"
/>
<window_info
anchor=
"bottom"
id=
"Inspection"
order=
"5"
weight=
"0.4"
/>
<window_info
anchor=
"bottom"
id=
"Inspection"
order=
"5"
weight=
"0.4"
/>
<window_info
anchor=
"bottom"
id=
"TODO"
order=
"6"
/>
<window_info
anchor=
"bottom"
id=
"TODO"
order=
"6"
/>
<window_info
anchor=
"bottom"
id=
"Version Control"
order=
"7"
/>
<window_info
anchor=
"bottom"
id=
"Version Control"
order=
"7"
/>
<<<<<<
< HEAD
<window_info
anchor=
"bottom"
id=
"Python Console"
order=
"8"
/>
<window_info
anchor=
"bottom"
id=
"Python Console"
order=
"8"
/>
=======
<window_info
anchor=
"bottom"
id=
"Python Console"
order=
"8"
weight=
"0.32955974"
/>
>>>>>>> 952d2fcf3d0f6c682a4b8680a958de165afc17ae
<window_info
anchor=
"right"
id=
"Commander"
internal_type=
"SLIDING"
order=
"0"
type=
"SLIDING"
weight=
"0.4"
/>
<window_info
anchor=
"right"
id=
"Commander"
internal_type=
"SLIDING"
order=
"0"
type=
"SLIDING"
weight=
"0.4"
/>
<window_info
anchor=
"right"
id=
"Ant Build"
order=
"1"
weight=
"0.25"
/>
<window_info
anchor=
"right"
id=
"Ant Build"
order=
"1"
weight=
"0.25"
/>
<window_info
anchor=
"right"
content_ui=
"combo"
id=
"Hierarchy"
order=
"2"
weight=
"0.25"
/>
<window_info
anchor=
"right"
content_ui=
"combo"
id=
"Hierarchy"
order=
"2"
weight=
"0.25"
/>
...
@@ -288,13 +379,26 @@
...
@@ -288,13 +379,26 @@
</entry>
</entry>
<entry
file=
"file://$PROJECT_DIR$/game2048/grid_2048.py"
>
<entry
file=
"file://$PROJECT_DIR$/game2048/grid_2048.py"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<<<<<<
< HEAD
<state
relative-caret-position=
"219"
>
<state
relative-caret-position=
"219"
>
<caret
line=
"87"
column=
"43"
selection-start-line=
"87"
selection-start-column=
"43"
selection-end-line=
"87"
selection-end-column=
"43"
/>
<caret
line=
"87"
column=
"43"
selection-start-line=
"87"
selection-start-column=
"43"
selection-end-line=
"87"
selection-end-column=
"43"
/>
<folding>
<folding>
<marker
date=
"1542184553928"
expanded=
"true"
signature=
"2609:2611"
ph=
"..."
/>
<marker
date=
"1542184553928"
expanded=
"true"
signature=
"2609:2611"
ph=
"..."
/>
=======
<state
relative-caret-position=
"349"
>
<caret
line=
"126"
column=
"34"
selection-start-line=
"126"
selection-start-column=
"34"
selection-end-line=
"126"
selection-end-column=
"34"
/>
<folding>
<marker
date=
"1542184310612"
expanded=
"true"
signature=
"3334:3339"
ph=
"..."
/>
>>>>>>> 952d2fcf3d0f6c682a4b8680a958de165afc17ae
</folding>
</folding>
</state>
</state>
</provider>
</provider>
</entry>
</entry>
<entry
file=
"file://$PROJECT_DIR$/game2048/textual_2048.py"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
/>
</entry>
<entry
file=
"file://$PROJECT_DIR$/game2048/test_textual_2048.py"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
/>
</entry>
</component>
</component>
</project>
</project>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
game2048/grid_2048.py
+
49
−
22
View file @
386a403c
...
@@ -2,67 +2,96 @@ import random as rd
...
@@ -2,67 +2,96 @@ import random as rd
THEMES
=
{
"
0
"
:
{
"
name
"
:
"
Default
"
,
0
:
""
,
2
:
"
2
"
,
4
:
"
4
"
,
8
:
"
8
"
,
16
:
"
16
"
,
32
:
"
32
"
,
64
:
"
64
"
,
128
:
"
128
"
,
256
:
"
256
"
,
512
:
"
512
"
,
1024
:
"
1024
"
,
2048
:
"
2048
"
,
4096
:
"
4096
"
,
8192
:
"
8192
"
},
"
1
"
:
{
"
name
"
:
"
Chemistry
"
,
0
:
""
,
2
:
"
H
"
,
4
:
"
He
"
,
8
:
"
Li
"
,
16
:
"
Be
"
,
32
:
"
B
"
,
64
:
"
C
"
,
128
:
"
N
"
,
256
:
"
O
"
,
512
:
"
F
"
,
1024
:
"
Ne
"
,
2048
:
"
Na
"
,
4096
:
"
Mg
"
,
8192
:
"
Al
"
},
"
2
"
:
{
"
name
"
:
"
Alphabet
"
,
0
:
""
,
2
:
"
A
"
,
4
:
"
B
"
,
8
:
"
C
"
,
16
:
"
D
"
,
32
:
"
E
"
,
64
:
"
F
"
,
128
:
"
G
"
,
256
:
"
H
"
,
512
:
"
I
"
,
1024
:
"
J
"
,
2048
:
"
K
"
,
4096
:
"
L
"
,
8192
:
"
M
"
}}
THEMES
=
{
"
0
"
:
{
"
name
"
:
"
Default
"
,
0
:
""
,
2
:
"
2
"
,
4
:
"
4
"
,
8
:
"
8
"
,
16
:
"
16
"
,
32
:
"
32
"
,
64
:
"
64
"
,
128
:
"
128
"
,
256
:
"
256
"
,
512
:
"
512
"
,
1024
:
"
1024
"
,
2048
:
"
2048
"
,
4096
:
"
4096
"
,
8192
:
"
8192
"
},
"
1
"
:
{
"
name
"
:
"
Chemistry
"
,
0
:
""
,
2
:
"
H
"
,
4
:
"
He
"
,
8
:
"
Li
"
,
16
:
"
Be
"
,
32
:
"
B
"
,
64
:
"
C
"
,
128
:
"
N
"
,
256
:
"
O
"
,
512
:
"
F
"
,
1024
:
"
Ne
"
,
2048
:
"
Na
"
,
4096
:
"
Mg
"
,
8192
:
"
Al
"
},
"
2
"
:
{
"
name
"
:
"
Alphabet
"
,
0
:
""
,
2
:
"
A
"
,
4
:
"
B
"
,
8
:
"
C
"
,
16
:
"
D
"
,
32
:
"
E
"
,
64
:
"
F
"
,
128
:
"
G
"
,
256
:
"
H
"
,
512
:
"
I
"
,
1024
:
"
J
"
,
2048
:
"
K
"
,
4096
:
"
L
"
,
8192
:
"
M
"
}}
#FONCTIONNALITE 1
def
create_grid
(
n
):
def
create_grid
(
n
):
game_grid
=
[]
game_grid
=
[]
for
i
in
range
(
n
):
for
i
in
range
(
n
):
game_grid
.
append
([
'
'
]
*
n
)
#crée le bon nombre de ligne
return
game_grid
game_grid
.
append
([
'
'
]
*
n
)
#crée le bon nombre de colonnes
return
(
game_grid
)
def
get_value_new_tile
():
def
get_value_new_tile
():
#choisi la valeur de la nouvelle case avec la probabilté indiquée dans l'énoncé
return
rd
.
choice
([
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
4
])
return
rd
.
choice
([
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
4
])
def
get_all_tiles
(
grid
):
def
get_all_tiles
(
grid
):
tiles
=
[]
tiles
=
[]
for
line
in
grid
:
for
line
in
grid
:
#parcours toutes les lignes
for
tile
in
line
:
for
tile
in
line
:
#parcours toutes les colonnes
if
tile
==
'
'
:
tiles
.
append
(
0
)
if
tile
==
'
'
:
tiles
.
append
(
0
)
#traite le cas particulier de la double notation 0 ou " " pour les emplacments vides
else
:
tiles
.
append
(
tile
)
else
:
tiles
.
append
(
tile
)
return
tiles
return
tiles
def
get_empty_tiles_positions
(
grid
):
def
get_empty_tiles_positions
(
grid
):
empty_tiles
=
[]
empty_tiles
=
[]
n
=
len
(
grid
)
nb_ligne
=
len
(
grid
)
m
=
len
(
grid
[
0
])
nb_colonne
=
len
(
grid
[
0
])
for
i
in
range
(
n
):
#on suppose que la grille a au moins une ligne
for
j
in
range
(
m
):
#on suppose que toutes les lignes ont le même nombre de colonnes
for
i
in
range
(
nb_ligne
):
for
j
in
range
(
nb_colonne
):
if
grid
[
i
][
j
]
==
'
'
or
grid
[
i
][
j
]
==
0
:
if
grid
[
i
][
j
]
==
'
'
or
grid
[
i
][
j
]
==
0
:
#traite le cas particulier de la double notation 0 ou " " pour les emplacments vides
empty_tiles
.
append
((
i
,
j
))
empty_tiles
.
append
((
i
,
j
))
return
empty_tiles
return
empty_tiles
def
get_new_position
(
grid
):
def
get_new_position
(
grid
):
#choisi une postion au hasard parmis les position libre
empty_tiles
=
get_empty_tiles_positions
(
grid
)
empty_tiles
=
get_empty_tiles_positions
(
grid
)
return
rd
.
choice
(
empty_tiles
)
return
(
rd
.
choice
(
empty_tiles
)
)
def
grid_get_value
(
grid
,
x
,
y
):
def
grid_get_value
(
grid
,
x
,
y
):
if
grid
[
x
][
y
]
==
'
'
:
if
grid
[
x
][
y
]
==
'
'
:
#traite le cas particulier de la double notation 0 ou " "
return
0
return
0
return
grid
[
x
][
y
]
return
grid
[
x
][
y
]
def
grid_add_new_tile
(
grid
):
def
grid_add_new_tile
(
grid
):
x
,
y
=
get_new_position
(
grid
)
x
,
y
=
get_new_position
(
grid
)
grid
[
x
][
y
]
=
get_value_new_tile
()
grid
[
x
][
y
]
=
get_value_new_tile
()
#attention, la fonction modifie la liste passée en argument !
return
grid
return
grid
def
init_game
(
n
):
def
init_game
(
n
):
grid
=
create_grid
(
n
)
grid
=
create_grid
(
n
)
for
i
in
range
(
2
):
for
new_tile
in
range
(
2
):
grid
=
grid_add_new_tile
(
grid
)
grid
=
grid_add_new_tile
(
grid
)
return
grid
return
grid
#FONCTIONNALITE 2
def
grid_to_string_with_size_and_theme
(
grid
,
theme
,
n
):
def
grid_to_string_with_size_and_theme
(
grid
,
theme
,
n
):
m
=
long_value_with_theme
(
grid
,
theme
)
longest_str
=
long_value_with_theme
(
grid
,
theme
)
a
=
""
affichage
=
""
for
i
in
range
(
n
):
for
ligne
in
range
(
n
):
a
+=
(
"
"
+
"
=
"
*
(
m
+
2
))
*
n
+
"
\n
"
for
j
in
range
(
n
):
#création de la délimation du dessus
a
+=
"
| {}
"
.
format
(
theme
[
grid
[
i
][
j
]])
+
"
"
*
(
1
+
m
-
len
(
theme
[
grid
[
i
][
j
]]))
affichage
+=
(
"
"
+
"
=
"
*
(
longest_str
+
2
))
*
n
+
"
\n
"
a
+=
"
|
\n
"
#calcul du nombre nécéssaire d'espaces
a
+=
(
"
"
+
"
=
"
*
(
m
+
2
))
*
n
return
a
for
colonne
in
range
(
n
):
affichage
+=
"
| {}
"
.
format
(
theme
[
grid
[
ligne
][
colonne
]])
+
"
"
*
(
1
+
longest_str
-
len
(
theme
[
grid
[
ligne
][
colonne
]]))
affichage
+=
"
|
\n
"
#fini la ligne
#création de la dernière délimation du bas
affichage
+=
(
"
"
+
"
=
"
*
(
longest_str
+
2
))
*
n
return
affichage
def
long_value_with_theme
(
grid
,
theme
):
def
long_value_with_theme
(
grid
,
theme
):
return
max
(
len
(
theme
[
v
])
for
v
in
get_all_tiles
(
grid
))
return
max
(
len
(
theme
[
v
])
for
v
in
get_all_tiles
(
grid
))
<<<<<<<
HEAD
#FONCTIONNALITE 4
def
del_zeros
(
row
):
def
del_zeros
(
row
):
n
=
len
(
row
)
n
=
len
(
row
)
new_row
=
[]
new_row
=
[]
...
@@ -86,5 +115,3 @@ def move_row_left(row):
...
@@ -86,5 +115,3 @@ def move_row_left(row):
row
,
n
=
del_zeros
(
row
)
row
,
n
=
del_zeros
(
row
)
new_row
=
move_left_bis
(
row
)
new_row
=
move_left_bis
(
row
)
return
new_row
+
[
0
]
*
(
n
-
len
(
new_row
))
return
new_row
+
[
0
]
*
(
n
-
len
(
new_row
))
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