mark-wiemer / calculator-game Goto Github PK
View Code? Open in Web Editor NEWA clone and solver of Calculator: The Game. Includes 0-click test factory and integrated custom level creation
A clone and solver of Calculator: The Game. Includes 0-click test factory and integrated custom level creation
Description
Lots of functions convert lists from one type to another manually without a consistent interface.
Problems
Cluttered, clunky code is hard to maintain
Proposed Solution
Java 8 Streams! Read all about them here and use maps and stuff!
All arrays (Rule[] rules
, int[] portals
, etc.) should be converted to lists (preferably immutable, but that's for another issue) for easier stream usage.
Acceptance Criteria
Description
Static methods are used to build and tear down the testing environment
Problems
Static methods only have one return value and are stateless. This means the client must track things instead, violating SRP and cluttering client code
Proposed Solution
Make IoUtils
methods instance-based. This way, the IoUtils
instance can store the default System.out
and can build up / tear down testing environments with one method call
Acceptance Criteria
IoUtils
methods are instance-basedA control flow diagram for the main loops would be a nice overview of how the project works
Description
Currently, all Rule
instances have a getOperand1
and getOperand2
method. For many instances, these methods are unnecessary.
Problems
Violates the interface segregation principle, leading to potential issues when clients use those methods on Rule
instances that do not define them
Proposed Solution
Subclass Rule
with 'zero operators' type, 'one operator' type, and 'two operator' type.
Acceptance Criteria
Rule
and its subclassesDescription
Currently, clients build a state (value, movesLeft, rules) and pass that to CalculatorGame.generateGame
, which may return null
, but otherwise returns a CalculatorGame
instance
Problems
Using an intermediate method instead of a constructor is surprising, making the code more difficult to follow for newcomers to the project. Returning null
can, as always, result in surprises
Proposed Solution
N/A
Acceptance Criteria
Description
The Meta Store rule should be only internally represented and instantiable. Although not mission critical, it would be nice to ensure that this is the case. If external users can create Meta Store rules, they may run into bugs and other undefined behaviors.
Acceptance Criteria
MetaStoreRule
cannot be instantiated by external clientsTests are currently not very granular and, in general, poorly organized.
Acceptance Criteria:
MainTests.assertCreatesGame
becomes two methods: one for the scanner, one for CLAIoUtils
interface LevelTests
is redundant, already tested within PlayTests
)Description
Currently, I/O logic (printing prompts, getting input, enforcing typed input) is scattered about the three classes in the main
package
Problems
Logic is probably not DRY. It's also not the most readable
Proposed Solution
Create a new main.IO
class to handle all IO
Acceptance Criteria
Is your feature request related to a problem? Please describe.
When I provide command-line arguments, I only want to solve/play one level. Do not prompt me to enter an infinite loop, as that makes it more difficult to automate usage of the project.
Describe the solution you'd like
Don't prompt for infinite loop, just return 0 if game was solved, nonzero otherwise with informative error message
Describe alternatives you've considered
Currently I have to wrap all scripts using this with "no" inputs and provide that as well, wrapped in a scanner. Lots of maintenance code when a simple fix is possible
Additional context
N/A
Acceptance criteria
Description
Currently Rule
instances are created using Rule.makeRule
and Rule.ruleFromString
Problems
This is not the default way to instantiate a type, and surprises the developer, making the code harder to follow.
Proposed Solution
Use constructors
Acceptance Criteria
Rule.makeRule
Rule.ruleFromString
Description
Documenting the history of this project would be good practice to better understand how it has historically functioned
Acceptance Criteria
Right now, the user can only solve a given game. Playing the game could be a lot of fun.
Description
The naming is murky: transitioning from "game" to "level" hasn't been consistent, and what exactly a "test case" is compared to a "level" isn't immediately clear.
Problems
Ambiguity is bad!
Proposed Solution
CalculatorGame
should call it a level.solver.Game
interface should probably be renamed solver.Level
.CalculatorGame
class should be renamed, but remain concise, maybe CalculatorLevel
?Acceptance Criteria
Description
Run the tests on PR to absolutely verify that everything is working before merge
Acceptance Criteria
Description
Creating instances of CalculatorGame
currently results in null
often or throwing exceptions. Maybe Optional would fix this issue?
Acceptance Criteria
Description
Rule subclass constructors are usually public
Problems
Other packages shouldn't be able to create rules except through the Rule.makeRule
method.
Proposed Solution
Make Rule subclass constructors package-level visible.
Acceptance Criteria
Description
Right now, Config.java
acts as one monolith of nearly all config settings
Problems
Monoliths are bad and violate SRP. It's becoming difficult to read/maintain and it's unclear exactly what code belongs there
Proposed Solution
Split config into several files
Acceptance Criteria
For the Main
class, any old input is allowed and it's super gross. The user should never see exceptions.
Description
The pad rule logic is duplicated in PadRule.java
and StoreRule.java
.
Problems
This isn't DRY
Proposed Solution
Have StoreRule
call a package
visible method in PadRule
Acceptance Criteria
Is your feature request related to a problem? Please describe.
As a user,
I want to be able to create my own rules.
That would be really fun for me.
Describe the solution you'd like
Let me input a rule somehow to the program and then create levels using that rule. Ideally, the rule is persistent across runs.
Describe alternatives you've considered
Right now, as a user, I can't create my own rules at all.
Additional context
N/A
Acceptance criteria
main.Main
)Description
Currently, to quit Developer.main
, the user enters Config.QUIT == "n "
Problems
That's a gross entry. It ends with a space.
Proposed Solution
Trim the comparison so that n
is also valid input
Acceptance Criteria
Developer
quit entry logicDescription
Some of this code is super gross due to weird formatting behaviors
Acceptance Criteria
Description
The Meta Store rule is currently hidden from users.
Problems
Program functionality is ambiguous to users. They also cannot use Meta Store rules in the future "play" logic
Proposed Solution
The Meta Store rule should not be necessarily tied to a Store rule. If it is added to a game without a Store rule, an exception should be thrown. If it is explicitly added to a game by a user, a message should be printed to tell users that it is not necessary to add the rule.
Acceptance Criteria
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.