/vqdr/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/vqdr/trunk

« back to all changes in this revision

Viewing changes to tests/random-d6.vala

  • Committer: Gustav Hartvigsson
  • Date: 2024-12-21 22:39:17 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20241221223917-jbt2ylyz9nxjss49
various changes
[utils/utils.vala]
* Removed uneeded int32_abs function

[utils/stack]
* more informative error when trying to pop an empty stack.

[utils/random.vala]
* added c_names to functions (probobly not needed).

[utils/pair.vala]
* Made compact
* made FreeFunc delegates unowned to fix error
* added constructor Pair.with_free_func ().

[utils/named_vector.vala]
* made class compact.

[utils/meson.build]
* Reordered files in list
* added logger.vala.

[utils/logger.vala]
* Added fast and easy logger class.

[utils/fast_number.vala]
* added a bunch of cname CCode attributes.

[general]
* Spelling in comments and functions.

[meson.build]
* Made dependancies easier to read
* added vala posix dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    
38
38
    Test.add_func ("/VQDR/Expression/Dice/d6/roll_count", () => {
39
39
      Dice d = new Dice ();
40
 
      int count[7] = {0};
41
 
      int rolls = 1000000;
 
40
      int32 count[7] = {0};
 
41
      int32 rolls = 1000000;
42
42
      for (size_t i = 0; i < rolls; i++) {
43
 
        int r = d.roll ();
 
43
        uint32 r = d.roll ();
44
44
        
45
45
        count[r] += 1;
46
46
      }
47
 
      int total = 0;
48
 
      for (int i = 0; i < 6; i++) {
 
47
      int32 total = 0;
 
48
      for (int32 i = 0; i < 6; i++) {
49
49
        total += count[i];
50
50
      }
51
51
      
57
57
    
58
58
    Test.add_func ("/VQDR/Expression/Dice/d6/roll_probability", () => {
59
59
      Dice d = new Dice ();
60
 
      int count[7] = {0};
61
 
      int rolls = 1000000;
 
60
      int32 count[7] = {0};
 
61
      int32 rolls = 1000000;
62
62
      for (size_t i = 0; i < rolls; i++) {
63
 
        int r = d.roll ();
 
63
        uint32 r = d.roll ();
64
64
        
65
65
        count[r] += 1;
66
66
      }
67
 
      for (int i = 0; i < 6; i++) {
 
67
      for (int32 i = 0; i < 6; i++) {
68
68
        print ("------------\n");
69
69
        print ("count for %d : %\n", i + 1, count[i] );
70
70
        double procentile = ((double )count[i] / rolls) * 100;