Sample

Schnappinger/aoi/artofillusion.procedural.MaxModule

Human rating uses the original dataset scale.

Human3
Lines103

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
35.5Δ 9.0
Scalabrino0.5520–1; higher is more readable
14.4Δ 12.0
Dorn0.2680–1; higher is more readable
46.2Δ 19.8
Mi0.4110–1; higher is more readable
25.4Δ 1.0
LLOC46Logical lines; fewer is more readable
40.6Δ 14.2
DeepSeek V4 Pro160–20; mean of three runs
47.4Δ 21.0
GPT-6.1 Sol150–20; mean of three runs
25.7Δ 0.7
BTTF0.3450–1; higher is more readable
26.7Δ 0.3
Human31–4; original rating
26.4

Views

Source code

/* Copyright (C) 2000-2009 by Peter Eastman This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ package artofillusion.procedural; import artofillusion.math.*; import java.awt.*; /** This is a Module which returns the maximum of two numbers. */ public class MaxModule extends Module { double lastBlur, value, error; int which; boolean valueOk; public MaxModule(Point position) { super("Max", new IOPort [] {new IOPort(IOPort.NUMBER, IOPort.INPUT, IOPort.TOP, new String [] {"Value 1", "(0)"}), new IOPort(IOPort.NUMBER, IOPort.INPUT, IOPort.BOTTOM, new String [] {"Value 2", "(0)"})}, new IOPort [] {new IOPort(IOPort.NUMBER, IOPort.OUTPUT, IOPort.RIGHT, new String [] {"Maximum"})}, position); } /* New point, so the inputs will need to be compared again. */ public void init(PointInfo p) { valueOk = false; } /* Compare the two inputs. */ public double getAverageValue(int which, double blur) { if (valueOk && blur == lastBlur) return value; valueOk = true; double value1 = (linkFrom[0] == null) ? 0.0 : linkFrom[0].getAverageValue(linkFromIndex[0], blur); double value2 = (linkFrom[1] == null) ? 0.0 : linkFrom[1].getAverageValue(linkFromIndex[1], blur); double error1 = (linkFrom[0] == null) ? 0.0 : linkFrom[0].getValueError(linkFromIndex[0], blur); double error2 = (linkFrom[1] == null) ? 0.0 : linkFrom[1].getValueError(linkFromIndex[1], blur); double min1 = value1-error1; double max1 = value1+error1; double min2 = value2-error2; double max2 = value2+error2; if (max1 < min2) { value = value2; error = error2; which = 1; } else if (max2 < min1) { value = value1; error = error1; which = 0; } else if (value1 > value2) { value = value1; double maxmin = (min1 < min2 ? min2 : min1); error = Math.abs(value-maxmin); which = 0; } else { value = value2; double maxmin = (min1 < min2 ? min2 : min1); error = Math.abs(value-maxmin); which = 1; } return value; } /* Determine which input to use, and get its error. */ public double getValueError(int which, double blur) { if (!valueOk || blur != lastBlur) getAverageValue(which, blur); return error; } /* Determine which input to use, and get its gradient. */ public void getValueGradient(int which, Vec3 grad, double blur) { if (!valueOk || blur != lastBlur) getAverageValue(which, blur); if (linkFrom[which] == null) grad.set(0.0, 0.0, 0.0); else linkFrom[which].getValueGradient(linkFromIndex[which], grad, blur); } }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.3561.865−117.542
Source linesThe number of non-empty source lines.103+41.2
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.974−7.46

Intercept 8.87 + feature contributions = -74.932 (log-odds).
Score = sigmoid(-74.932) = 0.

Score0.552

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.104−2.646
Indentation frequencyHow rapidly indentation changes from line to line.95+2.549
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.95−1.759
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.117.981−1.332
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.117.971+1.099
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.102.84+1.028
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.098−0.013

Intercept 0.07 + feature contributions = -1.005 (log-odds).
Score = sigmoid(-1.005) = 0.268.

Score0.411
Score46
Run 1

The code is generally readable with clear structure and intent. The class has a logical organization, with a constructor, initialization, and three related methods for computing values, errors, and gradients. Nesting is minimal—conditional logic is flat and easy to follow. The use of comments before each method explains purpose well, though some comments are redundant ('Compare the two inputs' on a method named getAverageValue). Variable names are mostly descriptive, but some are cryptic (e.g., 'which', 'linkFrom[0]'). The getAverageValue method is somewhat long and mixes multiple responsibilities: value calculation, error estimation, and caching. Action granularity is mostly one action per line, but the repeated ternary checks for null inputs add verbosity and hurt reading flow. The caching mechanism (valueOk, lastBlur) is not immediately obvious without closer inspection. Overall, the code is maintainable but could benefit from refactoring to extract null-check helpers and separate error calculation for improved clarity.

Run 2

The code is generally well-structured and readable. It has a clear class purpose, flat nesting, and concise methods. Naming is mostly clear, though `which`, `valueOk`, and parameter shadowing (`which` in getAverageValue and getValueError) slightly reduce clarity. The constructor is long due to IOPort configuration but follows a consistent pattern. The caching logic using `valueOk` and `lastBlur` is a bit implicit but understandable. Action granularity is good: one main operation per line in the core conditional logic. The handling of null links with ternaries is repetitive but straightforward. Overall, the code is maintainable and easy to follow, with minor room for improvement in variable naming and reducing duplication.

Run 3

The code is generally clear and well-structured. The class has a single purpose, methods are short, and comments explain non-obvious parts. The constructor uses clear IOPort definitions. However, readability is slightly reduced by the repeated ternary null-check pattern for each input, which makes getAverageValue longer and more cluttered than necessary. The getValueGradient method names its parameter 'which' but uses an instance field of the same name, creating potential ambiguity. Long lines in the constructor and method calls also reduce readability somewhat. Overall, the logic is understandable, but it could be improved with a helper method to read input values and errors, reducing duplication.

Run 1

Code Structure: Methods are logically separated into initialization, value calculation, error retrieval, and gradient retrieval, though shared mutable state complicates understanding. Nesting: Shallow conditionals and early returns keep control flow manageable. Clarity of intent: The class description and method names communicate its purpose, but the uncertainty calculations lack explanation. The parameter 'which' shadows the field, obscuring which input is selected, and lastBlur is checked without being updated. Code length: Generally compact, although repeated input lookups and similar branch bodies could be consolidated. Action granularity: Most lines perform one action, but the constructor packs substantial configuration into long expressions. Reading flow: Methods follow a natural progression, with consistent formatting and helpful comments; dense constructor formatting, omitted braces, and terse names such as 'maxmin' introduce friction.

Run 2

Code Structure: Methods logically separate initialization, value calculation, error retrieval, and gradient retrieval, although caching and input selection are mixed into calculation. Nesting: Shallow conditionals and early returns keep complexity manageable. Clarity of intent: The class description and method comments establish its purpose, but 'which' shadows the field, obscuring selected-input state, and lastBlur is checked without an evident update. Names such as 'maxmin' require interpretation, and overlapping error-range handling lacks explanation. Code length: Generally compact, though repeated input lookups and similar result-selection branches introduce duplication. Action granularity: Most lines perform one action; grouped field declarations and the dense constructor reduce scanability. Reading flow: Methods follow a natural progression, but long ternary expressions, inconsistent operator spacing, and subtle state dependencies interrupt otherwise straightforward reading.

Run 3

Code Structure: Methods separate initialization, value calculation, error retrieval, and gradient retrieval logically, although repeated input-access expressions and comparison branches could be simplified. Nesting: Shallow conditionals and an early return keep control flow easy to follow. Clarity of intent: The class description and method comments establish its purpose, but names such as which and maxmin are vague. The which parameters shadow the field, obscuring whether assignments represent the selected input or the method argument; lastBlur is checked but never updated, making caching intent harder to understand. Code length: Generally compact, with some duplicated calculations and assignments. Action granularity: Most statements perform one action per line, though grouped field declarations and the dense constructor reduce scanability. Reading flow: Method order and consistent indentation support natural reading, while long ternary expressions, tightly spaced arithmetic, and missing braces around short conditionals slightly impede it.