/* * This is a cellular automaton library * * Copyright (C) 2016-2017 Antoine BARTUCCIO, Jean POREE DE RIDDER * * Licensed under the MIT License,(the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * hhttps://opensource.org/licenses/MIT * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * */ #include #include #include #include #include int main(){ int rule; int times; bool useSDL; bool cont = true; int col; int row; Matrix m1; Matrix m2; BooleanMatrix bmatrix; useSDL = YesOrNo("Do you want to use SDL library for matrix display ?"); printf("A random matrix will be generated\n"); printf("Enter the number of columns of this matrix\n"); col = SafeNumberInput(1, 30000); printf("Enter the number of rows of this matrix\n"); row = SafeNumberInput(1, 30000); bmatrix = CreateBooleanMatrix(col, row); bmatrix = RandomizeBooleanMatrix(bmatrix); m1 = newMatrix(bmatrix); FreeBooleanMatrix(bmatrix); DisplayMatrixGUI(m1, useSDL); while (cont){ printf("What rule do you want to apply to this matrix ?\n"); rule = SafeNumberInput(1, 481); printf("How many times do you want the rule to be applied ?\n"); times = SafeNumberInput(1, 100000); m2 = applyRules(m1,rule,times); freeMatrix(m1); DisplayMatrixGUI(m2, useSDL); cont = YesOrNo("Do you want to apply other rules on this matrix ?"); m1 = m2; } freeMatrix(m2); return 0; }