Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
6
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
C
Conway
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Adrian Kosmaczewski
Conway
Commits
69331b49
Commit
69331b49
authored
Sep 26, 2020
by
Adrian Kosmaczewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated PHP version
parent
0888dd47
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
79 deletions
+65
-79
PHP/.gitignore
PHP/.gitignore
+22
-36
PHP/.idea/php.xml
PHP/.idea/php.xml
+1
-1
PHP/src/Cell.php
PHP/src/Cell.php
+1
-1
PHP/src/Coord.php
PHP/src/Coord.php
+8
-8
PHP/src/World.php
PHP/src/World.php
+33
-33
No files found.
PHP/.gitignore
View file @
69331b49
composer.phar
vendor
# Created by https://www.
gitignore.io/api/phpstorm
# Edit at https://www.
gitignore.io/?templates=phpstorm
# Created by https://www.
toptal.com/developers/gitignore/api/phpunit,phpstorm+all
# Edit at https://www.
toptal.com/developers/gitignore?templates=phpunit,phpstorm+all
### PhpStorm ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
and WebStorm
### PhpStorm
+all
###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
...
...
@@ -33,6 +35,9 @@
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
...
...
@@ -72,41 +77,21 @@ fabric.properties
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### PhpStorm Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
.idea/**/sonarlint/
# SonarQube Plugin
.idea/**/sonarIssues.xml
# Markdown Navigator plugin
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator/
# End of https://www.gitignore.io/api/phpstorm
### PhpStorm+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
# Created by https://www.gitignore.io/api/composer
# Edit at https://www.gitignore.io/?templates=composer
.idea/
### Composer ###
composer.phar
/vendor/
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
# End of https://www.gitignore.io/api/composer
*.iml
modules.xml
.idea/misc.xml
*.ipr
#
Created by https://www.gitignore.io/api/phpunit
# Edit at https://www.gitignore.io/?templates=phpuni
t
#
Sonarlint plugin
.idea/sonarlin
t
### PHPUnit ###
# Covers PHPUnit
...
...
@@ -117,8 +102,9 @@ composer.phar
# PHPUnit
/app/phpunit.xml
/phpunit.xml
# Build data
/build/
# End of https://www.
gitignore.io/api/phpunit
# End of https://www.
toptal.com/developers/gitignore/api/phpunit,phpstorm+all
PHP/.idea/php.xml
View file @
69331b49
...
...
@@ -34,7 +34,7 @@
<path
value=
"$PROJECT_DIR$/vendor/phpunit/php-code-coverage"
/>
</include_path>
</component>
<component
name=
"PhpProjectSharedConfiguration"
php_language_level=
"7.
2
"
/>
<component
name=
"PhpProjectSharedConfiguration"
php_language_level=
"7.
4
"
/>
<component
name=
"PhpUnit"
>
<phpunit_settings>
<PhpUnitSettings
custom_loader_path=
"$PROJECT_DIR$/vendor/autoload.php"
/>
...
...
PHP/src/Cell.php
View file @
69331b49
...
...
@@ -8,7 +8,7 @@ abstract class Cell
const
Dead
=
0
;
const
Alive
=
1
;
static
function
tableDescription
(
int
$cell
):
string
static
function
cellToString
(
int
$cell
):
string
{
if
(
$cell
==
Cell
::
Alive
)
{
return
" x |"
;
...
...
PHP/src/Coord.php
View file @
69331b49
...
...
@@ -14,6 +14,14 @@ class Coord
$this
->
y
=
$y
;
}
public
static
function
fromString
(
string
$str
):
Coord
{
$parts
=
explode
(
":"
,
$str
);
$a
=
intval
(
$parts
[
0
]);
$b
=
intval
(
$parts
[
1
]);
return
new
Coord
(
$a
,
$b
);
}
public
function
getX
():
int
{
return
$this
->
x
;
...
...
@@ -28,12 +36,4 @@ class Coord
{
return
sprintf
(
"%d:%d"
,
$this
->
x
,
$this
->
y
);
}
public
static
function
createFromString
(
string
$str
):
Coord
{
$parts
=
explode
(
":"
,
$str
);
$a
=
intval
(
$parts
[
0
]);
$b
=
intval
(
$parts
[
1
]);
return
new
Coord
(
$a
,
$b
);
}
}
PHP/src/World.php
View file @
69331b49
...
...
@@ -25,61 +25,61 @@ class World
}
}
public
static
function
blinker
(
Coord
$
coord
):
array
public
static
function
blinker
(
Coord
$
origin
):
array
{
$alive
=
array
(
new
Coord
(
$
coord
->
getX
(),
$coord
->
getY
()),
new
Coord
(
$
coord
->
getX
()
+
1
,
$coord
->
getY
()),
new
Coord
(
$
coord
->
getX
()
+
2
,
$coord
->
getY
())
new
Coord
(
$
origin
->
getX
(),
$origin
->
getY
()),
new
Coord
(
$
origin
->
getX
()
+
1
,
$origin
->
getY
()),
new
Coord
(
$
origin
->
getX
()
+
2
,
$origin
->
getY
())
);
return
$alive
;
}
public
static
function
beacon
(
Coord
$
coord
):
array
public
static
function
beacon
(
Coord
$
origin
):
array
{
$alive
=
array
(
new
Coord
(
$
coord
->
getX
(),
$coord
->
getY
()),
new
Coord
(
$
coord
->
getX
()
+
1
,
$coord
->
getY
()),
new
Coord
(
$
coord
->
getX
(),
$coord
->
getY
()
+
1
),
new
Coord
(
$
coord
->
getX
()
+
1
,
$coord
->
getY
()
+
1
),
new
Coord
(
$
coord
->
getX
()
+
2
,
$coord
->
getY
()
+
2
),
new
Coord
(
$
coord
->
getX
()
+
3
,
$coord
->
getY
()
+
2
),
new
Coord
(
$
coord
->
getX
()
+
2
,
$coord
->
getY
()
+
3
),
new
Coord
(
$
coord
->
getX
()
+
3
,
$coord
->
getY
()
+
3
)
new
Coord
(
$
origin
->
getX
(),
$origin
->
getY
()),
new
Coord
(
$
origin
->
getX
()
+
1
,
$origin
->
getY
()),
new
Coord
(
$
origin
->
getX
(),
$origin
->
getY
()
+
1
),
new
Coord
(
$
origin
->
getX
()
+
1
,
$origin
->
getY
()
+
1
),
new
Coord
(
$
origin
->
getX
()
+
2
,
$origin
->
getY
()
+
2
),
new
Coord
(
$
origin
->
getX
()
+
3
,
$origin
->
getY
()
+
2
),
new
Coord
(
$
origin
->
getX
()
+
2
,
$origin
->
getY
()
+
3
),
new
Coord
(
$
origin
->
getX
()
+
3
,
$origin
->
getY
()
+
3
)
);
return
$alive
;
}
public
static
function
glider
(
Coord
$
coord
):
array
public
static
function
glider
(
Coord
$
origin
):
array
{
$alive
=
array
(
new
Coord
(
$
coord
->
getX
()
+
2
,
$coord
->
getY
()
+
2
),
new
Coord
(
$
coord
->
getX
()
+
1
,
$coord
->
getY
()
+
2
),
new
Coord
(
$
coord
->
getX
(),
$coord
->
getY
()
+
2
),
new
Coord
(
$
coord
->
getX
()
+
2
,
$coord
->
getY
()
+
1
),
new
Coord
(
$
coord
->
getX
()
+
1
,
$coord
->
getY
())
new
Coord
(
$
origin
->
getX
()
+
2
,
$origin
->
getY
()
+
2
),
new
Coord
(
$
origin
->
getX
()
+
1
,
$origin
->
getY
()
+
2
),
new
Coord
(
$
origin
->
getX
(),
$origin
->
getY
()
+
2
),
new
Coord
(
$
origin
->
getX
()
+
2
,
$origin
->
getY
()
+
1
),
new
Coord
(
$
origin
->
getX
()
+
1
,
$origin
->
getY
())
);
return
$alive
;
}
public
static
function
block
(
Coord
$
coord
):
array
public
static
function
block
(
Coord
$
origin
):
array
{
$alive
=
array
(
new
Coord
(
$
coord
->
getX
(),
$coord
->
getY
()),
new
Coord
(
$
coord
->
getX
()
+
1
,
$coord
->
getY
()),
new
Coord
(
$
coord
->
getX
(),
$coord
->
getY
()
+
1
),
new
Coord
(
$
coord
->
getX
()
+
1
,
$coord
->
getY
()
+
1
)
new
Coord
(
$
origin
->
getX
(),
$origin
->
getY
()),
new
Coord
(
$
origin
->
getX
()
+
1
,
$origin
->
getY
()),
new
Coord
(
$
origin
->
getX
(),
$origin
->
getY
()
+
1
),
new
Coord
(
$
origin
->
getX
()
+
1
,
$origin
->
getY
()
+
1
)
);
return
$alive
;
}
public
static
function
tub
(
Coord
$
coord
):
array
public
static
function
tub
(
Coord
$
origin
):
array
{
$alive
=
array
(
new
Coord
(
$
coord
->
getX
()
+
1
,
$coord
->
getY
()),
new
Coord
(
$
coord
->
getX
(),
$coord
->
getY
()
+
1
),
new
Coord
(
$
coord
->
getX
()
+
2
,
$coord
->
getY
()
+
1
),
new
Coord
(
$
coord
->
getX
()
+
1
,
$coord
->
getY
()
+
2
)
new
Coord
(
$
origin
->
getX
()
+
1
,
$origin
->
getY
()),
new
Coord
(
$
origin
->
getX
(),
$origin
->
getY
()
+
1
),
new
Coord
(
$
origin
->
getX
()
+
2
,
$origin
->
getY
()
+
1
),
new
Coord
(
$
origin
->
getX
()
+
1
,
$origin
->
getY
()
+
2
)
);
return
$alive
;
}
...
...
@@ -89,7 +89,7 @@ class World
$alive
=
array
();
$range
=
range
(
-
1
,
1
);
foreach
(
$this
->
cells
as
$str
=>
$cell
)
{
$coord
=
Coord
::
createF
romString
(
$str
);
$coord
=
Coord
::
f
romString
(
$str
);
$count
=
0
;
foreach
(
$range
as
$a
)
{
...
...
@@ -106,13 +106,13 @@ class World
switch
(
$cell
)
{
case
Cell
::
Alive
:
if
(
$count
==
2
||
$count
==
3
)
{
array_push
(
$alive
,
Coord
::
createF
romString
(
$str
));
array_push
(
$alive
,
Coord
::
f
romString
(
$str
));
}
break
;
case
Cell
::
Dead
:
if
(
$count
==
3
)
{
array_push
(
$alive
,
Coord
::
createF
romString
(
$str
));
array_push
(
$alive
,
Coord
::
f
romString
(
$str
));
}
break
;
}
...
...
@@ -143,7 +143,7 @@ class World
for
(
$b
=
0
;
$b
<
$this
->
size
;
++
$b
)
{
$coord
=
new
Coord
(
$b
,
$a
);
$cell
=
$this
->
cells
[
strval
(
$coord
)];
$str
.
=
Cell
::
tableDescription
(
$cell
);
$str
.
=
Cell
::
cellToString
(
$cell
);
}
$str
.
=
"
\n
"
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment