Skip to content

Commit

Permalink
[shapes] Add numeric code for 2D
Browse files Browse the repository at this point in the history
  • Loading branch information
Prometheus3375 committed Jul 19, 2024
1 parent e92816d commit 14e90b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
30 changes: 15 additions & 15 deletions solve/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
from collections.abc import Sequence
from dataclasses import dataclass

from .key_sets import *
from .players import *
from .shapes import *
from .states import *
from .key_sets import KeySetType

number2shape = {
0: circle,
3: triangle,
4: square,

20: sphere,
23: pyramid,
33: pyramid,
24: cube,
44: cube,

30: cone,
40: cylinder,
34: prism,
43: prism,
circle.code: circle,
triangle.code: triangle,
square.code: square,

20: sphere,
23: pyramid,
33: pyramid,
24: cube,
44: cube,

30: cone,
40: cylinder,
34: prism,
43: prism,
}


Expand Down
8 changes: 5 additions & 3 deletions solve/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def __hash__(self, /) -> int:

@dataclass(repr=False, eq=False, frozen=True, slots=True)
class Shape2D(Shape):
code: int

def __add__(self, other: 'Shape2D', /) -> 'Shape3D':
result = _addition.get((self, other))
return NotImplemented if result is None else result
Expand Down Expand Up @@ -61,9 +63,9 @@ def __sub__(self, other: Shape2D, /) -> Shape2D:
_addition: dict[tuple[Shape2D, Shape2D], Shape3D] = {}
_subtraction: dict[tuple[Shape3D, Shape2D], Shape2D] = {}

circle = Shape2D('circle')
triangle = Shape2D('triangle')
square = Shape2D('square')
circle = Shape2D('circle', 0)
triangle = Shape2D('triangle', 3)
square = Shape2D('square', 4)

sphere = Shape3D('sphere', circle, circle)
pyramid = Shape3D('pyramid', triangle, triangle)
Expand Down

0 comments on commit 14e90b8

Please sign in to comment.